forked from cachix/devenv
-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (93 loc) · 2.86 KB
/
examples.yml
File metadata and controls
113 lines (93 loc) · 2.86 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: "Examples"
on:
workflow_call:
inputs:
repository:
description: "Repository to checkout"
required: false
type: string
default: ${{ github.repository }}
ref:
description: "Git ref to checkout"
required: false
type: string
system:
description: "System to run examples on"
required: true
type: string
runs-on:
description: "Runner to use"
required: true
type: string
nixpkgs-input:
description: "An optional nixpkgs input to test against"
required: false
type: string
jobs:
generate-examples:
runs-on: [self-hosted, linux]
outputs:
examples: ${{ steps.set-examples.outputs.examples }}
steps:
- name: Checkout base repo
uses: actions/checkout@v5
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
- name: Install Nix
uses: cachix/install-nix-action@v31
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Configure Cachix
uses: cachix/cachix-action@v16
with:
name: devenv
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Build devenv
run: |
path=$(nix build -L --print-out-paths)
echo "$path/bin" >> $GITHUB_PATH
- name: Fetch examples to run
id: set-examples
# Get test metadata filtered for current system
run: |
set -euxo pipefail
examples=$(devenv-run-tests generate-json examples)
echo "examples=$examples" >> $GITHUB_OUTPUT
examples:
needs: [generate-examples]
runs-on: ${{ fromJSON(inputs.runs-on) }}
name: ${{ matrix.example.name }} (${{ inputs.system }})
strategy:
fail-fast: false
matrix:
example: ${{ fromJSON(needs.generate-examples.outputs.examples) }}
steps:
- uses: actions/checkout@v5
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
- name: Install Nix
uses: cachix/install-nix-action@v31
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Configure Cachix
uses: cachix/cachix-action@v16
with:
name: devenv
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Build devenv
run: |
path=$(nix build -L --print-out-paths)
echo "$path/bin" >> $GITHUB_PATH
- name: Run examples
env:
NIXPKGS_INPUT: ${{ inputs.nixpkgs-input }}
run: |
args=()
if [ -n "$NIXPKGS_INPUT" ]; then
args+=(--override-input nixpkgs "$NIXPKGS_INPUT")
fi
devenv-run-tests run "${args[@]}" --only ${{ matrix.example.name }} examples