Skip to content

Commit dca2f1e

Browse files
authored
Merge branch 'apache:master' into master
2 parents 14f1554 + 3591378 commit dca2f1e

73 files changed

Lines changed: 3483 additions & 459 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.codespellrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ skip =
1010
LICENSE,
1111

1212
# Ignore words list (FTP protocol commands and technical terms)
13-
ignore-words-list = ALLO
13+
ignore-words-list = ALLO, ARCHTYPE

.github/labeler.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
# specific language governing permissions and limitations
1818
# under the License.
1919
#
20+
# Note: NuttX PR Labeler only supports a subset of the
21+
# `actions/labeler` syntax: `changed-files` and
22+
# `any-glob-to-any-file`. See .github/workflows/labeler.yml
2023

2124
# add arch labels
2225

.github/workflows/arch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ jobs:
230230
skip_build=1
231231
fi
232232

233-
# For "Arch / Board: xtensa": Build xtensa-01, xtensa-02
233+
# For "Arch / Board: xtensa": Build xtensa-01, xtensa-02, xtensa-03
234234
elif [[ "$arch_contains_xtensa" == "1" || "$board_contains_xtensa" == "1" ]]; then
235235
if [[ "$board" != *"xtensa-"* ]]; then
236236
skip_build=1

.github/workflows/build.yml

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ jobs:
106106
run: tar zcf sources.tar.gz sources
107107

