Repository navigation
172 lines (146 loc) · 5.28 KB
/
Copy pathpr.yml
File metadata and controls
172 lines (146 loc) · 5.28 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
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
name: Config File Check
description: Check config files are valid by performing a betaflight build (using master)
permissions:
contents: read
pull-requests: read
on:
pull_request:
branches:
- master
paths:
- 'configs/**'
jobs:
# -------------------------------------------------------
# JOB 1.1: Prepares the Matrix using a Marketplace Action
# -------------------------------------------------------
prepare_matrix:
name: Prepare Build List
runs-on: ubuntu-latest
outputs:
changed_files_json: ${{ steps.changed_files.outputs.all_changed_files_json }}
board_list_json: ${{ steps.process_dirs.outputs.board_list_json }}
is_empty: ${{ steps.check_empty.outputs.is_empty }}
steps:
- name: Checkout Code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Get Changed Files and Output JSON
id: changed_files
uses: tj-actions/changed-files@v44
with:
dir_names: true
json: true
- name: Display Debug Output
run: |
echo "--- ALL CHANGED FILES ---"
echo "${{ steps.changed_files.outputs.all_changed_files }}"
echo "-------------------------"
- name: Process Paths and Extract Board Names
id: process_dirs
run: |
RAW_DIR_JSON="${{ steps.changed_files.outputs.all_changed_files }}"
MAX_MATRIX_SIZE=10 # limit the matrix size to 10... in case a bulk update is occurring.
BOARD_LIST=$(echo "$RAW_DIR_JSON" | jq -c \
--argjson max_size "$MAX_MATRIX_SIZE" \
'[
# Iterate, process, and collect into a new array
.[] |
select(startswith("configs/")) |
rtrimstr("/") |
split("/") |
last |
select(. != "")
] | unique | .[:$max_size]')
# Fallback check: if the list is empty, default to an empty JSON array
if [[ -z "$BOARD_LIST" || "$BOARD_LIST" == "[]" ]]; then
BOARD_LIST="[]"
echo "No relevant board directories were changed."
fi
echo "Final Board List JSON: $BOARD_LIST"
echo "board_list_json=$BOARD_LIST" >> $GITHUB_OUTPUT
- name: Check if the Board List is Empty
id: check_empty
env:
BOARD_LIST: ${{ steps.process_dirs.outputs.board_list_json }}
run: |
# JQ checks if the length of the array is 0
IS_EMPTY=$(echo "$BOARD_LIST" | jq 'length == 0')
echo "Board list empty? $IS_EMPTY"
echo "is_empty=$IS_EMPTY" >> $GITHUB_OUTPUT
# -------------------------------------------------------
# JOB 1.2: Prepare the build capability
# -------------------------------------------------------
setup:
name: Setup Build Environment
runs-on: ubuntu-latest
steps:
- name: Checkout Firmware Repository
uses: actions/checkout@v5
with:
repository: 'betaflight/betaflight'
submodules: recursive
ref: 'master'
path: 'betaflight'
fetch-depth: 1
- name: Cache build toolchain
uses: actions/cache@v4
id: cache-toolchain
with:
path: betaflight/tools
key: ${{ runner.os }}-${{ hashFiles('betaflight/mk/tools.mk') }}
- name: Download and install toolchain
if: steps.cache-toolchain.outputs.cache-hit != 'true'
working-directory: ./betaflight
run: make arm_sdk_install
- name: Build pico tool and install
if: steps.cache-toolchain.outputs.cache-hit != 'true'
working-directory: ./betaflight
run: make picotool_install
# ----------------------------------------------------
# JOB 2: Runs the matrix for each Target Config
# ----------------------------------------------------
process_target:
name: Process Target ${{ matrix.target }}
needs: [prepare_matrix, setup]
runs-on: ubuntu-latest
if: ${{ needs.prepare_matrix.outputs.is_empty == 'false' }}
strategy:
fail-fast: false
matrix:
target: ${{ fromJson(needs.prepare_matrix.outputs.board_list_json) }}
steps:
- name: Checkout Config PR
uses: actions/checkout@v5
with:
path: 'config'
fetch-depth: 1
- name: Checkout Firmware Repository
uses: actions/checkout@v5
with:
repository: 'betaflight/betaflight'
submodules: recursive
ref: 'master'
path: 'betaflight'
fetch-depth: 1
- name: Fetch toolchain from cache
uses: actions/cache@v4
id: cache-toolchain
with:
path: betaflight/tools
key: ${{ runner.os }}-${{ hashFiles('betaflight/mk/tools.mk') }}
- name: Build Target ${{ matrix.target }}
working-directory: ./betaflight
run: |
TARGET="${{ matrix.target }}"
echo "--- Running check on $TARGET ---"
make EXTRA_FLAGS=-Werror CONFIG=$TARGET BETAFLIGHT_CONFIG=../config
- name: Upload Firmware Artifact
uses: actions/upload-artifact@v4
if: success()
with:
name: firmware-${{ matrix.target }}
path: |
betaflight/obj/*.hex
retention-days: 30
if-no-files-found: warn