From c1e94933f60229ddf660cfab2956b067931af7dc Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Sat, 11 Jul 2026 11:58:10 -0600 Subject: [PATCH 1/3] build: declare GNU C99 baseline Signed-off-by: Eduardo Silva --- CMakeLists.txt | 5 +++++ src/CMakeLists.txt | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba7ec04..6038fcc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5aa596b..6e69868 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) From 8333b3a360a71b7527e56f2801e11380151ebd23 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Sat, 11 Jul 2026 11:58:10 -0600 Subject: [PATCH 2/3] ci: align validation with Fluent Bit consumers Signed-off-by: Eduardo Silva --- .github/workflows/build.yaml | 130 ++++++++++++++++++++++++++++---- .github/workflows/lint.yaml | 12 +-- .github/workflows/packages.yaml | 19 +++-- 3 files changed, 133 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6969df2..b43f1ed 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -8,6 +8,9 @@ on: - master types: [opened, reopened, synchronize] +permissions: + contents: read + jobs: build-windows: name: Build sources on amd64 for ${{ matrix.os }} @@ -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 @@ -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 @@ -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: | @@ -142,9 +145,9 @@ 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 @@ -152,16 +155,15 @@ jobs: 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 }} @@ -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" @@ -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: @@ -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 @@ -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) }} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 12f9791..5b87f7f 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -3,6 +3,9 @@ on: pull_request: workflow_dispatch: +permissions: + contents: read + jobs: shellcheck: runs-on: ubuntu-latest @@ -10,8 +13,8 @@ jobs: 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 @@ -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 - diff --git a/.github/workflows/packages.yaml b/.github/workflows/packages.yaml index c37dafc..957b81a 100644 --- a/.github/workflows/packages.yaml +++ b/.github/workflows/packages.yaml @@ -9,6 +9,9 @@ on: - 'v*' workflow_dispatch: +permissions: + contents: read + jobs: build-distro-packages-arm64: runs-on: ubuntu-latest @@ -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 @@ -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: | @@ -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: | @@ -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/ @@ -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 }} @@ -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 From ed0fdb3dbb4bdcdbef6fce08fc10a601ad626719 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Sat, 11 Jul 2026 12:11:45 -0600 Subject: [PATCH 3/3] docs: a.k.a C:\Floppy Signed-off-by: Eduardo Silva --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b66cba3..6805bb4 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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.