diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0cf5527..0abb342 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,118 +1,67 @@ name: ci + on: workflow_dispatch: pull_request: push: tags: ['v*'] -jobs: - matrix: - runs-on: ubuntu-latest - outputs: - include: ${{ steps.set.outputs.include }} - steps: - - id: set - shell: bash - run: | - { - echo 'include<> $GITHUB_OUTPUT - - build-zig: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: mlugg/setup-zig@v2 - with: - version: master - - run: make big -j$(nproc) - - uses: actions/upload-artifact@v4 - with: - name: build-all - path: build/ +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true - build-msvc: - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - uses: microsoft/setup-msbuild@v2 - - run: msbuild tools\windows\sp\sp.sln /p:Configuration=Release /p:Platform=x64 /m - - uses: actions/upload-artifact@v4 - with: - name: build-msvc - path: tools/windows/sp/build/** +permissions: {} - test: - needs: [matrix, build-zig] +jobs: + zig: strategy: fail-fast: false matrix: - include: ${{ fromJSON(needs.matrix.outputs.include) }} - runs-on: ${{ matrix.runs-on }} + include: + - { id: x86_64-linux, os: ubuntu-latest, triples: x86_64-linux-none x86_64-linux-gnu x86_64-linux-musl } + - { id: aarch64-linux, os: ubuntu-24.04-arm, triples: aarch64-linux-none aarch64-linux-gnu aarch64-linux-musl } + - { id: macos, os: macos-14, triples: aarch64-macos } + - { id: windows, os: windows-latest, triples: x86_64-windows-gnu } + - { id: wasm, os: ubuntu-latest, triples: wasm32-wasi wasm32-freestanding } + name: ${{ matrix.id }} + runs-on: ${{ matrix.os }} steps: - - uses: actions/download-artifact@v4 + - uses: actions/checkout@v4 + - uses: mlugg/setup-zig@v2 with: - name: build-all - path: build + version: master + - if: runner.os == 'Windows' + run: choco install make --no-progress + - if: contains(matrix.triples, 'wasm32') + uses: bytecodealliance/actions/wasmtime/setup@v1 - shell: bash run: | - for dir in build/${{ matrix.triple }}/test build/cpp/${{ matrix.triple }}/test; do - chmod +x "$dir"/*${{ matrix.ext }} - for t in "$dir"/*${{ matrix.ext }}; do - echo "=== $t ===" - "$t" || exit 1 - done + for triple in ${{ matrix.triples }}; do + make ci TRIPLE=$triple done - test-wasm: - needs: build-zig + gcc: runs-on: ubuntu-latest steps: - - uses: actions/download-artifact@v4 - with: - name: build-all - path: build - - uses: bytecodealliance/actions/wasmtime/setup@v1 - - shell: bash - run: | - for dir in build/wasm32-wasi/test build/cpp/wasm32-wasi/test; do - for t in "$dir"/*.wasm; do - echo "=== $t ===" - wasmtime run "$t" || exit 1 - done - done + - uses: actions/checkout@v4 + - run: make ci CC=gcc - test-msvc: - needs: build-msvc + msvc: runs-on: windows-latest steps: - - uses: actions/download-artifact@v4 - with: - name: build-msvc - path: bin + - uses: actions/checkout@v4 + - uses: microsoft/setup-msbuild@v2 + - run: msbuild tools\windows\sp\sp.sln /p:Configuration=Release /p:Platform=x64 /m - shell: bash run: | - for t in bin/vs/Release/bin/*.exe; do + for t in tools/windows/sp/build/vs/Release/bin/*.exe; do echo "=== $t ===" "$t" || exit 1 done release: if: startsWith(github.ref, 'refs/tags/v') - needs: [test, test-wasm, test-msvc] + needs: [zig, gcc, msvc] runs-on: ubuntu-latest permissions: { contents: write } steps: diff --git a/Makefile b/Makefile index 97b34a8..e677c8f 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,10 @@ else EXE := endif +ifneq (,$(findstring wasm32,$(TRIPLE))) + RUNNER = wasmtime run +endif + CFLAGS = $(CFLAGS_LANG) -g -Werror=return-type -fsanitize=undefined,alignment -fno-sanitize-recover=all $(CFLAGS_PLATFORM) CFLAGS_TEST = -DSP_IMPLEMENTATION -DSP_TEST_IMPLEMENTATION -I. -Itest/tools -Itest CFLAGS_BENCH = $(CFLAGS_LANG) -g -Werror=return-type -O2 -DSP_IMPLEMENTATION -DUBENCH_ENABLE_PERF_COUNTERS -I. -Itest/bench -Itest/tools @@ -64,7 +68,7 @@ BENCH_BINARIES = $(addsuffix $(EXE),$(addprefix $(BENCH_DIR)/,$(BENCHES))) SP_HEADERS = sp.h $(wildcard sp/*.h) TEST_SOURCES = $(wildcard test/*/*.c) $(wildcard test/*/*.h) $(wildcard test/*/*/*.c) $(wildcard test/*/*/*.h) -.PHONY: all clean tests examples bench smoke big c cpp gcc tcc $(TRIPLES) +.PHONY: all clean tests examples bench smoke big c cpp gcc tcc check ci $(TRIPLES) all: examples tests tests: $(TEST_BINARIES) examples: $(EXAMPLE_BINARIES) @@ -87,6 +91,15 @@ c:; +$(MAKE) $(TRIPLES) examples tests gcc cpp:; +$(MAKE) MODE=cpp $(TRIPLES) examples tests gcc:; +$(MAKE) CC=gcc examples tests tcc:; +$(MAKE) CC=tcc examples tests +ci: + +$(MAKE) check + +$(MAKE) MODE=cpp check +check: all + @for t in $(TEST_BINARIES); do \ + echo "> $$t"; \ + $(RUNNER) $$t || exit 1; \ + echo ""; \ + done wasm: +$(MAKE) wasm32-wasi wasm32-freestanding +$(MAKE) MODE=cpp wasm32-wasi wasm32-freestanding