Skip to content

Commit 788017b

Browse files
committed
Use a dedicated GitHub workflow to check for problems with Yarn configuration
The "build" workflow builds the application for all supported targets, generates workflow artifacts from which the builds can be downloaded by users and beta testers, and publishes nightly and production releases. As if that wasn't enough, the workflow was also configured to check the sync of the Yarn lockfile. This monolithic approach is harmful for multiple reasons: * Makes it difficult to interpret a failed workflow run * Makes the build workflow more difficult to maintain * Increases the turnaround time for contributors and maintainers to get feedback from the CI system The sync check operation is hereby moved to a dedicated workflow, consistent with standard practices for Arduino Tooling projects.
1 parent 9331d2e commit 788017b

File tree

2 files changed

+92
-1
lines changed

2 files changed

+92
-1
lines changed

Diff for: .github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ jobs:
385385
fi
386386
387387
npx node-gyp install
388-
yarn install --immutable
388+
yarn install
389389
390390
yarn --cwd arduino-ide-extension build
391391
yarn --cwd electron-app rebuild

Diff for: .github/workflows/check-yarn.yml

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Check Yarn
2+
3+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
4+
on:
5+
create:
6+
push:
7+
paths:
8+
- ".github/workflows/check-yarn.ya?ml"
9+
- "**/.yarnrc"
10+
- "**/package.json"
11+
- "**/package-lock.json"
12+
- "**/yarn.lock"
13+
pull_request:
14+
paths:
15+
- ".github/workflows/check-yarn.ya?ml"
16+
- "**/.yarnrc"
17+
- "**/package.json"
18+
- "**/package-lock.json"
19+
- "**/yarn.lock"
20+
schedule:
21+
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
22+
- cron: "0 8 * * TUE"
23+
workflow_dispatch:
24+
repository_dispatch:
25+
26+
jobs:
27+
run-determination:
28+
runs-on: ubuntu-latest
29+
permissions: {}
30+
outputs:
31+
result: ${{ steps.determination.outputs.result }}
32+
steps:
33+
- name: Determine if the rest of the workflow should run
34+
id: determination
35+
run: |
36+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
37+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
38+
if [[
39+
"${{ github.event_name }}" != "create" ||
40+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
41+
]]; then
42+
# Run the other jobs.
43+
RESULT="true"
44+
else
45+
# There is no need to run the other jobs.
46+
RESULT="false"
47+
fi
48+
49+
echo "result=$RESULT" >> $GITHUB_OUTPUT
50+
51+
check-sync:
52+
name: check-sync (${{ matrix.project.path }})
53+
needs: run-determination
54+
if: needs.run-determination.outputs.result == 'true'
55+
runs-on: ubuntu-latest
56+
permissions:
57+
contents: read
58+
59+
strategy:
60+
fail-fast: false
61+
matrix:
62+
project:
63+
- path: .
64+
65+
steps:
66+
- name: Checkout repository
67+
uses: actions/checkout@v4
68+
69+
- name: Setup Node.js
70+
uses: actions/setup-node@v4
71+
with:
72+
cache: yarn
73+
node-version: ${{ env.NODE_VERSION }}
74+
75+
- name: Install npm package dependencies
76+
env:
77+
# Avoid failure of @vscode/ripgrep installation due to GitHub API rate limiting:
78+
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note
79+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
run: |
81+
yarn \
82+
install \
83+
--ignore-scripts
84+
85+
- name: Check yarn.lock
86+
run: |
87+
git \
88+
diff \
89+
--color \
90+
--exit-code \
91+
"${{ matrix.project.path }}/yarn.lock"

0 commit comments

Comments
 (0)