fix flake and add caching. #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| # Cancel in-progress runs for the same branch/PR | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| fmt-check: | |
| name: Format Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: DeterminateSystems/nix-installer-action@main | |
| - uses: DeterminateSystems/magic-nix-cache-action@main | |
| - name: Check formatting | |
| run: nix develop .#ci --command zig fmt --check src/ tests/ bench/ build.zig | |
| unit-tests: | |
| name: Unit Tests (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: DeterminateSystems/nix-installer-action@main | |
| - uses: DeterminateSystems/magic-nix-cache-action@main | |
| - name: Cache Zig build artifacts | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| .zig-cache | |
| ~/.cache/zig | |
| key: zig-unit-${{ matrix.os }}-${{ hashFiles('build.zig', 'build.zig.zon', 'src/**') }} | |
| restore-keys: | | |
| zig-unit-${{ matrix.os }}- | |
| - name: Run unit tests | |
| run: nix develop .#ci --command zig build test --summary all | |
| smoke-tests: | |
| name: Smoke Tests (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: DeterminateSystems/nix-installer-action@main | |
| - uses: DeterminateSystems/magic-nix-cache-action@main | |
| - name: Cache Zig build artifacts | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| .zig-cache | |
| ~/.cache/zig | |
| key: zig-smoke-${{ matrix.os }}-${{ hashFiles('build.zig', 'build.zig.zon', 'src/**') }} | |
| restore-keys: | | |
| zig-smoke-${{ matrix.os }}- | |
| - name: Start OpenSearch | |
| run: nix develop .#ci --command es-start | |
| - name: Run smoke tests | |
| run: nix develop .#ci --command zig build test-smoke --summary all | |
| env: | |
| ES_URL: http://localhost:9200 | |
| - name: Stop OpenSearch | |
| if: always() | |
| run: nix develop .#ci --command es-stop | |
| integration-tests: | |
| name: Integration Tests (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| needs: [unit-tests] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: DeterminateSystems/nix-installer-action@main | |
| - uses: DeterminateSystems/magic-nix-cache-action@main | |
| - name: Cache Zig build artifacts | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| .zig-cache | |
| ~/.cache/zig | |
| key: zig-integration-${{ matrix.os }}-${{ hashFiles('build.zig', 'build.zig.zon', 'src/**', 'tests/**') }} | |
| restore-keys: | | |
| zig-integration-${{ matrix.os }}- | |
| - name: Start OpenSearch | |
| run: nix develop .#ci --command es-start | |
| - name: Run integration tests | |
| run: nix develop .#ci --command zig build test-integration --summary all | |
| env: | |
| ES_URL: http://localhost:9200 | |
| - name: Stop OpenSearch | |
| if: always() | |
| run: nix develop .#ci --command es-stop | |
| build-check: | |
| name: Build Check (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: DeterminateSystems/nix-installer-action@main | |
| - uses: DeterminateSystems/magic-nix-cache-action@main | |
| - name: Nix build (reproducible) | |
| run: nix build | |
| - name: Nix flake check | |
| run: nix flake check |