Temperature: Output board status #98
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: C/C++ stm32 build for the open-source embedded software | |
on: | |
push: | |
branches: [ 'main' ] | |
paths: ['STM32/**', '.github/workflows/stm32build.yml'] | |
pull_request: | |
branches: [ 'main' ] | |
paths: ['STM32/**', '.github/workflows/stm32build.yml'] | |
jobs: | |
# JOB to run change detection | |
changes: | |
runs-on: ubuntu-latest | |
# Required permissions | |
permissions: | |
pull-requests: read | |
contents: read | |
outputs: | |
# Expose matched filters as job 'packages' output variable | |
packages: ${{ steps.filter.outputs.changes }} | |
steps: | |
# gets file environment with submodule included for libraries | |
- uses: actions/checkout@v3 | |
with: | |
submodules: 'true' | |
# For pull requests it's not necessary to checkout the code | |
- uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
filters: | | |
AC: STM32/AC/** | |
AirconCtrl: STM32/AirconCtrl/** | |
DC: STM32/DC/** | |
LightController: STM32/LightController/** | |
OTP: STM32/OTP/** | |
Temperature: STM32/Temperature/** | |
run_unittests: | |
needs: changes | |
if: ${{ needs.changes.outputs.packages != '[]' && needs.changes.outputs.packages != '' }} | |
strategy: | |
matrix: | |
# Parse JSON array containing names of all filters matching any of changed files | |
package: ${{ fromJSON(needs.changes.outputs.packages) }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 # gets file environment with submodule included for libraries | |
with: | |
submodules: 'true' | |
# Check whether the unittest folder exist in the modified project. If so, run unittests. | |
- name: Check if unittests exist | |
id: unittests_exists | |
run: | | |
if [ -d "STM32/${{ matrix.package }}/UnitTesting" ]; then | |
echo 'exist=1' >> $GITHUB_ENV | |
else | |
echo 'exist=0' >> $GITHUB_ENV | |
fi | |
# Build and run unittests. If the unittest fails the line number is output. | |
- name: Run unittests | |
if: env.exist == '1' | |
run: | | |
cd "STM32/${{ matrix.package }}/UnitTesting" | |
cmake CMakeLists.txt | |
make | |
output=$(./CA_UnitTesting) | |
echo $output | |
if [[ $output =~ "failed" ]]; then | |
echo "Test failed" | |
exit 1 | |
fi | |
# Run the static code analysis test. | |
- name: Run static tests | |
run: STM32/CommonTests/code_generation_test.sh STM32/${{ matrix.package }} | |
build: | |
needs: changes | |
permissions: | |
pull-requests: read | |
contents: write | |
# If no changes has been made to projects above do not build | |
if: ${{ needs.changes.outputs.packages != '[]' && needs.changes.outputs.packages != '' }} | |
strategy: | |
matrix: | |
# Parse JSON array containing names of all filters matching any of changed files | |
package: ${{ fromJSON(needs.changes.outputs.packages) }} | |
runs-on: ubuntu-latest | |
steps: | |
# gets file environment with submodule included for libraries | |
- uses: actions/checkout@v3 | |
with: | |
submodules: 'true' | |
# Setup the compiler and compile the program | |
- uses: carlosperate/arm-none-eabi-gcc-action@v1 | |
# Generate the next release + tag for including in the build | |
- uses: copenhagenatomics/mono_release_on_push_action@master | |
id: release-on-push-1 | |
with: | |
bump_version_scheme: minor | |
# Tag prefix required for this action to update the most relevant version number | |
tag_prefix: "${{ matrix.package }}-" | |
# Note: This is a dry_run, because if something goes wrong in the build (next step), we | |
# don't want to actually make any release. | |
dry_run: "true" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Tag Filter | |
id: tagfilter | |
# Checks if the file pcbversion exists and that the first line is configured as a version number with v<number>.number and returns the first line, otherwise it returns v0.0. | |
run: echo "version=$(echo "${{ steps.release-on-push-1.outputs.tag_name }}" | cut -d'-' -f2)" >> $GITHUB_OUTPUT | |
# Build the upload artifacts | |
- run: make | |
working-directory: "STM32/${{ matrix.package }}/" | |
env: | |
VERSION_TAG: ${{ steps.tagfilter.outputs.version }} | |
# Upload the .elf and .bin file under the summary tab | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.package }} | |
path: | | |
STM32/${{ matrix.package }}/build/${{ matrix.package }}.elf | |
STM32/${{ matrix.package }}/build/${{ matrix.package }}.bin | |
- uses: copenhagenatomics/mono_release_on_push_action@master | |
id: release-on-push-2 | |
# tag only pushes to the main branch | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
with: | |
bump_version_scheme: minor | |
use_github_release_notes: true | |
tag_prefix: "${{ matrix.package }}-" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Read PCB version | |
id: pcbversion | |
# Checks if the file pcbversion exists and that the first line is configured as a version number with v<number>.number and returns the first line, otherwise it returns v0.0. | |
run: echo "version=$(if test -f STM32/${{ matrix.package }}/pcbversion && head -n 1 STM32/${{ matrix.package }}/pcbversion | grep -Eq "^v[0-9]+\.[0-9]+$"; then echo $(head -n 1 STM32/${{ matrix.package }}/pcbversion); else echo "v0.0"; fi)" >> $GITHUB_OUTPUT | |
- name: Read Breaking PCB version | |
id: breakingpcbversion | |
# Checks if the file pcbversion exists and that the second line is configured as a version number with v<number>.number and returns the second line, otherwise it returns the current pcb version if the second line does not match the structure or v0.0 if the file does not exist. | |
run: echo "breaking=$(if test -f STM32/${{ matrix.package }}/pcbversion && sed -n '2p' STM32/${{ matrix.package }}/pcbversion | grep -Eq "^v[0-9]+\.[0-9]+$"; then echo $(sed -n '2p' STM32/${{ matrix.package }}/pcbversion); else if test -f STM32/${{ matrix.package }}/pcbversion; then echo $(head -n 1 STM32/${{ matrix.package }}/pcbversion); else echo "v0.0"; fi; fi)" >> $GITHUB_OUTPUT | |
- name: Release | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} # upload only pushes to the main branch | |
uses: softprops/[email protected] | |
with: | |
files: | | |
**/*.elf | |
**/*.bin | |
tag_name: ${{ steps.release-on-push-2.outputs.tag_name }} | |
name: "${{ steps.release-on-push-2.outputs.tag_name }}-PCB${{ steps.pcbversion.outputs.version }}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Prepare zip file for Azure blob | |
run: zip -j ${{ matrix.package }}.zip STM32/${{ matrix.package }}/build/${{ matrix.package }}.elf STM32/${{ matrix.package }}/build/${{ matrix.package }}.bin | |
shell: bash | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.10" | |
- name: Test PCB file | |
run: python release_mgmt/updatePcbVersionList.py | |
env : | |
AZURE_BLOB_QUERYSTRING : ${{ secrets.AZURE_BLOB_QUERYSTRING }} | |
PCB_VERSION_FILE : "STM32/${{ matrix.package }}/pcbversion" | |
MODULE_NAME : ${{ matrix.package }} | |
- name: Manage PCB Versioning | |
run: python release_mgmt/managePcbVersions.py -c $(echo "${{ steps.pcbversion.outputs.version }}" | sed 's/[a-zA-Z]//g') -b $(echo "${{ steps.breakingpcbversion.outputs.breaking }}" | sed 's/[a-zA-Z]//g') -fw ${{ steps.tagfilter.outputs.version }} -m ${{ matrix.package }} | |
env : | |
AZURE_BLOB_QUERYSTRING : ${{ secrets.AZURE_BLOB_QUERYSTRING }} |