Skip to content

Commit 72fb7ef

Browse files
authored
Improve tests (#6)
* Improve tests
1 parent d5e1770 commit 72fb7ef

11 files changed

Lines changed: 61 additions & 23 deletions

File tree

.github/workflows/autotag.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
steps:
3333
- name: Check pull request
3434
id: check-pr
35-
uses: actions/github-script@v7
35+
uses: actions/github-script@v8
3636
with:
3737
retries: 3
3838
script: |
@@ -87,28 +87,28 @@ jobs:
8787
core.setOutput('PULL_SHA', pullSHA)
8888
8989
- name: Checkout code
90-
uses: actions/checkout@v4
90+
uses: actions/checkout@v6
9191
if: ${{ steps.check-pr.outputs.RELEASE_TYPE != '' }}
9292
with:
9393
fetch-depth: 0 # Ref: https://github.com/actions/checkout/issues/100
9494

9595
- name: Get current tag
9696
id: current-tag
97-
uses: "WyriHaximus/github-action-get-previous-tag@04e8485ecb6487243907e330d522ff60f02283ce" # v1.4.0 - latest as of 2025-04-27
97+
uses: "WyriHaximus/github-action-get-previous-tag@61819f33034117e6c686e6a31dba995a85afc9de" # v2.0.0 - latest as of 2026-03-21
9898
if: ${{ steps.check-pr.outputs.RELEASE_TYPE != '' }}
9999
with:
100100
fallback: v0.0.0
101101

102102
- name: Determine next semver version
103103
id: next-semver-version
104-
uses: madhead/semver-utils@36d1e0ed361bd7b4b77665de8093092eaeabe6ba # v4.3.0 - latest as of 2025-04-27
104+
uses: madhead/semver-utils@36d1e0ed361bd7b4b77665de8093092eaeabe6ba # v4.3.0 - latest as of 2026-03-21
105105
if: ${{ steps.check-pr.outputs.RELEASE_TYPE != '' }}
106106
with:
107107
version: ${{ steps.current-tag.outputs.tag }}
108108

109109
- name: Determine next tag
110110
id: next-tag
111-
uses: actions/github-script@v7
111+
uses: actions/github-script@v8
112112
if: ${{ steps.check-pr.outputs.RELEASE_TYPE != '' }}
113113
with:
114114
script: |
@@ -141,7 +141,7 @@ jobs:
141141
steps:
142142
- name: Create tag
143143
id: create-tag
144-
uses: actions/github-script@v7
144+
uses: actions/github-script@v8
145145
with:
146146
github-token: ${{ secrets.PAT_WORKFLOW }}
147147
retries: 3

.github/workflows/release.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
steps:
3131
- name: Check release tag
3232
id: check-tag
33-
uses: actions/github-script@v7
33+
uses: actions/github-script@v8
3434
with:
3535
script: |
3636
console.log('github.event_name', '${{ github.event_name }}')
@@ -51,7 +51,7 @@ jobs:
5151
5252
- name: Check tag semver
5353
id: check-tag-semver
54-
uses: madhead/semver-utils@36d1e0ed361bd7b4b77665de8093092eaeabe6ba # v4.3.0 - latest as of 2025-04-27
54+
uses: madhead/semver-utils@36d1e0ed361bd7b4b77665de8093092eaeabe6ba # v4.3.0 - latest as of 2026-03-21
5555
if: ${{ steps.check-tag.outputs.RELEASE_TAG != '' }}
5656
with:
5757
version: ${{ steps.check-tag.outputs.RELEASE_TAG }}
@@ -63,7 +63,7 @@ jobs:
6363
if: ${{ needs.check.outputs.RELEASE_TAG != '' }}
6464
steps:
6565
- name: Make a release
66-
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2 - latest as of 2025-04-27
66+
uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2.6.1 - latest as of 2026-03-21
6767
if: github.event.inputs.dryRun != 'true'
6868
with:
6969
tag_name: ${{ needs.check.outputs.RELEASE_TAG }}

.github/workflows/test.yaml

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,44 @@ on:
2828
default: test
2929

3030
jobs:
31-
31+
32+
test:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v6
37+
38+
- name: Install mise
39+
run: |
40+
curl https://mise.run | sh
41+
mise settings experimental=true
42+
43+
- name: Trust workspace
44+
run: mise trust
45+
46+
- name: Install dependencies
47+
run: mise exec -- mise install
48+
49+
- name: Configure project
50+
run: mise exec -- make configure
51+
52+
- name: Run formatting checks
53+
run: mise exec -- make format
54+
55+
- name: Run lint
56+
run: mise exec -- make lint
57+
58+
- name: Run static analysis
59+
run: mise exec -- make check
60+
61+
- name: Build project
62+
run: mise exec -- make build
63+
64+
- name: Run tests
65+
run: mise exec -- make test
66+
3267
test-amd64:
68+
needs: test
3369
runs-on: ubuntu-latest
3470
strategy:
3571
matrix:
@@ -42,15 +78,15 @@ jobs:
4278
steps:
4379
- name: Docker Setup QEMU
4480
if: matrix.platform != 'linux/amd64'
45-
uses: docker/setup-qemu-action@v3.6.0 # v3.6.0 - latest as of 2025-04-27
81+
uses: docker/setup-qemu-action@v4 # v4 - latest as of 2026-03-21
4682
with:
4783
platforms: all
4884

4985
- name: Docker Setup Buildx
50-
uses: docker/setup-buildx-action@v3.10.0 # v3.10.0 - latest as of 2025-04-27
86+
uses: docker/setup-buildx-action@v4 # v4 - latest as of 2026-03-21
5187

5288
- name: Checkout code
53-
uses: actions/checkout@v4 # v4.2.2 - latest as of 2025-04-27
89+
uses: actions/checkout@v6
5490

5591
- name: Create Buildx
5692
run: |
@@ -74,6 +110,7 @@ jobs:
74110
done
75111
76112
test-arm64:
113+
needs: test
77114
runs-on: ubuntu-24.04-arm
78115
strategy:
79116
matrix:
@@ -100,10 +137,10 @@ jobs:
100137

101138
steps:
102139
- name: Docker Setup Buildx
103-
uses: docker/setup-buildx-action@v3.10.0 # v3.10.0 - latest as of 2025-04-27
140+
uses: docker/setup-buildx-action@v4 # v4 - latest as of 2026-03-21
104141

105142
- name: Checkout code
106-
uses: actions/checkout@v4 # v4.2.2 - latest as of 2025-04-27
143+
uses: actions/checkout@v6
107144

108145
- name: Create Buildx
109146
run: |

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ if(BUILD_TESTS)
9898

9999
enable_testing()
100100
foreach(t app config debug error test)
101-
add_executable(tl_${t}_test tests/arch/generic/tl_${t}_test.c)
101+
add_executable(tl_${t}_test tests/unit/tl_${t}_test.c)
102102
target_link_libraries(tl_${t}_test unity tinyclib)
103103
add_test(NAME tl_${t}_test COMMAND tl_${t}_test)
104104
endforeach()

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CPPCHECK := $(shell if command -v cppcheck >/dev/null 2>&1; then echo cppcheck;
77
CLANG_TIDY_EXTRA_ARGS := $(shell if [ "$$(uname)" = "Darwin" ]; then echo "--extra-arg=--sysroot=$$(xcrun --show-sdk-path)"; fi)
88

99
SRC_FILES := src/*.c include/*.h
10-
TEST_FILES := tests/arch/generic/*.c
10+
TEST_FILES := tests/unit/*.c
1111
ALL_FILES := $(SRC_FILES) $(TEST_FILES)
1212

1313
help: ## Show available make targets
@@ -18,14 +18,15 @@ configure: ## Configure cmake
1818
cmake --preset default
1919

2020
build: ## Build the project
21+
@test -d "$(BUILD_DIR)" || cmake --preset default
2122
cmake --build --preset default
2223

2324
clean: ## Remove build directory
2425
@test -n "$(CURDIR)" && [ "$(CURDIR)" != "/" ]
2526
rm -rf "$(CURDIR)/$(BUILD_DIR)"
2627

27-
test: ## Build and run tests
28-
cmake --workflow --preset default
28+
test: ## Run tests
29+
ctest --preset default
2930

3031
format: ## Check code formatting
3132
@test -n "$(CLANG_FORMAT)" || { echo "error: clang-format not found"; exit 1; }
@@ -34,7 +35,7 @@ format: ## Check code formatting
3435
lint: ## Check code linting
3536
@test -n "$(CLANG_TIDY)" || { echo "error: clang-tidy not found"; exit 1; }
3637
$(CLANG_TIDY) -p $(BUILD_DIR) $(CLANG_TIDY_EXTRA_ARGS) \
37-
--header-filter="^$(CURDIR)/(src|include|tests)/" src/*.c tests/arch/generic/*.c
38+
--header-filter="^$(CURDIR)/(src|include|tests)/" src/*.c tests/unit/*.c
3839

3940
check: ## Static analysis
4041
@test -n "$(CPPCHECK)" || { echo "error: cppcheck not found"; exit 1; }

mise.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
cmake = "4.3.0"
66
"conda:make" = "4.4.1"
77
ninja = "1.13.2"
8-
"pipx:clang-format" = "latest"
9-
"pipx:clang-tidy" = "latest"
10-
"pipx:cppcheck" = "latest"
8+
"pipx:clang-format" = "22.1.1"
9+
"pipx:clang-tidy" = "22.1.0"
10+
"pipx:cppcheck" = "1.5.1"

0 commit comments

Comments
 (0)