-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (95 loc) · 3.41 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
compile:
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@v3
with:
submodules: true # Initialize and update submodules automatically
fetch-depth: 0 # Fetch all history to ensure proper submodule handling
- 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: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: |
firmware/iot-risk-logger-stm32l4/build/
firmware/iot-risk-logger-stm32l4/*.elf
firmware/iot-risk-logger-stm32l4/*.map
calculate-memory-usage:
runs-on: ubuntu-latest
needs: compile
steps:
- name: Checkout artifacts branch
uses: actions/checkout@v3
with:
ref: artifacts # Checkout the artifacts branch
submodules: true
fetch-depth: 0
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y gcc-arm-none-eabi
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
- 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))
FLASH_KB=$(( (FLASH_USAGE + 1023) / 1024 )) # Round to nearest KB
RAM_KB=$(( (RAM_USAGE + 1023) / 1024 )) # Round to nearest KB
FLASH_MAX=128 # Maximum flash size in KB
SRAM_MAX=40 # Maximum RAM size in KB
FLASH_USAGE_PERCENT=$(( (FLASH_KB * 100) / FLASH_MAX ))
SRAM_USAGE_PERCENT=$(( (RAM_KB * 100) / SRAM_MAX ))
touch usage.json
echo "{ \"flash\": \"${FLASH_KB}K/${FLASH_MAX}K (${FLASH_USAGE_PERCENT}%)\", \"SRAM\": \"${RAM_KB}K/${SRAM_MAX}K (${SRAM_USAGE_PERCENT}%)\" }" > usage.json
cat usage.json
- name: Commit usage.json to artifacts branch
run: |
mkdir -p artifacts
mv usage.json artifacts/
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -am "Update Flash and RAM usage artifacts"
git push origin artifacts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
test:
runs-on: ubuntu-latest
needs: compile
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
- name: Run tests
run: echo "Run your test commands here"
generate-diagrams:
runs-on: ubuntu-latest
needs: compile
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
- name: Generate diagrams
run: echo "Run your diagram generation commands here"