summaryrefslogtreecommitdiff
path: root/.github/workflows/ci.yaml
diff options
context:
space:
mode:
authorseth <[email protected]>2023-12-22 21:16:49 -0500
committerseth <[email protected]>2023-12-23 03:09:13 +0000
commit0405273d9330d881ca73b0f232d7bc4a81a1b998 (patch)
tree3f42b219351314f41f589809128908b18925aa04 /.github/workflows/ci.yaml
parent4cc4e1fec5775a15663eb4d91d171276aa04ecf4 (diff)
actions: use nix-eval-jobs for ci
Diffstat (limited to '.github/workflows/ci.yaml')
-rw-r--r--.github/workflows/ci.yaml113
1 files changed, 113 insertions, 0 deletions
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
new file mode 100644
index 0000000..c4fc11e
--- /dev/null
+++ b/.github/workflows/ci.yaml
@@ -0,0 +1,113 @@
+name: CI
+
+on:
+ pull_request:
+ workflow_call:
+ secrets:
+ CACHIX_AUTH_TOKEN:
+ description: "auth token for cachi"
+ workflow_dispatch:
+
+jobs:
+ eval:
+ name: Evaluate flake
+ runs-on: ubuntu-latest
+
+ outputs:
+ matrix: ${{ steps.eval.outputs.matrix }}
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Install Nix
+ uses: DeterminateSystems/nix-installer-action@v9
+
+ - name: Setup Cachix
+ uses: cachix/cachix-action@v13
+ with:
+ name: getchoo
+ authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
+
+ - name: Evaluate jobs
+ id: eval
+ run: |
+ nix shell --inputs-from . \
+ nixpkgs#{bash,coreutils,jq,nix-eval-jobs} \
+ --command bash ./.github/eval-flake.sh
+
+ build:
+ needs: eval
+
+ strategy:
+ matrix: ${{ fromJSON(needs.eval.outputs.matrix) }}
+
+ name: Build (${{ matrix.attr }})
+ runs-on: ${{ matrix.os }}
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Install Nix
+ uses: DeterminateSystems/nix-installer-action@v9
+
+ - name: Setup Cachix
+ uses: cachix/cachix-action@v13
+ with:
+ name: getchoo
+ authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
+
+ - name: Check if cached
+ if: ${{ matrix.isCached }}
+ run: |
+ echo ${{ matrix.attr }} is already built!
+
+ - name: Run build
+ if: ${{ !matrix.isCached }}
+ run: |
+ nix build --print-build-logs --fallback \
+ .#hydraJobs.${{ matrix.attr }}
+
+ check:
+ strategy:
+ matrix:
+ os: [ubuntu-latest, macos-latest]
+
+ name: Check flake (${{ matrix.os }})
+ runs-on: ${{ matrix.os }}
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Install Nix
+ uses: DeterminateSystems/nix-installer-action@v9
+
+ - name: Setup Cachix
+ uses: cachix/cachix-action@v13
+ with:
+ name: getchoo
+ authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
+
+ - name: Run check
+ run: |
+ nix flake check \
+ --print-build-logs \
+ --fallback \
+ --show-trace \
+ --option allow-import-from-derivation true
+
+ gate:
+ needs: [build, check]
+
+ name: CI Gate
+ runs-on: ubuntu-latest
+
+ if: always()
+
+ steps:
+ - name: Exit with result
+ run: |
+ build_result="${{ needs.build.result }}"
+ check_result="${{ needs.check.result }}"
+ results=("$build_result" "$check_result")
+ for result in "${results[@]}"; do [ "$result" != "success" ] && exit 1; done
+ exit 0