Repository navigation
169 lines (162 loc) · 8.36 KB
/
Copy pathnightly.yml
File metadata and controls
169 lines (162 loc) · 8.36 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
159
160
161
162
163
164
165
166
167
168
169
# SPDX-License-Identifier: MIT
# Copyright (c) 2026 The RadioFoundry Authors
#
# Nightly CI (docs/dev/ci.md): the long builds the per-push workflow leaves out, on the default branch.
# matrix one job per toolchain (Arm, C-SKY), every board built with it from the registry: a build per feature
# switch turned off alone, fm-minimal and maximal, each with zero warnings and its size (tools/ci.sh
# --matrix --toolchain; about 4-5 minutes per board on the runner). C-SKY in the csky-elf image unless
# the runner has csky-elf GCC (skipped where the image isn't available)
# reuse `reuse lint`, reported as a warning until the tree passes it
# A scheduled run builds only what changed since the last commit that passed: a successful run saves a cache entry
# named after its commit (nightly-ok-<sha>, holding the sha), and the next scheduled run restores the newest one and
# diffs against it. The matrix runs when a file the firmware builds read changed (ci.yml's paths), reuse lint when
# any file did. A night with no firmware change records its commit as passed without building. That works the same
# on Gitea and GitHub (no API token, no clock arithmetic), catches up after nights the runner was off, and an evicted
# entry only costs one repeated run. A manual run (workflow_dispatch) always builds.
name: Nightly
on:
schedule:
- cron: "17 7 * * *" # 07:17 UTC, early morning in the US
workflow_dispatch:
permissions:
contents: read
concurrency:
group: nightly-${{ github.ref }}
cancel-in-progress: false
jobs:
changes:
if: (github.server_url != 'https://github.com' || vars.RFOUNDRY_CI_GITHUB == 'true')
runs-on: ubuntu-24.04
timeout-minutes: 5
outputs:
run: ${{ steps.decide.outputs.run }}
reuse: ${{ steps.decide.outputs.reuse }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # the last passed commit must be here to diff against
submodules: false
# the newest nightly-ok-* entry: this commit's (an exact hit) or the last commit that passed (a prefix match)
- name: Look up the last nightly pass
id: tested
if: github.event_name == 'schedule'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .nightly-ok
key: nightly-ok-${{ github.sha }}
restore-keys: nightly-ok-
- id: decide
run: |
set -u
decide() { echo "run=$1" >> "$GITHUB_OUTPUT"; echo "reuse=$2" >> "$GITHUB_OUTPUT"; echo "::notice::$3"; exit 0; }
[ "${{ github.event_name }}" = schedule ] || decide true true "run by hand"
[ "${{ steps.tested.outputs.cache-hit }}" = true ] && decide false false "${GITHUB_SHA::8} already passed a nightly run"
last=$(cat .nightly-ok/sha 2> /dev/null || true)
[ -n "$last" ] || decide true true "no earlier nightly pass to compare with"
git cat-file -e "$last^{commit}" 2> /dev/null || decide true true "last passed commit $last not in the history"
git diff --name-only "$last" HEAD > "$RUNNER_TEMP/files"
[ -s "$RUNNER_TEMP/files" ] || decide false false "no change since ${last::8} passed"
# what the firmware builds read (ci.yml's paths, less the tests and license files)
if grep -qE '^(Makefile|\.gitmodules|\.github/actions/|\.github/workflows/nightly\.yml$|(boards|boot|config|core|drivers|hal|platform|third_party|tools)/)' \
"$RUNNER_TEMP/files"; then
decide true true "firmware inputs changed since ${last::8} passed"
fi
{ echo "run=false"; echo "reuse=true"; echo "mark=true"; } >> "$GITHUB_OUTPUT"
echo "::notice::no firmware input changed since ${last::8} passed: matrix skipped, this commit counts as passed"
# nothing the builds read changed, so this commit's matrix would be the last pass's: record it as passed here,
# without the mark job, so later nights diff against it
- name: Remember that this commit passed
if: steps.decide.outputs.mark == 'true'
run: mkdir -p .nightly-ok && echo "$GITHUB_SHA" > .nightly-ok/sha
- if: steps.decide.outputs.mark == 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .nightly-ok
key: nightly-ok-${{ github.sha }}
matrix:
# one job per toolchain: every board built with it in turn (tools/ci.sh --toolchain, from the registry), so the
# checkout, submodules and compiler are set up once per toolchain, not once per radio
name: matrix (${{ matrix.name }})
needs: changes
if: (github.server_url != 'https://github.com' || vars.RFOUNDRY_CI_GITHUB == 'true') && (needs.changes.outputs.run == 'true')
runs-on: ubuntu-24.04
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
# the [toolchain] ids of platform/*/platform.toml, with their names; a new platform on a toolchain listed here
# needs no edit, a new toolchain gets an entry here and its set-up in .github/actions/toolchain
include:
- { toolchain: arm, name: Arm }
- { toolchain: csky, name: C-SKY }
permissions:
contents: read
packages: read # pulling a private ghcr.io csky-elf image with the job token
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: false # tools/checkout-submodules.sh: the runner image's copies, then the network
- name: third_party submodules
run: tools/checkout-submodules.sh
- name: Toolchain (platform.toml [toolchain])
id: tc
uses: ./.github/actions/toolchain
with:
toolchain: ${{ matrix.toolchain }}
image: ${{ vars.RFOUNDRY_CSKY_IMAGE }}
registry: ${{ vars.RFOUNDRY_CSKY_REGISTRY }}
# a read-only registry token (secret); on GitHub a ghcr.io package linked to this repository takes the job's
# own token (packages: read)
registry-user: ${{ vars.RFOUNDRY_CSKY_REGISTRY_USER || github.actor }}
registry-token: ${{ secrets.RFOUNDRY_CSKY_REGISTRY_TOKEN || github.token }}
- name: Feature matrix of every board on the toolchain
env:
RUN: ${{ steps.tc.outputs.run }} # empty, or the csky-elf image's run.sh
TOOLCHAIN: ${{ matrix.toolchain }}
run: |
set -u
rc=0
$RUN tools/ci.sh --matrix --steps firmware --toolchain "$TOOLCHAIN" || rc=$?
if [ "$rc" = 3 ]; then
echo "::notice::$TOOLCHAIN matrix skipped: the image ${RFOUNDRY_CSKY_IMAGE:-} isn't available on this runner (docs/dev/ci.md)"
exit 0
fi
[ -f build/ci/size-report.md ] && cat build/ci/size-report.md >> "$GITHUB_STEP_SUMMARY"
exit "$rc"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: always()
with:
name: matrix-${{ matrix.toolchain }}
path: |
build/ci/size-report.md
build/ci/*.log
if-no-files-found: ignore
reuse:
needs: changes
if: (github.server_url != 'https://github.com' || vars.RFOUNDRY_CI_GITHUB == 'true') && (needs.changes.outputs.reuse == 'true')
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: false
- name: reuse lint (a warning until the tree passes)
run: |
set -u
if [ -x /opt/reuse/bin/reuse ]; then PATH="/opt/reuse/bin:$PATH" # the self-hosted runner's image
else pipx install reuse > /dev/null && PATH="$HOME/.local/bin:$PATH"; fi
if ! reuse lint; then
echo "::warning::reuse lint does not pass yet (see the log; docs/dev/ci.md)"
fi
mark:
needs: [matrix]
if: (github.server_url != 'https://github.com' || vars.RFOUNDRY_CI_GITHUB == 'true')
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- name: Remember that this commit passed
run: mkdir -p .nightly-ok && echo "$GITHUB_SHA" > .nightly-ok/sha # the next run diffs against it
- uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .nightly-ok
key: nightly-ok-${{ github.sha }}