Skip to content

Commit 05a7b53

Browse files
authored
Merge pull request #421 from pillo79/pr-tool-ci-p2
ci: fixes to tooling build
2 parents 879ae70 + c1c2e2f commit 05a7b53

3 files changed

Lines changed: 38 additions & 46 deletions

File tree

.github/workflows/package_core.yml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,9 @@
55

66
name: Package, test and upload core
77

8-
# Trigger on all pushes and PRs, except for changes only affecting the 'tools/'
9-
# directory or tagged with "tool/**".
10-
118
on:
129
push:
13-
branches:
14-
- '**'
15-
tags-ignore:
16-
- 'tool/**'
17-
paths:
18-
- '**'
19-
- '!extra/package_tool.sh'
20-
- '!tools/**'
2110
pull_request:
22-
paths:
23-
- '**'
24-
- '!extra/package_tool.sh'
25-
- '!tools/**'
2611

2712
concurrency:
2813
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.actor }}
@@ -90,7 +75,7 @@ jobs:
9075
# needs the above env vars
9176
run: |
9277
echo "## Building \`$CORE_VER\`" >> "$GITHUB_STEP_SUMMARY"
93-
echo "CORE_TAG=$(git describe --tags --exact-match 2>/dev/null || echo $CORE_HASH)" >> "$GITHUB_ENV"
78+
echo "CORE_TAG=$(git describe --tags --exact-match --exclude '*/*' 2>/dev/null || echo $CORE_HASH)" >> "$GITHUB_ENV"
9479
echo "ALL_BOARD_FQBNS=$(jq -c 'map((. + {link_mode: "static"}), (. + {link_mode: "dynamic"}))' <<< ${ALL_BOARD_DATA})" >> "$GITHUB_ENV"
9580
echo "ARTIFACTS=$(jq -c '["zephyr"] + (map(.artifact) | unique)' <<< ${ALL_BOARD_DATA})" >> "$GITHUB_ENV"
9681
echo "SUB_ARCHES=$(jq -c 'map(.subarch) | unique' <<< ${ALL_BOARD_DATA})" >> "$GITHUB_ENV"

.github/workflows/package_tool.yml

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,17 @@
55

66
name: Package and upload tool
77

8-
# Trigger on any push or pull request that modifies files in the tools/
9-
# directory or the packaging script, or on any tag that starts with tool/.
8+
# Trigger on any pull request that modifies files in the tools/ directory or
9+
# the packaging script, or on any tag that starts with tools/ and has the
10+
# format tools/<tool>/<version>, e.g. tools/gen-rodata-ld/0.1.0.
1011
#
1112
# For tag pushes, only build the specific tool and version indicated by the
12-
# tag, and only publish if the repository is the main one
13-
# (arduino/ArduinoCore-zephyr).
13+
# tag, and only publish if the repository is the official Arduino one.
1414

1515
on:
1616
push:
17-
branches:
18-
- '**'
1917
tags:
20-
- 'tool/**'
21-
paths:
2218
- 'tools/**'
23-
- 'extra/package_tool.sh'
2419
pull_request:
2520
paths:
2621
- 'tools/**'
@@ -32,6 +27,12 @@ concurrency:
3227

3328
jobs:
3429

