✅ ci(artifacts) add RAM/Flash usage CI, basic badges… #2
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: build-artifacts | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout main branch | |
uses: actions/checkout@v3 | |
with: | |
ref: main # Ensure we're checking out the main branch | |
submodules: true # Initialize and update submodules automatically | |
fetch-depth: 0 # Fetch all history to ensure proper submodule handling | |
- name: Initialize submodules (in case it's not done automatically) | |
run: | | |
git submodule sync | |
git submodule update --init --recursive | |
- name: Install dependencies | |
run: sudo apt-get update && sudo apt-get install -y gcc-arm-none-eabi make | |
- name: Build project | |
run: cd firmware/iot-risk-logger-stm32l4 && make all | |
- name: Calculate Flash and RAM usage | |
run: | | |
SIZE_OUTPUT=$(arm-none-eabi-size build/iot-risk-logger-stm32l4.elf) | |
TEXT_SIZE=$(echo "$SIZE_OUTPUT" | awk 'NR==2 {print $1}') | |
DATA_SIZE=$(echo "$SIZE_OUTPUT" | awk 'NR==2 {print $2}') | |
BSS_SIZE=$(echo "$SIZE_OUTPUT" | awk 'NR==2 {print $3}') | |
FLASH_USAGE=$((TEXT_SIZE + DATA_SIZE)) | |
RAM_USAGE=$((DATA_SIZE + BSS_SIZE)) | |
echo "Flash usage: $FLASH_USAGE bytes" > flash_usage.txt | |
echo "RAM usage: $RAM_USAGE bytes" > ram_usage.txt | |
- name: Checkout artifacts branch | |
run: | | |
git fetch origin artifacts | |
git checkout artifacts | |
git merge main --no-edit # Merge changes from main into artifacts | |
- name: Update artifacts | |
run: | | |
mv flash_usage.txt artifacts/ | |
mv ram_usage.txt artifacts/ | |
git add artifacts/flash_usage.txt artifacts/ram_usage.txt | |
git commit -m "Update Flash and RAM usage artifacts" | |
git push origin artifacts |