Skip to content

Commit

Permalink
Huge refactoring to ease project maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
xanthio committed May 11, 2024
1 parent aa4b996 commit 487db22
Show file tree
Hide file tree
Showing 33 changed files with 2,001 additions and 1,467 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ env:
BUILD_TYPE: Release

jobs:
RetrieveTargetsMatrix:
uses: ./.github/workflows/create-matrix.yml

test-ubuntu:
runs-on: ubuntu-20.04
needs: RetrieveTargetsMatrix
strategy:
matrix:
family: [C0, F0, F1, F2, F3, F4, F7, G0, G4, H5, H7, L0, L1, L4, L5, U0, U5, WB, WL, MP1]
matrix: ${{ fromJSON(needs.RetrieveTargetsMatrix.outputs.matrix) }}
fail-fast: false

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install ARM toolchain
run: sudo apt-get install gcc-arm-none-eabi binutils-arm-none-eabi
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/create-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: MatrixCreator

run-name: "Creates supported target matrix for other jobs"

on:
workflow_call:
inputs:
labelname:
required: true
type: string
color:
required: false
default: "03234B"
type: string

jobs:
CreateLabel:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Print Job
run: echo "Create ${{ inputs.labelname }} labels"

- name: Create tag if doesn't exists
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
exists=$(gh label list --search ${{ inputs.labelname }} --json name --jq '.[0].name' | wc -l)
if [ "x$exists" == "x0" ]; then
gh label create ${{ inputs.labelname }} --color ${{ inputs.color }}
fi
30 changes: 30 additions & 0 deletions .github/workflows/create-matrix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: MatrixCreator

run-name: "Creates supported target matrix for other jobs"

on:
workflow_call:
outputs:
matrix:
description: "Supported targets for job matrixing"
value: ${{ jobs.CreateMatrix.outputs.matrix }}

jobs:
CreateMatrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.create-matrix.outputs.matrix }}
steps:
- name: Checkout repo
id: checkout
uses: actions/checkout@v4

- name: Create matrix
id: create-matrix
run: |
files=$(find cmake/stm32/ -name '*.cmake' -exec sh -c "basename {} | cut -f1 -d '.' | tr a-z A-Z" \; | sort)
deletes="COMMON DEVICES LINKER_LD"
for del in $deletes; do
files=(${files[@]/$del})
done
echo "matrix={\"family\":$(jq --compact-output --null-input '$ARGS.positional' --args -- ${files[@]})}" >> $GITHUB_OUTPUT
103 changes: 103 additions & 0 deletions .github/workflows/dependency-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Dependency Check

run-name: "Periodic check for dependency updates"

on:
schedule:
- cron: '17 4 * * *'

jobs:
RetrieveTargetsMatrix:
uses: ./.github/workflows/create-matrix.yml

CheckForSTReposRelease:
runs-on: ubuntu-latest
needs: RetrieveTargetsMatrix
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
run: |
http_code=$(curl --request GET \
--silent --write-out "%{http_code}" \
--url "https://api.github.com/repos/STMicroelectronics/STM32Cube${{matrix.family}}/tags" \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer $GH_TOKEN" \
-o body.json );
if [ "${http_code}" -ne "200" ]; then
echo "Failed (${http_code}) to get https://api.github.com/repos/STMicroelectronics/STM32Cube${{matrix.family}}/tags";
exit 1;
else
latest_cube_version=$(jq '.[0].name' body.json | sed -rn 's@\"@@gp' );
echo "Latest Cube Version: ${latest_cube_version}";
fi
echo "VERSION=${latest_cube_version}" >> $GITHUB_OUTPUT
- name: Get CMSIS version
id: get-latest-cmsis
run: |
FAMILY_L=$(echo "${{matrix.family}}" | tr '[:upper:]' '[:lower:]');
http_code=$(curl --request GET \
--silent --write-out "%{http_code}" \
--url "https://api.github.com/repos/STMicroelectronics/cmsis_device_${FAMILY_L}/tags" \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer $GH_TOKEN" \
-o body.json ); \
if [ "${http_code}" -ne "200" ]; then
echo "Failed (${http_code}) to get https://api.github.com/repos/STMicroelectronics/cmsis_device_${FAMILY_L}/tags";
echo "Assume we can use the one from cube";
latest_cmsis_version="cube";
else
latest_cmsis_version=$(jq '.[0].name' body.json | sed -rn 's@\"@@gp' );
fi
echo "Latest CMSIS Version: ${latest_cmsis_version}";
echo "VERSION=${latest_cmsis_version}" >> $GITHUB_OUTPUT
- name: Get HAL version
id: get-latest-hal
run: |
FAMILY_L=$(echo "${{matrix.family}}" | tr '[:upper:]' '[:lower:]');
http_code=$(curl --request GET \
--silent --write-out "%{http_code}" \
--url "https://api.github.com/repos/STMicroelectronics/stm32${FAMILY_L}xx_hal_driver/tags" \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer $GH_TOKEN" \
-o body.json ); \
if [ "${http_code}" -ne "200" ]; then
echo "Failed (${http_code}) to get https://api.github.com/repos/STMicroelectronics/stm32${FAMILY_L}xx_hal_driver/tags";
echo "Assume we can use the one from cube";
latest_hal_version="cube";
else
latest_hal_version=$(jq '.[0].name' body.json | sed -rn 's@\"@@gp' );
fi
echo "Latest HAL Version: ${latest_hal_version}";
echo "VERSION=${latest_hal_version}" >> $GITHUB_OUTPUT
- name: Update family file with latest values
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.VERSION }}\4@g' $family_src_file
sed -ri 's@(set\(CMSIS_${{ matrix.family }}_VERSION(\s+))(.*)(\))@\1${{ steps.get-latest-cmsis.outputs.VERSION }}\4@g' $family_src_file
sed -ri 's@(set\(HAL_${{ matrix.family }}_VERSION(\s+))(.*)(\))@\1${{ steps.get-latest-hal.outputs.VERSION }}\4@g' $family_src_file
- 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 }}
body: |
Update ${{ matrix.family }} to use latest ST Repos
29 changes: 29 additions & 0 deletions .github/workflows/label-management.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Manage Labels