30+
# Set up the build matrix based on the event type. For tag pushes, the matrix
31+
# will contain only the tool and version specified by the tag. For pull
32+
# requests, the matrix will include all tools with the version set to the
33+
# commit SHA. Also determine if this is a release build on the main
34+
# repository, and if so, set the tool artifact name for later use.
35+
3536
setup:
3637
name: Set up build matrix
3738
runs-on: ubuntu-latest
@@ -49,9 +50,9 @@ jobs:
4950
- name: Set build matrix
5051
id: set-matrix
5152
run: |
52-
if [[ "$GITHUB_REF" == refs/tags/tool/* ]]; then
53+
if [[ "$GITHUB_REF" == refs/tags/tools/* ]]; then
5354
# single tool, release build on main repo
54-
TAG="${GITHUB_REF#refs/tags/tool/}"
55+
TAG="${GITHUB_REF#refs/tags/tools/}"
5556
TOOL="${TAG%%/*}"
5657
VERSION="${TAG#*/}"
5758
MATRIX=$(jq -cn --arg tool "$TOOL" --arg version "$VERSION" \
@@ -68,6 +69,9 @@ jobs:
6869
fi
6970
echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"
7071
72+
# Build and package the tools in parallel according to the matrix, uploading
73+
# the resulting packages and metadata as artifacts for later use.
74+
7175
build-tool:
7276
name: Build ${{ matrix.tool }} ${{ matrix.version }}
7377
needs: setup
@@ -86,10 +90,10 @@ jobs:
8690
go-version: stable
8791
cache: false
8892

89-
- name: Build and package ${{ matrix.tool }}
93+
- name: Build and package tool
9094
run: extra/package_tool.sh tools/${{ matrix.tool }} ${{ matrix.version }}
9195

92-
- name: Upload ${{ matrix.tool }} ${{ matrix.version }}
96+
- name: Upload tool artifact
9397
uses: actions/upload-artifact@v7
9498
with:
9599
name: ${{ matrix.tool }}-${{ matrix.version }}
@@ -98,23 +102,13 @@ jobs:
98102
distrib/*.zip
99103
retention-days: 7
100104

101-
- name: Upload JSON ${{ matrix.tool }} ${{ matrix.version }}
105+
- name: Upload JSON artifact
102106
uses: actions/upload-artifact@v7
103107
with:
104108
name: ${{ matrix.tool }}-${{ matrix.version }}.json
105109
path: distrib/*.json
106110
archive: false
107111
retention-days: 7
108-
if-no-files-found: ignore
109-
110-
verify-tool:
111-
runs-on: ubuntu-latest
112-
if: always()
113-
needs: build-tool
114-
steps:
115-
- name: Check build result
116-
run: |
117-
[ "${{ needs.build-tool.result }}" == "success" ]
118112

119113
# Upload the built tool packages to the S3 bucket for public distribution.
120114

@@ -142,10 +136,24 @@ jobs:
142136
role-to-assume: ${{ secrets.IAM_ROLE }}
143137
aws-region: ${{ secrets.AWS_REGION }}
144138

145-
- name: Upload tools to S3
139+
- name: Upload tool files to S3
146140
run: |
147141
for f in *.tar.gz *.zip ; do
148142
[ -f "$f" ] || continue
149143
aws s3 cp "$f" s3://${{ secrets.S3_TOOLS_BUCKET }}/
150144
done
151145
146+
# The final verification step always runs to properly get the overall job status.
147+
148+
verify-tool:
149+
runs-on: ubuntu-latest
150+
if: always()
151+
needs:
152+
- build-tool
153+
- publish-tool
154+
steps:
155+
- name: Check build result
156+
run: |
157+
# A failure here means either the build or publish step failed when it was expected to run.
158+
[ ${{ needs.build-tool.result }} == "success" ] && \
159+
( [ ${{ needs.publish-tool.result }} == "success" ] || [ ${{ needs.publish-tool.result }} == "skipped" ] )

extra/get_core_version.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
# environments the correct commit is used, even in pull requests where HEAD
3434
# might be a temporary detached commit.
3535

36-
VERSION=$(git describe --tags --exact-match 2>/dev/null)
36+
VERSION=$(git describe --tags --exact-match --exclude '*/*' 2>/dev/null)
3737
if [ -z "$VERSION" ]; then
38-
STEM=$(git describe --tags 2>/dev/null |
38+
STEM=$(git describe --tags --exclude '*/*' 2>/dev/null |
3939
sed 's/\.\([[:digit:]]\+\)\(-.*\)*-[[:digit:]]\+-g.*/ \1 \2/' |
4040
awk '{ if (NF==2) { print $1 "." ($2+1) "-0.dev" } else { print $1 "." $2 $3 "-0.dev" }}')
4141
if [ -z "$STEM" ]; then
@@ -44,8 +44,7 @@ if [ -z "$VERSION" ]; then
4444
fi
4545

4646
# If HEAD_REF is not set, we're not in CI but in a local clone. Use the
47-
# default branch (HEAD) and include --dirty to test for uncommitted
48-
# changes.
49-
VERSION="${STEM}+$(git describe --always ${HEAD_REF:---dirty HEAD})"
47+
# implicit HEAD and include --dirty to test for uncommitted changes.
48+
VERSION="${STEM}+$(git describe --always ${HEAD_REF:---dirty})"
5049
fi
5150
echo $VERSION

0 commit comments

Comments
 (0)