summaryrefslogtreecommitdiff
path: root/.github
diff options
context:
space:
mode:
authorseth <[email protected]>2023-12-10 08:56:11 -0500
committerseth <[email protected]>2023-12-11 08:44:48 -0500
commitad840d3fab4d2e8dc27d265bbc0a08ed7e85c3a5 (patch)
tree2db39df327e5b9621fd41f1d8d1a8ac3dac8ceb6 /.github
parent8ac8de2593a9f5e3c160f95358b4db75d3a04640 (diff)
ci: use gha & attic for building/caching
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/ci.yaml124
-rw-r--r--.github/workflows/deploy.yaml19
-rw-r--r--.github/workflows/update-lock.yaml2
3 files changed, 135 insertions, 10 deletions
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
new file mode 100644
index 0000000..cf2ccbc
--- /dev/null
+++ b/.github/workflows/ci.yaml
@@ -0,0 +1,124 @@
+name: CI
+
+on:
+ pull_request:
+ workflow_dispatch:
+ workflow_call:
+ secrets:
+ ATTIC_TOKEN:
+ required: false
+
+jobs:
+ eval:
+ name: Evaluate flake
+
+ runs-on: ubuntu-latest
+
+ outputs:
+ matrix: ${{ steps.generate.outputs.matrix }}
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Install Nix
+ uses: DeterminateSystems/nix-installer-action@v9
+
+ - name: Generate matrix
+ id: generate
+ run: |
+ set -Eeu
+ echo "matrix=$(nix eval --show-trace --json .#githubWorkflow.matrix)" >> "$GITHUB_OUTPUT"
+
+ build:
+ needs: eval
+
+ strategy:
+ fail-fast: false
+ matrix: ${{ fromJSON(needs.eval.outputs.matrix) }}
+
+ runs-on: ${{ matrix.os }}
+
+ name: Build (${{matrix.attr}})
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Setup Qemu
+ if: matrix.arch == 'aarch64'
+ uses: docker/setup-qemu-action@v3
+ with:
+ platforms: "arm64"
+
+ - name: Install Nix
+ if: matrix.arch != 'aarch64'
+ uses: DeterminateSystems/nix-installer-action@v9
+
+ - name: Install Nix (with aarch64)
+ if: matrix.arch == 'aarch64'
+ uses: DeterminateSystems/nix-installer-action@v9
+ with:
+ extra-conf: "extra-platforms = aarch64-linux arm-linux"
+
+ - name: Setup Attic
+ if: github.event_name != 'pull_request'
+ uses: ryanccn/attic-action@v0
+ with:
+ endpoint: https://cache.mydadleft.me
+ cache: getchoo
+ token: ${{ secrets.ATTIC_TOKEN }}
+
+ - name: Setup Magic Nix Cache
+ uses: DeterminateSystems/magic-nix-cache-action@v2
+
+ - name: Build ${{ matrix.attr }}
+ run: nix build -L --accept-flake-config --fallback .#${{ matrix.attr }}
+
+ check:
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [macos-latest, ubuntu-latest]
+
+ runs-on: ${{ matrix.os }}
+
+ name: Check flake (${{ matrix.os }})
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Install Nix
+ uses: DeterminateSystems/nix-installer-action@v9
+
+ - name: Setup Attic
+ if: github.event_name != 'pull_request'
+ uses: ryanccn/attic-action@v0
+ with:
+ endpoint: https://cache.mydadleft.me
+ cache: getchoo
+ token: ${{ secrets.ATTIC_TOKEN }}
+
+ - name: Setup Magic Nix Cache
+ uses: DeterminateSystems/magic-nix-cache-action@v2
+
+ - name: Run check
+ run: nix flake check -L --accept-flake-config --show-trace
+
+ # https://github.com/orgs/community/discussions/26822#discussioncomment-3305794
+ gate:
+ name: CI Gate
+ needs: [build, check]
+ runs-on: ubuntu-latest
+
+ if: always()
+
+ steps:
+ - name: Exit with result
+ run: |
+ buildResult="${{ needs.build.result }}"
+ checkResult="${{ needs.check.result }}"
+
+ results=("$buildResult" "$checkResult")
+
+ for result in "${results[@]}"; do [ "$result" != "success" ] && exit 1; done
+
+ exit 0
diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml
index 9caf2df..113a847 100644
--- a/.github/workflows/deploy.yaml
+++ b/.github/workflows/deploy.yaml
@@ -1,29 +1,30 @@
name: Deploy systems
on:
- check_suite:
- types: [completed]
+ push:
+ branches: [main]
workflow_dispatch:
jobs:
+ ci:
+ name: CI
+ uses: ./.github/workflows/ci.yaml
+ secrets: inherit
+
deploy:
+ name: Deploy all
+ needs: ci
runs-on: ubuntu-latest
concurrency:
group: deploy
cancel-in-progress: true
- # https://github.com/sellout/bash-strict-mode/commit/9bf1d65c2f786a9887facfcb81e06d8b8b5f4667
- if: github.event.check_suite.app.name == 'Garnix CI'
- && github.event.check_suite.conclusion == 'success'
- && github.event.check_suite.latest_check_runs_count >= 12
- && github.event.check_suite.head_branch == 'main'
-
steps:
- uses: actions/checkout@v4
- name: Install Nix
- uses: nixbuild/nix-quick-install-action@v26
+ uses: DeterminateSystems/nix-installer-action@v9
- name: Setup local Nix cache
uses: DeterminateSystems/magic-nix-cache-action@v2
diff --git a/.github/workflows/update-lock.yaml b/.github/workflows/update-lock.yaml
index f9cdfed..1f2063c 100644
--- a/.github/workflows/update-lock.yaml
+++ b/.github/workflows/update-lock.yaml
@@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v4
- name: Install Nix
- uses: nixbuild/nix-quick-install-action@v26
+ uses: DeterminateSystems/nix-installer-action@v9
- name: Update lockfile & make PR
uses: DeterminateSystems/update-flake-lock@v20