From 0ddf0bfd407050e7970bf882ffbd2c7ba414e71b Mon Sep 17 00:00:00 2001 From: Fatih Cetinkaya <965295+devfacet@users.noreply.github.com> Date: Sat, 21 Mar 2026 21:21:09 -0400 Subject: [PATCH 1/9] Improve tests --- CMakeLists.txt | 2 +- Makefile | 9 +++++---- tests/{arch/generic => unit}/tl_app_test.c | 0 tests/{arch/generic => unit}/tl_config_test.c | 0 tests/{arch/generic => unit}/tl_debug_test.c | 0 tests/{arch/generic => unit}/tl_error_test.c | 0 tests/{arch/generic => unit}/tl_test_test.c | 0 7 files changed, 6 insertions(+), 5 deletions(-) rename tests/{arch/generic => unit}/tl_app_test.c (100%) rename tests/{arch/generic => unit}/tl_config_test.c (100%) rename tests/{arch/generic => unit}/tl_debug_test.c (100%) rename tests/{arch/generic => unit}/tl_error_test.c (100%) rename tests/{arch/generic => unit}/tl_test_test.c (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f4e4c9..6a4a09b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,7 +98,7 @@ if(BUILD_TESTS) enable_testing() foreach(t app config debug error test) - add_executable(tl_${t}_test tests/arch/generic/tl_${t}_test.c) + add_executable(tl_${t}_test tests/unit/tl_${t}_test.c) target_link_libraries(tl_${t}_test unity tinyclib) add_test(NAME tl_${t}_test COMMAND tl_${t}_test) endforeach() diff --git a/Makefile b/Makefile index 8c786dc..f25d1a4 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ CPPCHECK := $(shell if command -v cppcheck >/dev/null 2>&1; then echo cppcheck; CLANG_TIDY_EXTRA_ARGS := $(shell if [ "$$(uname)" = "Darwin" ]; then echo "--extra-arg=--sysroot=$$(xcrun --show-sdk-path)"; fi) SRC_FILES := src/*.c include/*.h -TEST_FILES := tests/arch/generic/*.c +TEST_FILES := tests/unit/*.c ALL_FILES := $(SRC_FILES) $(TEST_FILES) help: ## Show available make targets @@ -18,14 +18,15 @@ configure: ## Configure cmake cmake --preset default build: ## Build the project + @test -d "$(BUILD_DIR)" || cmake --preset default cmake --build --preset default clean: ## Remove build directory @test -n "$(CURDIR)" && [ "$(CURDIR)" != "/" ] rm -rf "$(CURDIR)/$(BUILD_DIR)" -test: ## Build and run tests - cmake --workflow --preset default +test: ## Run tests + ctest --preset default format: ## Check code formatting @test -n "$(CLANG_FORMAT)" || { echo "error: clang-format not found"; exit 1; } @@ -34,7 +35,7 @@ format: ## Check code formatting lint: ## Check code linting @test -n "$(CLANG_TIDY)" || { echo "error: clang-tidy not found"; exit 1; } $(CLANG_TIDY) -p $(BUILD_DIR) $(CLANG_TIDY_EXTRA_ARGS) \ - --header-filter="^$(CURDIR)/(src|include|tests)/" src/*.c tests/arch/generic/*.c + --header-filter="^$(CURDIR)/(src|include|tests)/" src/*.c tests/unit/*.c check: ## Static analysis @test -n "$(CPPCHECK)" || { echo "error: cppcheck not found"; exit 1; } diff --git a/tests/arch/generic/tl_app_test.c b/tests/unit/tl_app_test.c similarity index 100% rename from tests/arch/generic/tl_app_test.c rename to tests/unit/tl_app_test.c diff --git a/tests/arch/generic/tl_config_test.c b/tests/unit/tl_config_test.c similarity index 100% rename from tests/arch/generic/tl_config_test.c rename to tests/unit/tl_config_test.c diff --git a/tests/arch/generic/tl_debug_test.c b/tests/unit/tl_debug_test.c similarity index 100% rename from tests/arch/generic/tl_debug_test.c rename to tests/unit/tl_debug_test.c diff --git a/tests/arch/generic/tl_error_test.c b/tests/unit/tl_error_test.c similarity index 100% rename from tests/arch/generic/tl_error_test.c rename to tests/unit/tl_error_test.c diff --git a/tests/arch/generic/tl_test_test.c b/tests/unit/tl_test_test.c similarity index 100% rename from tests/arch/generic/tl_test_test.c rename to tests/unit/tl_test_test.c From 4f94715ffcf262dbd1619ec2e1393ef9bff24f86 Mon Sep 17 00:00:00 2001 From: Fatih Cetinkaya <965295+devfacet@users.noreply.github.com> Date: Sat, 21 Mar 2026 21:28:38 -0400 Subject: [PATCH 2/9] Add test-native job --- .github/workflows/test.yaml | 40 ++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9b55164..c13e3d6 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -28,8 +28,45 @@ on: default: test jobs: - + + test-native: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install mise + run: | + curl https://mise.run | sh + echo "$HOME/.local/bin" >> "$GITHUB_PATH" + "$HOME/.local/bin/mise" --version + + - name: Trust workspace + run: mise trust + + - name: Install dependencies + run: mise install + + - name: Configure project + run: make configure + + - name: Run formatting checks + run: make format + + - name: Run lint + run: make lint + + - name: Run static analysis + run: make check + + - name: Build project + run: make build + + - name: Run tests + run: make test + test-amd64: + needs: test-native runs-on: ubuntu-latest strategy: matrix: @@ -74,6 +111,7 @@ jobs: done test-arm64: + needs: test-native runs-on: ubuntu-24.04-arm strategy: matrix: From f0b27348b03bf854033a24e9fb3fba6eafe4843e Mon Sep 17 00:00:00 2001 From: Fatih Cetinkaya <965295+devfacet@users.noreply.github.com> Date: Sat, 21 Mar 2026 21:30:12 -0400 Subject: [PATCH 3/9] Tidy --- .github/workflows/test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c13e3d6..b682465 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -29,7 +29,7 @@ on: jobs: - test-native: + test: runs-on: ubuntu-latest steps: - name: Checkout code @@ -66,7 +66,7 @@ jobs: run: make test test-amd64: - needs: test-native + needs: test runs-on: ubuntu-latest strategy: matrix: @@ -111,7 +111,7 @@ jobs: done test-arm64: - needs: test-native + needs: test runs-on: ubuntu-24.04-arm strategy: matrix: From ffb0c97cbbd6f03951f2a8cd0ad8c5e759c30b4e Mon Sep 17 00:00:00 2001 From: Fatih Cetinkaya <965295+devfacet@users.noreply.github.com> Date: Sat, 21 Mar 2026 21:31:06 -0400 Subject: [PATCH 4/9] Enable mise experimental backends --- .github/workflows/test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b682465..a6a340d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -40,6 +40,7 @@ jobs: curl https://mise.run | sh echo "$HOME/.local/bin" >> "$GITHUB_PATH" "$HOME/.local/bin/mise" --version + mise settings experimental=true - name: Trust workspace run: mise trust From 6d8381149cbbc12de29ae6ca1f46ac9066799a80 Mon Sep 17 00:00:00 2001 From: Fatih Cetinkaya <965295+devfacet@users.noreply.github.com> Date: Sat, 21 Mar 2026 21:36:44 -0400 Subject: [PATCH 5/9] Pin versions --- mise.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mise.toml b/mise.toml index df13554..1d7b474 100644 --- a/mise.toml +++ b/mise.toml @@ -5,6 +5,6 @@ cmake = "4.3.0" "conda:make" = "4.4.1" ninja = "1.13.2" -"pipx:clang-format" = "latest" -"pipx:clang-tidy" = "latest" -"pipx:cppcheck" = "latest" +"pipx:clang-format" = "22.1.1" +"pipx:clang-tidy" = "22.1.0" +"pipx:cppcheck" = "1.5.1" From e3f272d201ff18d5e1c3a86ff6cf3a19bd41bf00 Mon Sep 17 00:00:00 2001 From: Fatih Cetinkaya <965295+devfacet@users.noreply.github.com> Date: Sat, 21 Mar 2026 21:40:52 -0400 Subject: [PATCH 6/9] Test --- .github/workflows/test.yaml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a6a340d..267fb86 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -38,33 +38,31 @@ jobs: - name: Install mise run: | curl https://mise.run | sh - echo "$HOME/.local/bin" >> "$GITHUB_PATH" - "$HOME/.local/bin/mise" --version mise settings experimental=true - name: Trust workspace run: mise trust - name: Install dependencies - run: mise install + run: mise exec -- mise install - name: Configure project - run: make configure + run: mise exec -- make configure - name: Run formatting checks - run: make format + run: mise exec -- make format - name: Run lint - run: make lint + run: mise exec -- make lint - name: Run static analysis - run: make check + run: mise exec -- make check - name: Build project - run: make build + run: mise exec -- make build - name: Run tests - run: make test + run: mise exec -- make test test-amd64: needs: test From ac4419077238106cd0464f2b8d19abe5ee885b58 Mon Sep 17 00:00:00 2001 From: Fatih Cetinkaya <965295+devfacet@users.noreply.github.com> Date: Sat, 21 Mar 2026 21:47:15 -0400 Subject: [PATCH 7/9] vsnprintf fix --- src/tl_error.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/tl_error.c b/src/tl_error.c index 59fb3f1..857874f 100644 --- a/src/tl_error.c +++ b/src/tl_error.c @@ -24,21 +24,26 @@ void tl_error_set(TLError *error, TLErrorCode code, const char *message, ...) { // Set message if provided if (message) { va_list args; + va_list args_copy; + va_start(args, message); - int size = vsnprintf(NULL, 0, message, args); - va_end(args); + va_copy(args_copy, args); + + int size = vsnprintf(NULL, 0, message, args_copy); + va_end(args_copy); if (size < 0) { + va_end(args); return; // ignore if vsnprintf fails } - error->message = malloc(size + 1); // include null terminator by adding 1 + error->message_size = (size_t)size + 1; + error->message = malloc(error->message_size); // include null terminator by adding 1 if (!error->message) { + va_end(args); return; // ignore if malloc fails } - error->message_size = size + 1; - va_start(args, message); vsnprintf((char *)error->message, error->message_size, message, args); va_end(args); } From 0c41809c192662a0a972083c6716f6a2d2ce0210 Mon Sep 17 00:00:00 2001 From: Fatih Cetinkaya <965295+devfacet@users.noreply.github.com> Date: Sat, 21 Mar 2026 21:53:42 -0400 Subject: [PATCH 8/9] Revert tl_error.c --- src/tl_error.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/tl_error.c b/src/tl_error.c index 857874f..59fb3f1 100644 --- a/src/tl_error.c +++ b/src/tl_error.c @@ -24,26 +24,21 @@ void tl_error_set(TLError *error, TLErrorCode code, const char *message, ...) { // Set message if provided if (message) { va_list args; - va_list args_copy; - va_start(args, message); - va_copy(args_copy, args); - - int size = vsnprintf(NULL, 0, message, args_copy); - va_end(args_copy); + int size = vsnprintf(NULL, 0, message, args); + va_end(args); if (size < 0) { - va_end(args); return; // ignore if vsnprintf fails } - error->message_size = (size_t)size + 1; - error->message = malloc(error->message_size); // include null terminator by adding 1 + error->message = malloc(size + 1); // include null terminator by adding 1 if (!error->message) { - va_end(args); return; // ignore if malloc fails } + error->message_size = size + 1; + va_start(args, message); vsnprintf((char *)error->message, error->message_size, message, args); va_end(args); } From be5c9a3488f7b52d93cc6e732413540845d93db4 Mon Sep 17 00:00:00 2001 From: Fatih Cetinkaya <965295+devfacet@users.noreply.github.com> Date: Sat, 21 Mar 2026 22:02:11 -0400 Subject: [PATCH 9/9] Update Github Actions --- .github/workflows/autotag.yaml | 12 ++++++------ .github/workflows/release.yaml | 6 +++--- .github/workflows/test.yaml | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/autotag.yaml b/.github/workflows/autotag.yaml index 38d67d1..f798922 100644 --- a/.github/workflows/autotag.yaml +++ b/.github/workflows/autotag.yaml @@ -32,7 +32,7 @@ jobs: steps: - name: Check pull request id: check-pr - uses: actions/github-script@v7 + uses: actions/github-script@v8 with: retries: 3 script: | @@ -87,28 +87,28 @@ jobs: core.setOutput('PULL_SHA', pullSHA) - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 if: ${{ steps.check-pr.outputs.RELEASE_TYPE != '' }} with: fetch-depth: 0 # Ref: https://github.com/actions/checkout/issues/100 - name: Get current tag id: current-tag - uses: "WyriHaximus/github-action-get-previous-tag@04e8485ecb6487243907e330d522ff60f02283ce" # v1.4.0 - latest as of 2025-04-27 + uses: "WyriHaximus/github-action-get-previous-tag@61819f33034117e6c686e6a31dba995a85afc9de" # v2.0.0 - latest as of 2026-03-21 if: ${{ steps.check-pr.outputs.RELEASE_TYPE != '' }} with: fallback: v0.0.0 - name: Determine next semver version id: next-semver-version - uses: madhead/semver-utils@36d1e0ed361bd7b4b77665de8093092eaeabe6ba # v4.3.0 - latest as of 2025-04-27 + uses: madhead/semver-utils@36d1e0ed361bd7b4b77665de8093092eaeabe6ba # v4.3.0 - latest as of 2026-03-21 if: ${{ steps.check-pr.outputs.RELEASE_TYPE != '' }} with: version: ${{ steps.current-tag.outputs.tag }} - name: Determine next tag id: next-tag - uses: actions/github-script@v7 + uses: actions/github-script@v8 if: ${{ steps.check-pr.outputs.RELEASE_TYPE != '' }} with: script: | @@ -141,7 +141,7 @@ jobs: steps: - name: Create tag id: create-tag - uses: actions/github-script@v7 + uses: actions/github-script@v8 with: github-token: ${{ secrets.PAT_WORKFLOW }} retries: 3 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3756291..7a6e5fe 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -30,7 +30,7 @@ jobs: steps: - name: Check release tag id: check-tag - uses: actions/github-script@v7 + uses: actions/github-script@v8 with: script: | console.log('github.event_name', '${{ github.event_name }}') @@ -51,7 +51,7 @@ jobs: - name: Check tag semver id: check-tag-semver - uses: madhead/semver-utils@36d1e0ed361bd7b4b77665de8093092eaeabe6ba # v4.3.0 - latest as of 2025-04-27 + uses: madhead/semver-utils@36d1e0ed361bd7b4b77665de8093092eaeabe6ba # v4.3.0 - latest as of 2026-03-21 if: ${{ steps.check-tag.outputs.RELEASE_TAG != '' }} with: version: ${{ steps.check-tag.outputs.RELEASE_TAG }} @@ -63,7 +63,7 @@ jobs: if: ${{ needs.check.outputs.RELEASE_TAG != '' }} steps: - name: Make a release - uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2 - latest as of 2025-04-27 + uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2.6.1 - latest as of 2026-03-21 if: github.event.inputs.dryRun != 'true' with: tag_name: ${{ needs.check.outputs.RELEASE_TAG }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 267fb86..99196b3 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -33,7 +33,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Install mise run: | @@ -78,15 +78,15 @@ jobs: steps: - name: Docker Setup QEMU if: matrix.platform != 'linux/amd64' - uses: docker/setup-qemu-action@v3.6.0 # v3.6.0 - latest as of 2025-04-27 + uses: docker/setup-qemu-action@v4 # v4 - latest as of 2026-03-21 with: platforms: all - name: Docker Setup Buildx - uses: docker/setup-buildx-action@v3.10.0 # v3.10.0 - latest as of 2025-04-27 + uses: docker/setup-buildx-action@v4 # v4 - latest as of 2026-03-21 - name: Checkout code - uses: actions/checkout@v4 # v4.2.2 - latest as of 2025-04-27 + uses: actions/checkout@v6 - name: Create Buildx run: | @@ -137,10 +137,10 @@ jobs: steps: - name: Docker Setup Buildx - uses: docker/setup-buildx-action@v3.10.0 # v3.10.0 - latest as of 2025-04-27 + uses: docker/setup-buildx-action@v4 # v4 - latest as of 2026-03-21 - name: Checkout code - uses: actions/checkout@v4 # v4.2.2 - latest as of 2025-04-27 + uses: actions/checkout@v6 - name: Create Buildx run: |