Skip to content

Commit

Permalink
✅ ci(artifacts) add RAM/Flash usage CI, basic badges to README
Browse files Browse the repository at this point in the history
  • Loading branch information
polesskiy-dev committed Aug 9, 2024
1 parent 5907f23 commit 755d109
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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: |
cd firmware/iot-risk-logger-stm32l4
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 firmware/iot-risk-logger-stm32l4/flash_usage.txt docs/artifacts/
mv firmware/iot-risk-logger-stm32l4/ram_usage.txt docs/artifacts/
git add docs/artifacts/flash_usage.txt docs/artifacts/ram_usage.txt
git commit -m "Update Flash and RAM usage artifacts"
git push origin artifacts
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
![CI Status](https://github.com/polesskiy-dev/iot-risk-logger-stm32l4/actions/workflows/ci.yml/badge.svg?branch=main)
[![codecov](https://codecov.io/gh/polesskiy-dev/iot-risk-logger-stm32l4/graph/badge.svg?token=0MO4ODZ1HA)](https://codecov.io/gh/polesskiy-dev/iot-risk-logger-stm32l4)
[![Documentation](https://img.shields.io/badge/docs-Doxygen-blue.svg)](https://polesskiy-dev.github.io/iot-risk-logger-stm32l4/)
![GitHub release (with filter)](https://img.shields.io/github/v/release/polesskiy-dev/iot-risk-logger-stm32l4)

# IoT Risk Data Logger,
## STM32L4 based

Expand Down
4 changes: 4 additions & 0 deletions compile_diagrams.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

echo "Transforming PlantUML text to diagrams .svg images"
echo "TODO: implement me"
Binary file modified firmware/iot-risk-logger-stm32l4/.DS_Store
Binary file not shown.
27 changes: 27 additions & 0 deletions track_memory_usage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Path to the ELF file generated by the build process
ELF_FILE="firmware/iot-risk-logger-stm32l4/build/iot-risk-logger-stm32l4.elf"

# Run arm-none-eabi-size and capture the output
SIZE_OUTPUT=$(arm-none-eabi-size $ELF_FILE)

# Extract text, data, and bss values
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}')

# Calculate Flash usage (text + data)
FLASH_USAGE=$((TEXT_SIZE + DATA_SIZE))

# Calculate RAM usage (data + bss)
RAM_USAGE=$((DATA_SIZE + BSS_SIZE))

# Print the results
echo "Memory usage:"
echo "Flash usage: $FLASH_USAGE bytes"
echo "RAM usage: $RAM_USAGE bytes"

# Update README.md with the new values
#sed -i "/## Flash and RAM Usage/c\## Flash and RAM Usage\n\n- Flash: $FLASH_USAGE bytes\n- RAM: $RAM_USAGE bytes" README.md

0 comments on commit 755d109

Please sign in to comment.