Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 115 additions & 15 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
- master
types: [opened, reopened, synchronize]

permissions:
contents: read

jobs:
build-windows:
name: Build sources on amd64 for ${{ matrix.os }}
Expand All @@ -17,7 +20,7 @@ jobs:
matrix:
os: [windows-latest, windows-2022]
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Build on ${{ matrix.os }} with MSVC
run: |
.\scripts\win_build.bat
Expand All @@ -33,12 +36,12 @@ jobs:
matrix:
os: [windows-latest, windows-2022]
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Get dependencies w/ chocolatey
uses: crazy-max/ghaction-chocolatey@v4
uses: crazy-max/ghaction-chocolatey@dfdcf5bba9c0a16358a21c13a06ec5c89024b3ac # v4
with:
args: install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System'
- uses: msys2/setup-msys2@v2
- uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2
with:
update: true
msystem: UCRT64
Expand Down Expand Up @@ -126,7 +129,7 @@ jobs:
# Confirm CMake installation
/usr/local/bin/cmake --version

- uses: actions/checkout@v6
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: Run compilation
run: |
Expand All @@ -142,26 +145,25 @@ jobs:
os: [ubuntu-latest]
compiler: [ gcc, clang ]
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Build on ${{ matrix.os }} with ${{ matrix.compiler }}
uses: uraimo/run-on-arch-action@v3.1.0
uses: uraimo/run-on-arch-action@f9b26e3a1a408d5fd530d20c17b9f3f4428ff8d9 # v3.1.0
with:
arch: aarch64
distro: ubuntu_latest
run: |
apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
clang \
cmake \
file \
make
export CC=${{ env.compiler }}
export CC=${{ matrix.compiler }}
"$CC" --version
cmake -DCFL_TESTS=On .
make all
CTEST_OUTPUT_ON_FAILURE=1 make test
env:
CC: ${{ matrix.compiler }}

build-unix-amd64:
name: Build sources on amd64 for ${{ matrix.os }} - ${{ matrix.compiler }}
runs-on: ${{ matrix.os }}
Expand All @@ -171,7 +173,7 @@ jobs:
os: [ubuntu-latest, macos-latest]
compiler: [ gcc, clang ]
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Build on ${{ matrix.os }} with ${{ matrix.compiler }}
run: |
echo "CC = $CC, CXX = $CXX"
Expand All @@ -181,6 +183,102 @@ jobs:
env:
CC: ${{ matrix.compiler }}

build-c-dialects:
name: Build sources with GNU ${{ matrix.standard }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
standard: [99, 17]
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Configure, build, and test
run: |
cmake -S . -B build \
-DCFL_TESTS=On \
-DCMAKE_C_STANDARD=${{ matrix.standard }} \
-DCMAKE_C_STANDARD_REQUIRED=On \
-DCMAKE_C_EXTENSIONS=On
cmake --build build -j2
ctest --test-dir build --output-on-failure

build-downstream:
name: Build downstream consumer ${{ matrix.consumer }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
consumer: [cmetrics, ctraces, fluent-bit]
steps:
- name: Check out CFL
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
path: cfl
- name: Check out ${{ matrix.consumer }}
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
repository: fluent/${{ matrix.consumer }}
path: consumer
submodules: recursive
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y bison flex libssl-dev libyaml-dev
- name: Report bundled CFL version
shell: bash
run: |
version_from()
{
local cmake_file="$1"
local major
local minor
local patch

major=$(sed -n 's/^set(CFL_VERSION_MAJOR *\([0-9][0-9]*\)).*/\1/p' "$cmake_file")
minor=$(sed -n 's/^set(CFL_VERSION_MINOR *\([0-9][0-9]*\)).*/\1/p' "$cmake_file")
patch=$(sed -n 's/^set(CFL_VERSION_PATCH *\([0-9][0-9]*\)).*/\1/p' "$cmake_file")
echo "${major}.${minor}.${patch}"
}

cfl_version=$(version_from cfl/CMakeLists.txt)
bundled_version=$(version_from consumer/lib/cfl/CMakeLists.txt)
echo "CFL under test: ${cfl_version}" >> "$GITHUB_STEP_SUMMARY"
echo "${{ matrix.consumer }} bundled CFL: ${bundled_version}" >> "$GITHUB_STEP_SUMMARY"
if [[ "$cfl_version" != "$bundled_version" ]]; then
echo "::warning::${{ matrix.consumer }} bundles CFL ${bundled_version}; current CFL is ${cfl_version}"
fi
- name: Replace bundled CFL with the version under test
run: |
rm -rf consumer/lib/cfl
mkdir -p consumer/lib/cfl
git -C cfl archive HEAD | tar -x -C consumer/lib/cfl
- name: Configure ${{ matrix.consumer }}
shell: bash
run: |
case "${{ matrix.consumer }}" in
cmetrics)
cmake -S consumer -B build -DCMT_TESTS=On
;;
ctraces)
cmake -S consumer -B build -DCTR_TESTS=On
;;
fluent-bit)
cmake -S consumer -B build \
-DFLB_ALL=Off \
-DFLB_EXAMPLES=Off \
-DFLB_SHARED_LIB=Off \
-DFLB_PROCESSOR_CONTENT_MODIFIER=On \
-DFLB_PROCESSOR_METRICS_SELECTOR=On \
-DFLB_PROCESSOR_SQL=On \
-DFLB_PROCESSOR_SAMPLING=On
;;
esac
- name: Build ${{ matrix.consumer }}
run: cmake --build build -j2
- name: Test ${{ matrix.consumer }}
if: matrix.consumer != 'fluent-bit'
run: ctest --test-dir build --output-on-failure