run-name: "Dynamically create new Labels"

on:
push

jobs:
CreateProjectManagementLabel:
strategy:
matrix:
label: [ missing-devices, dependency-update ]
fail-fast: false
uses: ./.github/workflows/create-label.yml
with:
labelname: ${{ matrix.label }}

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"
85 changes: 85 additions & 0 deletions .github/workflows/new-device-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Missing device check

run-name: "Periodic check for new devices"

on:
schedule:
- cron: '17 4 * * *'

jobs:
RetrieveTargetsMatrix:
uses: ./.github/workflows/create-matrix.yml

CheckForMissingTargets:
runs-on: ubuntu-latest
needs: RetrieveTargetsMatrix
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")
[[ -z "${serie}" ]] && echo "Failed to find serie " && exit 0
echo "${{ matrix.family }} is ST ${serie} serie"
echo "SERIE=$serie" >> $GITHUB_OUTPUT
- name: Retrieve Serie (Family) JSON file
id: get-json-file
run: |
URL=https://www.st.com/bin/st/selectors/cxst/en.cxst-ps-grid.html/${{ steps.get-ss-id.outputs.SERIE }}.json
curl --request GET \
--silent --url ${URL} \
--header "User-Agent: Firefox/9000" >> data.json
- name: Get missing components list
id: get-missings
run: |
FAMILY_L=$(echo "${{ matrix.family }}" | tr '[:upper:]' '[:lower:]')
family_src_file=${GITHUB_WORKSPACE}/cmake/stm32/${FAMILY_L}.cmake
cat data.json | jq -r '.rows[].cells[0].value' | while read -r dev; do
d=${dev#*STM32}
if [ "0" -eq $(sed -rn "s@(\s+)(${d})@found@p" ${family_src_file} | wc -m) ]; then
echo "${dev} is missing from ${family_src_file}"
echo "- [ ] ${d}" >> missings
else
echo "${dev} found"
fi
done
- name: Manage issues
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
LABELS="${{ matrix.family }},missing-devices"
existing=$(gh issue list \
--label "${LABELS}" \
--state open \
--json number \
--jq '.[0].number')
if [ ! -f missings ] && [ ! -z ${existing} ]; then
echo "Closing existing issue ${existing}"
gh issue close "${existing}" \
--comment "${{ matrix.family }} has all its devices supported now"
fi
if [ -f missings ] && [ -z ${existing} ]; then
echo "Creating issue to report missing devices"
BODY="Not supported yet devices list:"
BODY="${BODY}"$'\n'"$(cat missings)"
gh issue create \
--title "${{ matrix.family }} has devices not supported" \
--label "${LABELS}" \
--body "$BODY"
fi
26 changes: 26 additions & 0 deletions cmake/stm32/c0.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,29 @@ target_compile_options(STM32::C0 INTERFACE
target_link_options(STM32::C0 INTERFACE
-mcpu=cortex-m0plus
)

list(APPEND STM32_ALL_DEVICES
C011D6
C011F4
C011F6
C011J4
C011J6
C031C4
C031C6
C031F4
C031F6
C031G4
C031G6
C031K4
C031K6
)

list(APPEND STM32_SUPPORTED_FAMILIES_LONG_NAME
STM32C0
)

list(APPEND STM32_FETCH_FAMILIES C0)

set(CUBE_C0_VERSION v1.1.0)
set(CMSIS_C0_VERSION v1.1.0)
set(HAL_C0_VERSION v1.1.0)
33 changes: 1 addition & 32 deletions cmake/stm32/common.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
set(STM32_SUPPORTED_FAMILIES_LONG_NAME
STM32C0
STM32F0 STM32F1 STM32F2 STM32F3 STM32F4 STM32F7
STM32G0 STM32G4
STM32H5
STM32H7_M4 STM32H7_M7
STM32L0 STM32L1 STM32L4 STM32L5
STM32U0 STM32U5
STM32WB_M4 STM32WL_M4 STM32WL_M0PLUS
STM32MP1_M4 )
include(stm32/devices)

foreach(FAMILY ${STM32_SUPPORTED_FAMILIES_LONG_NAME})
# append short names (F0, F1, H7_M4, ...) to STM32_SUPPORTED_FAMILIES_SHORT_NAME
Expand Down Expand Up @@ -380,25 +371,3 @@ if(NOT (TARGET STM32::Nano::FloatScan))
$<$<C_COMPILER_ID:GNU>:-Wl,--undefined,_scanf_float>
)
endif()

include(stm32/utilities)
include(stm32/c0)
include(stm32/f0)
include(stm32/f1)
include(stm32/f2)
include(stm32/f3)
include(stm32/f4)
include(stm32/f7)
include(stm32/g0)
include(stm32/g4)
include(stm32/h5)
include(stm32/h7)
include(stm32/l0)
include(stm32/l1)
include(stm32/l4)
include(stm32/l5)
include(stm32/u0)
include(stm32/u5)
include(stm32/wb)
include(stm32/wl)
include(stm32/mp1)
Loading

0 comments on commit 487db22

Please sign in to comment.