Skip to content

Commit e9b283b

Browse files
committed
trice lib build ci workflow added
1 parent 6a440bc commit e9b283b

File tree

5 files changed

+566
-1
lines changed

5 files changed

+566
-1
lines changed

.github/workflows/trice_lib_ci.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: TRICE Library CI (Nightly Quick)
2+
3+
on:
4+
schedule:
5+
# Run nightly at 02:15 UTC (adjust to your preference).
6+
- cron: "15 2 * * *"
7+
workflow_dispatch: {}
8+
9+
permissions:
10+
contents: read
11+
actions: read
12+
13+
jobs:
14+
guard_activity:
15+
name: Guard - skip if no commits in last 24h
16+
runs-on: ubuntu-latest
17+
outputs:
18+
should_run: ${{ steps.decide.outputs.should_run }}
19+
steps:
20+
- name: Checkout (for git log)
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Decide whether to run heavy CI
26+
id: decide
27+
shell: bash
28+
run: |
29+
set -euo pipefail
30+
31+
# Determine default branch (main/master). We check remote refs.
32+
if git show-ref --verify --quiet refs/remotes/origin/main; then
33+
DEFAULT_BRANCH="origin/main"
34+
else
35+
DEFAULT_BRANCH="origin/master"
36+
fi
37+
38+
echo "Default branch assumed: ${DEFAULT_BRANCH}"
39+
40+
# Count commits in the last 24 hours on the default branch.
41+
COMMIT_COUNT="$(git log --since="24 hours ago" --pretty=oneline "${DEFAULT_BRANCH}" | wc -l | tr -d ' ')"
42+
echo "Commits in last 24h: ${COMMIT_COUNT}"
43+
44+
if [ "${COMMIT_COUNT}" = "0" ]; then
45+
echo "should_run=false" >> "$GITHUB_OUTPUT"
46+
else
47+
echo "should_run=true" >> "$GITHUB_OUTPUT"
48+
fi
49+
50+
heavy_ci:
51+
name: Heavy CI (quick)
52+
needs: guard_activity
53+
if: ${{ needs.guard_activity.outputs.should_run == 'true' }}
54+
uses: ./.github/workflows/trice_lib_reusable.yml
55+
with:
56+
# Quick mode: keep runtime bounded
57+
configs_mode: quick
58+
configs_start: 0
59+
configs_end: 10
60+
61+
# Keep your standard checks:
62+
toolchain_gcc_trice_on: true
63+
toolchain_gcc_trice_off: true
64+
toolchain_clang: true
65+
66+
upload_artifacts: true
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: TRICE Library CI (Nightly Full)
2+
3+
on:
4+
schedule:
5+
# Run nightly full sweep at 03:15 UTC (staggered to avoid overlap).
6+
- cron: "15 3 * * *"
7+
workflow_dispatch: {}
8+
9+
permissions:
10+
contents: read
11+
actions: read
12+
13+
jobs:
14+
guard_activity:
15+
name: Guard - skip if no commits in last 24h
16+
runs-on: ubuntu-latest
17+
outputs:
18+
should_run: ${{ steps.decide.outputs.should_run }}
19+
steps:
20+
- name: Checkout (for git log)
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Decide whether to run heavy CI
26+
id: decide
27+
shell: bash
28+
run: |
29+
set -euo pipefail
30+
31+
if git show-ref --verify --quiet refs/remotes/origin/main; then
32+
DEFAULT_BRANCH="origin/main"
33+
else
34+
DEFAULT_BRANCH="origin/master"
35+
fi
36+
37+
COMMIT_COUNT="$(git log --since="24 hours ago" --pretty=oneline "${DEFAULT_BRANCH}" | wc -l | tr -d ' ')"
38+
echo "Commits in last 24h: ${COMMIT_COUNT}"
39+
40+
if [ "${COMMIT_COUNT}" = "0" ]; then
41+
echo "should_run=false" >> "$GITHUB_OUTPUT"
42+
else
43+
echo "should_run=true" >> "$GITHUB_OUTPUT"
44+
fi
45+
46+
heavy_ci:
47+
name: Heavy CI (full)
48+
needs: guard_activity
49+
if: ${{ needs.guard_activity.outputs.should_run == 'true' }}
50+
uses: ./.github/workflows/trice_lib_reusable.yml
51+
with:
52+
# Full configuration sweep: 0..100
53+
configs_mode: full
54+
55+
toolchain_gcc_trice_on: true
56+
toolchain_gcc_trice_off: true
57+
toolchain_clang: true
58+
59+
upload_artifacts: true
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: TRICE Library CI (Reusable)
2+
3+
on:
4+
# This workflow is not triggered directly by pushes or schedules.
5+
# It is meant to be called from other workflows via "workflow_call".
6+
workflow_call:
7+
inputs:
8+
toolchain_gcc_trice_on:
9+
description: "Run gcc build for all targets with TRICE enabled"
10+
required: false
11+
type: boolean
12+
default: true
13+
toolchain_gcc_trice_off:
14+
description: "Run gcc build for all targets with TRICE disabled (TRICE_OFF=1)"
15+
required: false
16+
type: boolean
17+
default: true
18+
toolchain_clang:
19+
description: "Run clang build(s) that exist (currently only G0B1_inst/build_with_clang.sh via ci_build.sh)"
20+
required: false
21+
type: boolean
22+
default: true
23+
24+
configs_mode:
25+
description: "Configuration sweep mode: none|quick|full"
26+
required: false
27+
type: string
28+
default: "none"
29+
30+
configs_start:
31+
description: "Start configuration for quick mode (inclusive)"
32+
required: false
33+
type: number
34+
default: 0
35+
configs_end:
36+
description: "End configuration for quick mode (inclusive)"
37+
required: false
38+
type: number
39+
default: 10
40+
41+
upload_artifacts:
42+
description: "Upload .elf/.hex/.bin as workflow artifacts"
43+
required: false
44+
type: boolean
45+
default: true
46+
47+
permissions:
48+
contents: read
49+
50+
jobs:
51+
build:
52+
name: Heavy build & compile checks
53+
runs-on: ubuntu-latest
54+
55+
# Concurrency prevents multiple heavy builds for the same branch from running
56+
# in parallel, which can waste significant CI minutes.
57+
concurrency:
58+
group: trice-lib-ci-${{ github.workflow }}-${{ github.ref }}
59+
cancel-in-progress: false
60+
61+
steps:
62+
- name: Checkout
63+
uses: actions/checkout@v4
64+
with:
65+
# Full history makes it easier to debug "what changed", and allows git-based
66+
# checks if you ever add them inside the build scripts.
67+
fetch-depth: 0
68+
69+
- name: Install toolchains and build tools
70+
shell: bash
71+
run: |
72+
set -euxo pipefail
73+
sudo apt-get update
74+
sudo apt-get install -y \
75+
make \
76+
python3 \
77+
gcc-arm-none-eabi \
78+
binutils-arm-none-eabi \
79+
clang \
80+
llvm \
81+
lld
82+
83+
- name: Print tool versions
84+
shell: bash
85+
run: |
86+
set -euxo pipefail
87+
arm-none-eabi-gcc --version || true
88+
arm-none-eabi-objcopy --version || true
89+
clang --version || true
90+
llvm-objcopy --version || true
91+
make --version
92+
93+
- name: Run build orchestrator (ci_build.sh)
94+
shell: bash
95+
run: |
96+
set -euxo pipefail
97+
chmod +x ./ci_build.sh
98+
99+
# Make objcopy deterministic in CI.
100+
# This helps avoid failures caused by missing llvm-objcopy in PATH,
101+
# and matches the typical embedded toolchain expectation.
102+
export OBJCOPY=arm-none-eabi-objcopy
103+
104+
# 1) GCC all-target builds (TRICE ON/OFF)
105+
if [ "${{ inputs.toolchain_gcc_trice_on }}" = "true" ]; then
106+
./ci_build.sh \
107+
--toolchain=gcc \
108+
--trice=on \
109+
--configs=${{ inputs.configs_mode }} \
110+
--configs-start=${{ inputs.configs_start }} \
111+
--configs-end=${{ inputs.configs_end }}
112+
fi
113+
114+
if [ "${{ inputs.toolchain_gcc_trice_off }}" = "true" ]; then
115+
./ci_build.sh \
116+
--toolchain=gcc \
117+
--trice=off \
118+
--configs=none
119+
fi
120+
121+
# 2) Clang build(s) (as implemented in ci_build.sh)
122+
if [ "${{ inputs.toolchain_clang }}" = "true" ]; then
123+
./ci_build.sh \
124+
--toolchain=clang \
125+
--trice=on \
126+
--configs=none
127+
fi
128+
129+
- name: Upload build artifacts
130+
if: ${{ inputs.upload_artifacts }}
131+
uses: actions/upload-artifact@v4
132+
with:
133+
name: trice-lib-artifacts
134+
path: |
135+
examples/**/out.*/*.elf
136+
examples/**/out.*/*.hex
137+
examples/**/out.*/*.bin
138+
if-no-files-found: warn

0 commit comments

Comments
 (0)