108108
- name: Archive Source Bundle
109-
uses: actions/upload-artifact@v6
109+
uses: actions/upload-artifact@v7.0.0
110110
with:
111111
name: source-bundle
112112
path: sources.tar.gz
@@ -121,7 +121,7 @@ jobs:
121121
[
122122
"arm-01", "risc-v-01", "sim-01", "xtensa-01", "arm64-01", "x86_64-01", "other",
123123
"arm-02", "risc-v-02", "sim-02", "xtensa-02",
124-
"arm-03", "risc-v-03", "sim-03",
124+
"arm-03", "risc-v-03", "sim-03", "xtensa-03",
125125
"arm-04", "risc-v-04",
126126
"arm-05", "risc-v-05",
127127
"arm-06", "risc-v-06",
@@ -154,7 +154,7 @@ jobs:
154154
run: df -h
155155

156156
- name: Download Source Artifact
157-
uses: actions/download-artifact@v7
157+
uses: actions/download-artifact@v8
158158
with:
159159
name: source-bundle
160160
path: .
@@ -163,7 +163,7 @@ jobs:
163163
run: tar zxf sources.tar.gz
164164

165165
- name: Docker Login
166-
uses: docker/login-action@v3
166+
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
167167
with:
168168
registry: ghcr.io
169169
username: ${{ github.actor }}
@@ -175,42 +175,27 @@ jobs:
175175
- name: Export NuttX Repo SHA
176176
run: echo "nuttx_sha=`git -C sources/nuttx rev-parse HEAD`" >> $GITHUB_ENV
177177

178-
- name: Install NTFC
178+
- name: Run builds
179179
uses: ./sources/nuttx/.github/actions/ci-container
180180
env:
181181
BLOBDIR: /tools/blobs
182182
with:
183183
run: |
184-
# install python venv
185-
apt-get update
186-
apt-get install -y python3 python3-dev python3-venv
184+
export ARTIFACTDIR=`pwd`/buildartifacts
187185
188-
# get NTFC sources
189-
git clone -b release-0.0.1 https://github.com/szafonimateusz-mi/nuttx-ntfc
186+
pip install ntfc==0.0.1
187+
mkdir /github/workspace/nuttx-ntfc
188+
mkdir /github/workspace/nuttx-ntfc/external
190189
cd /github/workspace/nuttx-ntfc
191-
192-
# install NTFC with venv
193-
python3 -m venv /github/workspace/nuttx-ntfc/venv
194-
source /github/workspace/nuttx-ntfc/venv/bin/activate
195-
pip3 install .
196-
deactivate
197-
198190
# get NTFC test cases
199191
cd external
200192
git clone -b release-0.0.1 https://github.com/szafonimateusz-mi/nuttx-testing
193+
export NTFCDIR=/github/workspace/nuttx-ntfc
201194
202-
- name: Run builds
203-
uses: ./sources/nuttx/.github/actions/ci-container
204-
env:
205-
BLOBDIR: /tools/blobs
206-
with:
207-
run: |
208195
echo "::add-matcher::sources/nuttx/.github/gcc.json"
209-
export ARTIFACTDIR=`pwd`/buildartifacts
210-
export NTFCDIR=/github/workspace/nuttx-ntfc
211196
git config --global --add safe.directory /github/workspace/sources/nuttx
212197
git config --global --add safe.directory /github/workspace/sources/apps
213-
cd sources/nuttx/tools/ci
198+
cd /github/workspace/sources/nuttx/tools/ci
214199
if [ "X${{matrix.boards}}" = "Xcodechecker" ]; then
215200
./cibuild.sh -c -A -N -R --codechecker testlist/${{matrix.boards}}.dat
216201
else
@@ -222,7 +207,7 @@ jobs:
222207
if: always()
223208
run: df -h
224209

225-
- uses: actions/upload-artifact@v6
210+
- uses: actions/upload-artifact@v7.0.0
226211
if: ${{ always() }}
227212
with:
228213
name: linux-${{matrix.boards}}-builds
@@ -237,7 +222,7 @@ jobs:
237222
DOCKER_BUILDKIT: 1
238223
steps:
239224
- name: Download Source Artifact
240-
uses: actions/download-artifact@v7
225+
uses: actions/download-artifact@v8
241226
with:
242227
name: source-bundle
243228
path: .
@@ -246,7 +231,7 @@ jobs:
246231
run: tar zxf sources.tar.gz
247232

248233
- name: Docker Login
249-
uses: docker/login-action@v3
234+
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
250235
with:
251236
registry: ghcr.io
252237
username: ${{ github.actor }}
@@ -267,7 +252,7 @@ jobs:
267252
cd sources/nuttx
268253
./tools/ci/cibuild-oot.sh
269254
270-
- uses: actions/upload-artifact@v6
255+
- uses: actions/upload-artifact@v7.0.0
271256
if: ${{ always() }}
272257
with:
273258
name: oot-build-artifacts
@@ -296,7 +281,7 @@ jobs:
296281
boards: ${{ fromJSON(needs.macOS-Arch.outputs.selected_builds) }}
297282
steps:
298283
- name: Download Source Artifact
299-
uses: actions/download-artifact@v7
284+
uses: actions/download-artifact@v8
300285
with:
301286
name: source-bundle
302287
path: .
@@ -328,7 +313,7 @@ jobs:
328313
cd sources/nuttx/tools/ci
329314
./cibuild.sh -i -c -A -R testlist/${{matrix.boards}}.dat
330315
331-
- uses: actions/upload-artifact@v6
316+
- uses: actions/upload-artifact@v7.0.0
332317
with:
333318
name: macos-${{matrix.boards}}-builds
334319
path: buildartifacts/
@@ -391,7 +376,7 @@ jobs:
391376
- run: git config --global core.autocrlf false
392377

393378
- name: Download Source Artifact
394-
uses: actions/download-artifact@v7
379+
uses: actions/download-artifact@v8
395380
with:
396381
name: source-bundle
397382
path: .
@@ -411,7 +396,7 @@ jobs:
411396
cd sources/nuttx/tools/ci
412397
./cibuild.sh -g -i -A -C -N -R testlist/${{matrix.boards}}.dat
413398
414-
- uses: actions/upload-artifact@v6
399+
- uses: actions/upload-artifact@v7.0.0
415400
with:
416401
name: msys2-${{matrix.boards}}-builds
417402
path: buildartifacts/
@@ -445,7 +430,7 @@ jobs:
445430
- run: git config --global core.autocrlf false
446431

447432
- name: Download Source Artifact
448-
uses: actions/download-artifact@v7
433+
uses: actions/download-artifact@v8
449434
with:
450435
name: source-bundle
451436
path: .
@@ -463,7 +448,7 @@ jobs:
463448
cd sources\nuttx\tools\ci
464449
.\cibuild.ps1 -n -i -A -C -N testlist\windows.dat
465450
466-
- uses: actions/upload-artifact@v6
451+
- uses: actions/upload-artifact@v7.0.0
467452
with:
468453
name: msvc-builds
469454
path: ./sources/buildartifacts/

.github/workflows/labeler.yml

Lines changed: 123 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,139 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
#
15+
# This workflow will fetch the updated PR filenames, compute the Size Label
16+
# and Arch Labels, then save the PR Labels into a PR Artifact. The
17+
# PR Labels will be written to the PR inside the "workflow_run" trigger
18+
# (pr_labeler.yml), because this "pull_request" trigger has read-only
19+
# permission. Don't use "pull_request_target", it's unsafe.
20+
# See https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=321719166#GitHubActionsSecurity-Buildstriggeredwithpull_request_target
1521
name: "Pull Request Labeler"
1622
on:
17-
- pull_request_target
23+
- pull_request
1824

1925
jobs:
2026
labeler:
2127
permissions:
2228
contents: read
23-
pull-requests: write
24-
issues: write
29+
pull-requests: read
30+
issues: read
2531
runs-on: ubuntu-latest
2632
steps:
27-
- name: Checkout repository
28-
uses: actions/checkout@v6
33+
# Checkout one file from our trusted source: .github/labeler.yml
34+
# Never checkout and execute any untrusted code from the PR.
35+
- name: Checkout labeler config
36+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
37+
with:
38+
repository: apache/nuttx-apps
39+
ref: master
40+
path: labeler
41+
fetch-depth: 1
42+
persist-credentials: false
43+
sparse-checkout: .github/labeler.yml
44+
sparse-checkout-cone-mode: false
2945

30-
- name: Assign labels based on paths
31-
uses: actions/labeler@main
46+
# Fetch the updated PR filenames. Compute the Size Label and Arch Labels.
47+
- name: Compute PR labels
48+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
3249
with:
33-
repo-token: "${{ secrets.GITHUB_TOKEN }}"
34-
sync-labels: true
50+
github-token: ${{ secrets.GITHUB_TOKEN }}
51+
script: |
52+
const owner = context.repo.owner;
53+
const repo = context.repo.repo;
54+
const pull_number = context.issue.number;
55+
56+
// Fetch the array of updated PR filenames:
57+
// { status: 'added', filename: 'arch/arm/test.txt', additions: 3, deletions: 0, changes: 3 }
58+
// { status: 'removed', filename: 'Documentation/legacy_README.md', additions: 0, deletions: 2531, changes: 2531 }
59+
// { status: 'modified', filename: 'Documentation/security.rst', additions: 1, deletions: 0, changes: 1 }
60+
const listFilesOptions = github.rest.pulls.listFiles
61+
.endpoint.merge({ owner, repo, pull_number });
62+
const listFilesResponse = await github.paginate(listFilesOptions);
63+
64+
// Sum up the number of lines changed
65+
const sizeFiles = listFilesResponse
66+
.filter(f => (f.status != 'removed')); // Ignore deleted files
67+
var linesChanged = 0;
68+
for (const file of sizeFiles) {
69+
linesChanged += file.changes;
70+
}
71+
console.log({ linesChanged });
72+
73+
// Compute the Size Label
74+
const sizeLabel =
75+
(linesChanged <= 10) ? 'Size: XS'
76+
: (linesChanged <= 100) ? 'Size: S'
77+
: (linesChanged <= 500) ? 'Size: M'
78+
: (linesChanged <= 1000) ? 'Size: L'
79+
: 'Size: XL';
80+
var prLabels = [ sizeLabel ];
81+
82+
// Parse the Arch Label Patterns in .github/labeler.yml. Condense into:
83+
// "Arch: arm":
84+
// - any-glob-to-any-file: 'arch/arm/**'
85+
// - any-glob-to-any-file: ...
86+
const fs = require('fs');
87+
const config = fs.readFileSync('labeler/.github/labeler.yml', 'utf8')
88+
.split('\n') // Split by newline
89+
.map(s => s.trim()) // Remove leading and trailing spaces
90+
.filter(s => (s != '')) // Remove empty lines
91+
.filter(s => !s.startsWith('#')) // Remove comments
92+
.filter(s => !s.startsWith('- changed-files:')); // Remove "changed-files"
93+
94+
// Convert the Arch Label Patterns from config to archLabels.
95+
// archLabels will contain the mappings for Arch Label and Filename Pattern:
96+
// { label: "Arch: arm", pattern: "arch/arm/.*" },
97+
// { label: "Arch: arm64", pattern: "arch/arm64/.*" }, ...
98+
var archLabels = [];
99+
var label = "";
100+
for (const c of config) {
101+
// Get the Arch Label
102+
if (c.startsWith('"')) { // "Arch: arm":
103+
label = c.split('"')[1]; // Arch: arm
104+
105+
} else if (c.startsWith('- any-glob-to-any-file:')) { // - any-glob-to-any-file: 'arch/arm/**'
106+
// Convert the Glob Pattern to Regex Pattern
107+
const pattern = c.split("'")[1] // arch/arm/**
108+
.split('.').join('\\.') // . becomes \.
109+
.split('*').join('[^/]*') // * becomes [^/]*
110+
.split('[^/]*[^/]*').join('.*'); // ** becomes .*
111+
archLabels.push({
112+
label, // Arch: arm
113+
pattern: '^' + pattern + '$' // Match the Line Start and Line End
114+
});
115+
116+
} else {
117+
// We don't support all rules of `actions/labeler`
118+
throw new Error('.github/labeler.yml should contain only changed-files and any-glob-to-any-file, not: ' + c);
119+
}
120+
}
121+
122+
// Search the filenames for matching Arch Labels
123+
for (const archLabel of archLabels) {
124+
if (prLabels.includes(archLabel.label)) {
125+
break;
126+
}
127+
for (const file of listFilesResponse) {
128+
const re = new RegExp(archLabel.pattern);
129+
const match = re.test(file.filename);
130+
if (match && !prLabels.includes(archLabel.label)) {
131+
prLabels.push(archLabel.label);
132+
break;
133+
}
134+
}
135+
}
136+
console.log({ prLabels });
137+
138+
// Save the PR Number and PR Labels into a PR Artifact
139+
// e.g. 'Size: XS\nArch: avr\n'
140+
const dir = 'pr';
141+
fs.mkdirSync(dir);
142+
fs.writeFileSync(dir + '/pr-id.txt', pull_number + '\n');
143+
fs.writeFileSync(dir + '/pr-labels.txt', prLabels.join('\n') + '\n');
35144
36-
- name: Assign labels based on the PR's size
37-
uses: codelytv/pr-size-labeler@v1.10.3
145+
# Upload the PR Artifact as pr.zip
146+
- name: Upload PR artifact
147+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
38148
with:
39-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
ignore_file_deletions: true
41-
xs_label: 'Size: XS'
42-
s_label: 'Size: S'
43-
m_label: 'Size: M'
44-
l_label: 'Size: L'
45-
xl_label: 'Size: XL'
149+
name: pr
150+
path: pr/

0 commit comments

Comments
 (0)