-
Notifications
You must be signed in to change notification settings - Fork 4
91 lines (86 loc) · 2.75 KB
/
build.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
84
85
86
87
88
89
90
91
name: Build
on:
pull_request:
branches: [main]
push:
branches: [main]
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=channel:nixos-24.05-small
- name: Install devenv
run: |
nix profile install --accept-flake-config nixpkgs#devenv
devenv version
- name: Run tests
run: devenv test
build:
strategy:
matrix:
os:
- macos-13 # x86_64-darwin
- macos-latest # aarch64-darwin
- ubuntu-latest # x86_64-linux
fail-fast: false
runs-on: ${{ matrix.os }}
needs: [check]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v30
- name: Setup Cachix
uses: cachix/cachix-action@v15
with:
name: nixpkgs-terraform
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
skipPush: true
- name: Build packages
run: |
if grep -q authToken ~/.config/cachix/cachix.dhall; then
echo "Cachix token is present"
cachix watch-exec nixpkgs-terraform nix -- flake check --max-jobs 2
else
echo "Cachix token is not present"
nix flake check --max-jobs 2
fi
template:
runs-on: ubuntu-latest
timeout-minutes: 8
needs: [build]
strategy:
matrix:
template:
- name: config
test: nix flake metadata
- name: default
test: nix develop --accept-flake-config --impure -c terraform --version
- name: devenv
test: nix develop --accept-flake-config --impure -c terraform --version
- name: terranix
test: nix develop --accept-flake-config --impure -c terraform --version
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v30
- name: Replace inputs on templates
run: sed -i 's/github:stackbuilders\/nixpkgs-terraform/github:stackbuilders\/nixpkgs-terraform\/${{ github.sha }}/g' templates/*/flake.nix
- name: Create a temporary directory
run: echo "tmpdir=$(mktemp -d)" >> "$GITHUB_OUTPUT"
id: mktemp
- name: Scaffold a new project
run: nix flake init -t ${{ github.workspace }}#${{ matrix.template.name }}
working-directory: ${{ steps.mktemp.outputs.tmpdir }}
- name: Run test
run: ${{ matrix.template.test }}
working-directory: ${{ steps.mktemp.outputs.tmpdir }}