Skip to content

Nightly maintenance workflow #144

Nightly maintenance workflow

Nightly maintenance workflow #144

Workflow file for this run

name: Maintenance
run-name: "Nightly maintenance workflow"
on:
push
# 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: Get Serie (Family) number from ST website
id: get-ss-id
run: |
FAMILY_L=$(echo "${{ matrix.family }}" | tr '[:upper:]' '[:lower:]')
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) JSON
id: get-json
if: ${{ steps.get-ss-id.outputs.SERIE }}
env:
SERIE: ${{ steps.get-ss-id.outputs.SERIE }}
run: |
URL=https://www.st.com/bin/st/selectors/cxst/en.cxst-ps-grid.html/$SERIE.json
http_code=$(curl --request GET \
--silent --write-out "%{http_code}" \
--url "${URL}" \
--header "User-Agent: Firefox/9000" \
-o serie.json )
echo "HTTP_CODE=${http_code}" >> $GITHUB_OUTPUT
- name: Get existing devices list
id: get-devices-list
if: ${{ steps.get-json.outputs.HTTP_CODE == 200 }}
run: |
{
echo "DEVICES<<EOF"
jq -r '.rows[].cells[0].value' serie.json
echo "EOF"
} >> $GITHUB_OUTPUT
rm serie.json
- name: Get unsupported (yet) devices list
id: get-unsupported-list
if: ${{ steps.get-devices-list.outputs.DEVICES }}
env:
DEVICES: ${{ steps.get-devices-list.outputs.DEVICES }}
run: |
FAMILY_L=$(echo "${{ matrix.family }}" | tr '[:upper:]' '[:lower:]')
family_src_file=${GITHUB_WORKSPACE}/cmake/stm32/${FAMILY_L}.cmake
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"
MISSINGS=(${MISSINGS[@]/${dev}})
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-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"