-
Notifications
You must be signed in to change notification settings - Fork 0
187 lines (159 loc) · 6 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: Build and test the Nix shell environment
on:
pull_request:
push:
branches:
- main
- master
workflow_dispatch:
inputs:
mode:
description: 'Build mode: quick|default|full'
required: true
default: "default"
schedule:
- cron: '42 2 * * *'
env:
CACHIX_NAME: sigprof
jobs:
# The `setup` job determines the strategy for the real build job.
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
strategy: ${{ steps.strategy.outputs.result }}
steps:
- id: strategy
name: Determine build strategy
uses: actions/github-script@v7.0.1
with:
script: |
// Matrix for the "quick" mode.
const quickMatrix = {
os: [ "ubuntu-latest" ],
source: [
{ repo: "qmk/qmk_firmware", branch: "master" }
],
nixPath: [
"nixpkgs=channel:nixos-24.05"
]
};
// Matrix for the "default" and "full" modes.
const defaultMatrix = {
os: [ "ubuntu-latest", "macos-13", "macos-latest" ],
source: [
{ repo: "qmk/qmk_firmware", branch: "master" }
],
nixPath: [
"nixpkgs=channel:nixos-24.05"
]
};
// Determine the mode from workflow inputs.
let mode = "default";
if (context.eventName == "workflow_dispatch") {
const payload = context.payload;
const inputs = payload && payload.inputs;
mode = inputs && inputs.mode && inputs.mode.trim() || "default";
} else if (context.eventName == "schedule") {
mode = "full";
}
// Determine build strategy according to the selected mode.
const strategy = {
"fail-fast": !(mode == "full"),
"matrix": (mode == "quick") ? quickMatrix : defaultMatrix
};
// Print the resulting strategy to the log.
core.startGroup("Job strategy:");
core.info(JSON.stringify(strategy, null, 2));
core.endGroup();
// Return the strategy as the step output in the JSON format.
return strategy;
test:
needs: setup
strategy: ${{ fromJSON(needs.setup.outputs.strategy) }}
defaults:
run:
shell: bash
working-directory: qmk_firmware
runs-on: ${{ matrix.os }}
steps:
- name: Install Nix
uses: cachix/install-nix-action@v26
with:
nix_path: "${{ matrix.nixPath }}"
- name: Show nixpkgs version
working-directory: .
run: nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
- name: Setup Cachix
uses: cachix/cachix-action@v14
with:
name: ${{ env.CACHIX_NAME }}
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Checkout the project source
uses: actions/checkout@v4.1.1
with:
path: nix-devenv-qmk
- name: Checkout the QMK firmware source
uses: actions/checkout@v4.1.1
with:
path: qmk_firmware
repository: ${{ matrix.source.repo }}
ref: ${{ matrix.source.branch }}
submodules: recursive
- name: Configure the 'upstream' remote
run: git remote add upstream https://github.com/qmk/qmk_firmware
- name: Configure the udev rules
if: ${{ runner.os == 'Linux' }}
run: sudo install -o root -g root -m 0644 util/udev/50-qmk.rules /etc/udev/rules.d/
- name: Build the Nix shell environment
id: nix_shell
run: nix-shell ../nix-devenv-qmk/shell.nix --show-trace --run 'true'
- name: Update submodules
run: nix-shell ../nix-devenv-qmk/shell.nix --run 'make git-submodule'
- name: Test 'qmk doctor'
if: ${{ always() && (steps.nix_shell.outcome == 'success') }}
run: nix-shell ../nix-devenv-qmk/shell.nix --run 'qmk doctor'
- name: Test 'qmk setup'
if: ${{ always() && (steps.nix_shell.outcome == 'success') }}
run: |
# Test 'qmk setup'
# 'qmk setup' does not return the exit code of 'qmk doctor',
# therefore grepping the text output is needed.
nix-shell ../nix-devenv-qmk/shell.nix --run 'qmk setup' 2>&1 | tee qmk-setup.log
grep -q "QMK is ready to go" qmk-setup.log
- name: Test AVR build using 'make'
if: ${{ always() && (steps.nix_shell.outcome == 'success') }}
run: nix-shell ../nix-devenv-qmk/shell.nix --run 'make planck/rev5:default'
- name: Test Arm build using 'make'
if: ${{ always() && (steps.nix_shell.outcome == 'success') }}
run: nix-shell ../nix-devenv-qmk/shell.nix --run 'make planck/rev6:default'
- name: Test 'make clean'
if: ${{ always() && (steps.nix_shell.outcome == 'success') }}
run: nix-shell ../nix-devenv-qmk/shell.nix --run 'make clean'
- name: Force clean before testing 'qmk compile'
if: ${{ always() && (steps.nix_shell.outcome == 'success') }}
run: git clean -fdx
- name: Test AVR build using 'qmk compile'
if: ${{ always() && (steps.nix_shell.outcome == 'success') }}
run: nix-shell ../nix-devenv-qmk/shell.nix --run 'qmk compile -kb planck/rev5 -km default'
- name: Test Arm build using 'qmk compile'
if: ${{ always() && (steps.nix_shell.outcome == 'success') }}
run: nix-shell ../nix-devenv-qmk/shell.nix --run 'qmk compile -kb planck/rev6 -km default'
- name: Test 'qmk clean'
if: ${{ always() && (steps.nix_shell.outcome == 'success') }}
run: nix-shell ../nix-devenv-qmk/shell.nix --run 'qmk clean'
finish:
needs:
- setup
- test
runs-on: ubuntu-latest
if: always()
env:
ci_success: >-
${{
(needs.setup.result == 'success')
&& (needs.test.result == 'success')
}}
steps:
- name: Report CI status
run: $ci_success