forked from petejohanson/unified-zmk-config-template
-
Notifications
You must be signed in to change notification settings - Fork 158
131 lines (124 loc) · 5.36 KB
/
build.yml
File metadata and controls
131 lines (124 loc) · 5.36 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
on: [push, pull_request, workflow_dispatch]
name: Build
jobs:
matrix:
runs-on: ubuntu-latest
name: Fetch Build Keyboards
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install yaml2json
run: python3 -m pip install remarshal
- id: set-matrix
name: Fetch Build Matrix
run: |
matrix=$(yaml2json build.yaml | jq -c .)
yaml2json build.yaml
echo "::set-output name=matrix::${matrix}"
build:
runs-on: ubuntu-latest
container:
image: zmkfirmware/zmk-build-arm:2.5
needs: matrix
name: Build
strategy:
fail-fast: false
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
steps:
- name: Prepare variables
id: variables
run: |
if [ -n "${{ matrix.shield }}" ]; then
EXTRA_CMAKE_ARGS="-DSHIELD=${{ matrix.shield }}"
ARTIFACT_NAME="${{ matrix.shield }}-${{ matrix.board }}-zmk"
DISPLAY_NAME="${{ matrix.shield }} - ${{ matrix.board }}"
else
EXTRA_CMAKE_ARGS=
DISPLAY_NAME="${{ matrix.board }}"
ARTIFACT_NAME="${{ matrix.board }}-zmk"
fi
echo ::set-output name=extra-cmake-args::${EXTRA_CMAKE_ARGS}
echo ::set-output name=artifact-name::${ARTIFACT_NAME}
echo ::set-output name=display-name::${DISPLAY_NAME}
- name: Checkout
uses: actions/checkout@v2
- name: Cache west modules
uses: actions/cache@v2
env:
cache-name: cache-zephyr-modules
with:
path: |
modules/
tools/
zephyr/
bootloader/
zmk/
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('manifest-dir/west.yml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: West Init
run: west init -l config
- name: West Update
run: west update
- name: West Zephyr export
run: west zephyr-export
- name: West Build (${{ steps.variables.outputs.display-name }})
run: |
shell: bash
run: |
west build -s zmk/app -b ${{ matrix.board }} -- -DZMK_CONFIG=${GITHUB_WORKSPACE}/config ${{ steps.variables.outputs.extra-cmake-args }} ${{ matrix.cmake-args }} 2>&1 | tee build.log
- name: Troubleshooting (${{ steps.variables.outputs.display-name }})
if: ${{ failure() }}
shell: bash
run: |
# Provide helpful GitHub annotations if build fails:
echo "::notice::Build failed. See https://zmk.dev/docs/troubleshooting/ for help."
# Check that a given sed command ($1) returns a match when run over the
# build.log. Store the output of sed for further parsing.
match() {
output="$(sed -nE "$1" build.log)"
test -n "$output"
}
# Provide annotation for errors due to incorrect keycodes (e.g. `&kp ENTRE`)
# Error: nice_nano.dts.pre.tmp:74.137-138 syntax error
if match 's/^.+dts.pre.tmp:([0-9]+)\.([0-9]+).+ syntax error.*$/\1 \2/p'; then
read line_pos char_pos <<< $output
line=$(sed -n ${line_pos}p build/zephyr/${{ matrix.board }}.dts.pre.tmp)
value=$(cut -c${char_pos}- <<< $line | cut -f1 -d\ )
echo "::error::Error: Unable to parse \"${value}\" from line: ${line}"
# Provide annotation for errors due to missing parameters (e.g. `&mt LALT`):
# zephyr/include/generated/devicetree_unfixed.h:1415:44: error: 'DT_N_S_keymap_S_base_layer_P_bindings_IDX_1_PH_P_label' undeclared here (not in a function)
elif match 's/^.+error: .DT_N_S_keymap_S_(.+)_P_bindings_IDX_([0-9])_PH_P_label. undeclared here.+$/\1 \2/p'; then
read layer index <<< $output
echo "::error::Error: Problem with index ${index} on layer \"${layer}\"."
# Provide annotation for generic error messages such as:
# nice_nano.dts.pre.tmp:734.14-741.5: ERROR (phandle_references): /keymap/base_layer: Reference to non-existent node or label "kc"
elif match 's/^.+dts\.pre\.tmp\S+ ERROR (.+)$/\1/p'; then
echo "::error::Error ${output}"
fi
- name: ${{ steps.variables.outputs.display-name }} DTS File
if: ${{ always() }}
run: |
if [ -f "build/zephyr/${{ matrix.board }}.dts.pre.tmp" ]; then cat -n build/zephyr/${{ matrix.board }}.dts.pre.tmp; fi
if [ -f "build/zephyr/zephyr.dts" ]; then cat -n build/zephyr/zephyr.dts; fi
- name: ${{ steps.variables.outputs.display-name }} Kconfig file
run: cat build/zephyr/.config | grep -v "^#" | grep -v "^$"
- name: Rename artifacts
run: |
mkdir build/artifacts
if [ -f build/zephyr/zmk.uf2 ]
then
cp build/zephyr/zmk.uf2 "build/artifacts/${{ steps.variables.outputs.artifact-name }}.uf2"
elif [ -f build/zephyr/zmk.hex ]
then
cp build/zephyr/zmk.hex "build/artifacts/${{ steps.variables.outputs.artifact-name }}.hex"
fi
- name: Archive (${{ steps.variables.outputs.display-name }})
uses: actions/upload-artifact@v2
with:
name: firmware
path: build/artifacts