build-analysis-tests:
name: Build with various code analysis tools
strategy:
Expand All @@ -197,11 +295,11 @@ jobs:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
submodules: true

- uses: docker://lpenz/ghaction-cmake:0.19
- uses: docker://lpenz/ghaction-cmake@sha256:b59f08ebbbae1ed35650f774e3f2fd77e9c56e10cc841349d923ab4b65724aed
with:
pre_command: |
CMAKE_VERSION=3.20.0
Expand Down Expand Up @@ -230,12 +328,14 @@ jobs:
- build-debian
- build-unix-arm64
- build-unix-amd64
- build-c-dialects
- build-downstream
- build-analysis-tests
name: Required checks complete
runs-on: ubuntu-latest
permissions: {}
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # release/v1
with:
jobs: ${{ toJSON(needs) }}
12 changes: 7 additions & 5 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ on:
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
shellcheck:
runs-on: ubuntu-latest
name: Shellcheck
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- uses: ludeeus/action-shellcheck@master
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: ludeeus/action-shellcheck@00b27aa7cb85167568cb48a3838b75f4265f2bca
with:
ignore_paths: lib

Expand All @@ -21,10 +24,9 @@ jobs:
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- run: |
echo "::add-matcher::.github/actionlint-matcher.json"
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
bash <(curl -fsSL https://raw.githubusercontent.com/rhysd/actionlint/a443f344ff32813837fa49f7aa6cbc478d770e62/scripts/download-actionlint.bash) 1.7.9
./actionlint -color -shellcheck=
shell: bash

19 changes: 11 additions & 8 deletions .github/workflows/packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
- 'v*'
workflow_dispatch:

permissions:
contents: read

jobs:
build-distro-packages-arm64:
runs-on: ubuntu-latest
Expand All @@ -18,8 +21,8 @@ jobs:
matrix:
format: [ rpm, deb ]
steps:
- uses: actions/checkout@v6
- uses: uraimo/run-on-arch-action@v3.1.0
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: uraimo/run-on-arch-action@f9b26e3a1a408d5fd530d20c17b9f3f4428ff8d9 # v3.1.0
name: Build the ${{matrix.format}} packages
with:
arch: aarch64
Expand All @@ -36,7 +39,7 @@ jobs:
echo ${{ matrix.format }} | awk '{print toupper($0)}' | xargs -I{} cpack -G {}

- name: Store the master package artifacts
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ${{ matrix.format }}-arm64
path: |
Expand All @@ -51,14 +54,14 @@ jobs:

runs-on: [ ubuntu-latest ]
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Build the ${{matrix.format}} packages
run: |
cmake .
echo ${{ matrix.format }} | awk '{print toupper($0)}' | xargs -I{} cpack -G {}

- name: Store the master package artifacts
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ${{ matrix.format }}-amd64
path: |
Expand All @@ -74,7 +77,7 @@ jobs:
contents: write
steps:
- name: Download all artefacts
uses: actions/download-artifact@v8
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
path: artifacts/

Expand All @@ -84,7 +87,7 @@ jobs:
shell: bash

- name: Unstable release on push to master to make it easier to download
uses: pyTooling/Actions/releaser@r0
uses: pyTooling/Actions/releaser@b346408fef88bd4cfda9109149e9ec8338a32b15 # r0
continue-on-error: true
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -94,7 +97,7 @@ jobs:
artifacts/**/*

- name: Release on tag
uses: softprops/action-gh-release@v3
uses: softprops/action-gh-release@7c4723f7a335432393329f8f1c564994ce50185d # v3
if: startsWith(github.ref, 'refs/tags/')
with:
generate_release_notes: true
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
cmake_minimum_required(VERSION 3.20)
project(cfl C)
if(NOT DEFINED CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()
set(CMAKE_C_STANDARD_REQUIRED On)
set(CMAKE_C_EXTENSIONS On)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ CFL is a compact C library of data structures and low-level utilities used by
provides dynamic strings, intrusive lists, typed variants, arrays, key/value
containers, hashing, checksums, atomics, and an optional arena allocator.

CFL started as a C library for Fluent Bit, a.k.a. `C:\Floppy`.

The library is designed to be embedded. Callers can include the complete public
interface with:

Expand Down Expand Up @@ -125,6 +127,3 @@ CFL is distributed under the

Copyright is assigned to the CFL Authors. The contributor list is available on
[GitHub](https://github.com/fluent/cfl/graphs/contributors).

The name CFL has no required expansion. Historically, “C floppy” has been used
as an intentionally playful interpretation.
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ set(src

# Static Library
add_library(cfl-static STATIC ${src})
set_target_properties(cfl-static PROPERTIES
C_STANDARD ${CMAKE_C_STANDARD}
C_STANDARD_REQUIRED On
C_EXTENSIONS On)
target_link_libraries(cfl-static PUBLIC xxhash)

if(CFL_ATOMIC_NEEDS_LIBATOMIC)
Expand Down
Loading