-
Notifications
You must be signed in to change notification settings - Fork 5
83 lines (69 loc) · 2.52 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: CI
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
checks:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v24
- name: Nix Format Check
run: nix fmt -- . --check
- name: Nix Syntax Check
run: nix flake check
build-plan:
# Save some computation. If the checks fail, don't build.
needs: checks
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v24
with:
extra_nix_config: |
trusted-public-keys = public:O6JLD0yXzaJDPiQW1meVu32JIDViuaPtGDfjlOopU7o= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
substituters = https://hercules.servers.lowrisc.org/nix-cache/public/ https://cache.nixos.org/
- name: Build and Cache Attic
if: github.event_name != 'pull_request'
run: |
nix profile install github:zhaofengli/attic#attic
attic login --set-default lowrisc https://hercules.servers.lowrisc.org/nix-cache/ ${{ secrets.NIX_CACHE_TOKEN }}
attic push public $(which attic)
- name: Generate Build Matrix
id: set-matrix
run: |
matrix="$(nix eval --json .#githubActions.matrix)"
echo "matrix=$matrix" >> $GITHUB_OUTPUT
build:
needs: build-plan
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{fromJSON(needs.build-plan.outputs.matrix)}}
steps:
- name: checkout
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v24
with:
extra_nix_config: |
trusted-public-keys = public:O6JLD0yXzaJDPiQW1meVu32JIDViuaPtGDfjlOopU7o= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
substituters = https://hercules.servers.lowrisc.org/nix-cache/public/ https://cache.nixos.org/
- name: Setup Cache
if: github.event_name != 'pull_request'
run: |
nix profile install github:zhaofengli/attic#attic
attic login --set-default lowrisc https://hercules.servers.lowrisc.org/nix-cache/ ${{ secrets.NIX_CACHE_TOKEN }}
- name: Build
run: nix build ".#${{ matrix.attr }}"
- name: Upload Cache
if: github.event_name != 'pull_request'
run: |
attic push public result/