Skip to content

Nightly maintenance workflow #185

Nightly maintenance workflow

Nightly maintenance workflow #185

Workflow file for this run

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"