-
Notifications
You must be signed in to change notification settings - Fork 1
252 lines (225 loc) · 9.37 KB
/
maintenance.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
name: Maintenance
run-name: "Nightly maintenance workflow"
on:
workflow_dispatch:
schedule:
- cron: '17 4 * * *'
permissions:
contents: write
issues: write
pull-requests: write
jobs:
RetrieveTargetsMatrix:
uses: ./.github/workflows/create-matrix.yml
CreateFamilyLabel:
needs: RetrieveTargetsMatrix
strategy:
matrix: ${{ fromJSON(needs.RetrieveTargetsMatrix.outputs.matrix) }}
fail-fast: false
uses: ./.github/workflows/create-label.yml
with:
labelname: ${{ matrix.family }}
color: "FFD200"
CreateProjectManagementLabel:
strategy:
matrix:
label: [ missing-devices, dependency-update ]
fail-fast: false
uses: ./.github/workflows/create-label.yml
with:
labelname: ${{ matrix.label }}
color: "03234B"
UpdateFamilyWithLatestSTReposTags:
runs-on: ubuntu-latest
needs: [RetrieveTargetsMatrix, CreateFamilyLabel, CreateProjectManagementLabel]
strategy:
matrix: ${{ fromJSON(needs.RetrieveTargetsMatrix.outputs.matrix) }}
fail-fast: false
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Print Job
run: echo "Updating ${{ matrix.family }} Family with latest ST tags"
- name: Get Cube version
id: get-latest-cube
uses: './.github/actions/getLatestTag'
with:
repository: STMicroelectronics/STM32Cube${{ matrix.family }}
- name: Get CMSIS version
id: get-latest-cmsis
uses: './.github/actions/getLatestTag'
with:
repository: STMicroelectronics/cmsis_device_${{ matrix.family }}
- name: Get HAL version
id: get-latest-hal
uses: './.github/actions/getLatestTag'
with:
repository: STMicroelectronics/stm32${{ matrix.family }}xx_hal_driver
- name: Update Cube with latest version
run: |
family_src_file=${GITHUB_WORKSPACE}/cmake/stm32/$(echo "${{ matrix.family }}" | tr '[:upper:]' '[:lower:]').cmake
sed -ri 's@(set\(CUBE_${{ matrix.family }}_VERSION(\s+))(.*)(\))@\1${{ steps.get-latest-cube.outputs.TAG }}\4@g' $family_src_file
- name: Update CMSIS with latest version
if: ${{ steps.get-latest-cmsis.outputs.TAG }}
run: |
family_src_file=${GITHUB_WORKSPACE}/cmake/stm32/$(echo "${{ matrix.family }}" | tr '[:upper:]' '[:lower:]').cmake
sed -ri 's@(set\(CMSIS_${{ matrix.family }}_VERSION(\s+))(.*)(\))@\1${{ steps.get-latest-cmsis.outputs.TAG }}\4@g' $family_src_file
- name: Update HAL with latest version
if: ${{ steps.get-latest-hal.outputs.TAG }}
run: |
family_src_file=${GITHUB_WORKSPACE}/cmake/stm32/$(echo "${{ matrix.family }}" | tr '[:upper:]' '[:lower:]').cmake
sed -ri 's@(set\(HAL_${{ matrix.family }}_VERSION(\s+))(.*)(\))@\1${{ steps.get-latest-hal.outputs.TAG }}\4@g' $family_src_file
- name: Generate token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
id: generate-token
- name: Create Dependancy update Pull Request
uses: peter-evans/create-pull-request@v6
with:
add-paths: cmake/stm32/
commit-message: Update ${{ matrix.family }} dependencies
branch: maintenance/${{ matrix.family }}-dependencies-update
delete-branch: true
title: Update ${{ matrix.family }} dependencies
labels: dependency-update, ${{ matrix.family }}
token: ${{ steps.generate-token.outputs.token }}
body: |
Update ${{ matrix.family }} to use latest ST Repos
CheckForMissingDevices:
runs-on: ubuntu-latest
needs: [RetrieveTargetsMatrix, CreateFamilyLabel, CreateProjectManagementLabel]
strategy:
matrix: ${{ fromJSON(needs.RetrieveTargetsMatrix.outputs.matrix) }}
fail-fast: false
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Print Job
run: echo "Looking for possible missing ${{ matrix.family }} devices"
- name: Prepare Env variables
id: prepare-env
run: |
FAMILY_L=$(echo "${{ matrix.family }}" | tr '[:upper:]' '[:lower:]')
family_src_file=${GITHUB_WORKSPACE}/cmake/stm32/${FAMILY_L}.cmake
{
echo "FAMILY_L=${FAMILY_L}"
echo "FAMILY_SRC_FILE=${family_src_file}"
} >> $GITHUB_OUTPUT
- name: Get serie from family file
id: get-ss-id-from-file
env:
FAMILY_SRC_FILE: ${{ steps.prepare-env.outputs.FAMILY_SRC_FILE }}
run: |
serie=($(sed -rn "s@#\s+SERIE\s+(SS[0-9]{4,})@\1@p" ${FAMILY_SRC_FILE} | tr -d '\r'))
echo "SERIE=${serie[@]}" >> $GITHUB_OUTPUT
- name: Get Serie (Family) number from ST website
id: get-ss-id-from-st
env:
FAMILY_L: ${{ steps.prepare-env.outputs.FAMILY_L }}
if: ${{ ! steps.get-ss-id-from-file.outputs.SERIE }}
run: |
URL=https://www.st.com/en/microcontrollers-microprocessors/stm32${FAMILY_L}-series.html
serie=$(curl --request GET \
--silent --url ${URL} \
--header "User-Agent: Firefox/9000" \
| sed -rne "s@(.*)(data-associated-to=\")(SS[0-9]{4,})(\".*)@\3@p")
if [ -n ${serie} ]; then
echo "SERIE=$serie" >> $GITHUB_OUTPUT
fi
- name: Retrieve Serie (Family) JSONs
id: retrieve-jsons
continue-on-error: true
if: ${{ steps.get-ss-id-from-st.outputs.SERIE || steps.get-ss-id-from-file.outputs.SERIE }}
env:
SERIE_ST: ${{ steps.get-ss-id-from-st.outputs.SERIE }}
SERIE_FILE: ${{ steps.get-ss-id-from-file.outputs.SERIE }}
run: |
SERIES=(${SERIE_ST} ${SERIE_FILE})
mkdir -p .series
for serie in ${SERIES[@]}; do
URL=https://www.st.com/bin/st/selectors/cxst/en.cxst-ps-grid.html/${serie}.json
echo "Retrieving ${URL}"
curl --request GET \
--silent --url "${URL}" \
--header "User-Agent: Firefox/9000" \
-o .series/${serie}.json
done
- name: Get existing devices list
id: get-devices-list
if: ${{ steps.retrieve-jsons.outcome == 'success' }}
run: |
{
echo "DEVICES<<EOF"
jq -r '.rows[].cells[0].value' .series/*.json | sort
echo "EOF"
} >> $GITHUB_OUTPUT
rm -rf .series
- name: Get unsupported (yet) devices list
id: get-unsupported-list
if: ${{ steps.get-devices-list.outputs.DEVICES }}
env:
FAMILY_SRC_FILE: ${{ steps.prepare-env.outputs.FAMILY_SRC_FILE }}
DEVICES: ${{ steps.get-devices-list.outputs.DEVICES }}
run: |
MISSINGS=(${DEVICES})
for dev in ${DEVICES}; do
d=${dev#*STM32}
if [ -z $(sed -rn "s@(\s+)(${d})@X@p" ${FAMILY_SRC_FILE}) ]; then
echo "Device ${dev} is not supported"
else
echo "Device ${dev} is already supported"
for i in "${!MISSINGS[@]}"; do
if [[ ${MISSINGS[i]} = ${dev} ]]; then
unset 'MISSINGS[i]'
fi
done
fi
done
if [ 0 -ne ${#MISSINGS[@]} ]; then
echo "MISSINGS=${MISSINGS[@]}" >> $GITHUB_OUTPUT
fi
- name: Check for existing Issue
id: get-issue-number
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LABELS: ${{ matrix.family }},missing-devices
run: |
existing=$(gh issue list \
--label "${LABELS}" \
--state open \
--json number \
--jq '.[0].number')
if [ -n ${existing} ]; then
echo "ISSUE=${existing}" >> $GITHUB_OUTPUT
fi
- name: Open an issue for missing devices
if: ${{ steps.get-unsupported-list.outputs.MISSINGS && ! steps.get-issue-number.outputs.ISSUE }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LABELS: ${{ matrix.family }},missing-devices
MISSINGS: ${{ steps.get-unsupported-list.outputs.MISSINGS }}
run: |
echo "Creating issue to report missing devices"
{
echo "Not supported yet devices list:"
for device in ${MISSINGS[@]}; do
echo "- [ ] ${device}"
done
} >> body.file
gh issue create \
--title "${{ matrix.family }} has devices not supported" \
--label "${LABELS}" \
--body-file body.file
- name: Close the issue as there are no missing devices anymore
if: ${{ steps.get-devices-list.outputs.DEVICES && ! steps.get-unsupported-list.outputs.MISSINGS && steps.get-issue-number.outputs.ISSUE }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE: ${{ steps.get-issue-number.outputs.ISSUE }}
run: |
echo "Closing existing issue ${ISSUE}"
gh issue close "${ISSUE}" \
--comment "${{ matrix.family }} has all its devices supported now"