forked from rusefi/rusefi
-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (140 loc) · 5.52 KB
/
Copy pathfirmware-stack-usage.yaml
File metadata and controls
158 lines (140 loc) · 5.52 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Firmware Stack Usage
on:
pull_request:
schedule:
- cron: '17 3 * * *'
workflow_dispatch:
jobs:
stack-usage:
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- profile: f407-discovery
meta-info: config/boards/f407-discovery/meta-info.env
- profile: stm32f767_nucleo
meta-info: config/boards/nucleo_f767/meta-info.env
- profile: stm32h743_nucleo
meta-info: config/boards/nucleo_h743/meta-info.env
steps:
- uses: actions/checkout@v7
- name: Checkout Submodules
run: misc/git_scripts/common_submodule_init.sh
- uses: ./.github/actions/setup-java
- name: Install build tools
run: |
sudo bash misc/actions/add-ubuntu-latest-apt-mirrors.sh
sudo bash misc/actions/ubuntu-install-tools.sh
- name: Acquire Arm GNU Toolchain
uses: carlosperate/arm-none-eabi-gcc-action@v1.13.0
with:
release: '14.2.Rel1'
- name: Build firmware and bootloader callgraphs
working-directory: ./firmware/
env:
EXTRA_3_PARAMS: -fstack-usage -fcallgraph-info=su -Wstack-usage=1024
run: bash bin/compile.sh "${{ matrix.meta-info }}" elf bootloader --output-sync=recurse
- name: Test and generate stack usage report
working-directory: ./firmware/
run: |
../gradlew -p .. :gcc_map_reader:test :gcc_map_reader:shadowJar
java -cp ../java_tools/gcc_map_reader/build/libs/gcc_map_reader-all.jar \
com.rusefi.tools.stack.StackUsageReport \
--profile "${{ matrix.profile }}" \
--check-reviewed \
--output "build/firmware_stack_usage_${{ matrix.profile }}.md"
- name: Publish pull request workflow summary
if: ${{ github.event_name == 'pull_request' }}
working-directory: ./firmware/
run: cat "build/firmware_stack_usage_${{ matrix.profile }}.md" >> "$GITHUB_STEP_SUMMARY"
- name: Upload scheduled report
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/master' }}
uses: actions/upload-artifact@v7
with:
name: firmware_stack_usage_${{ matrix.profile }}
path: ./firmware/build/firmware_stack_usage_${{ matrix.profile }}.md
update-reference:
needs: stack-usage
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
permissions:
actions: read
contents: write
concurrency:
group: firmware-stack-usage-${{ github.ref }}
queue: max
cancel-in-progress: false
steps:
- uses: actions/checkout@v7
- name: Download stack usage reports
uses: actions/download-artifact@v8
with:
pattern: firmware_stack_usage_*
path: stack-usage
merge-multiple: true
- name: Assemble firmware stack usage document
run: |
{
echo '<!-- Generated by .github/workflows/firmware-stack-usage.yaml from StackUsageReport output. Do not edit. See java_tools/gcc_map_reader/README.md. -->'
echo
cat stack-usage/firmware_stack_usage_f407-discovery.md
echo
cat stack-usage/firmware_stack_usage_stm32f767_nucleo.md
echo
cat stack-usage/firmware_stack_usage_stm32h743_nucleo.md
} > docs/firmware_stack_usage.md
- name: Commit firmware stack usage document
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub firmware stack usage Action"
.github/workflows/bin/smart-git-add.sh docs/firmware_stack_usage.md
OUT=$(git commit -m "Auto-generated firmware stack usage" docs/firmware_stack_usage.md 2>&1) || echo "commit failed, finding out why"
echo "$OUT"
if echo "$OUT" | grep 'nothing to commit\|no changes added'; then
echo "firmware stack usage: looks like nothing to commit"
elif echo "$OUT" | grep 'changed'; then
if [ "${{ github.repository }}" = "rusefi/rusefi" ]; then
echo "COMMIT=true" >> "$GITHUB_ENV"
echo "firmware stack usage: changed on master, pushing"
else
echo "firmware stack usage: changed, but this is a fork"
fi
else
echo "firmware stack usage: unexpected commit result"
exit 1
fi
- name: Push current firmware stack usage document
if: ${{ env.COMMIT == 'true' }}
run: |
can_publish() {
if ! git merge-base --is-ancestor "${{ github.sha }}" origin/master; then
return 1
fi
while IFS=$'\t' read -r AUTHOR SUBJECT; do
if [ "$AUTHOR" != "action@github.com" ]; then
return 1
fi
case "$SUBJECT" in
"Auto-generated configs and docs"|"Trigger wheel definitions"|"Auto-generated default tune"|"Update date") ;;
*) return 1 ;;
esac
done < <(git log --format='%ae%x09%s' "${{ github.sha }}..origin/master")
}
for ATTEMPT in 1 2 3; do
git fetch origin master
if ! can_publish; then
echo "master advanced with non-generated changes; skipping this stale report"
exit 0
fi
git rebase origin/master
if git push origin HEAD:master; then
exit 0
fi
echo "push attempt $ATTEMPT raced another generated commit; retrying"
sleep 2
done
echo "failed to push firmware stack usage after 3 attempts"
exit 1