Skip to content

Commit 6e69542

Browse files
committed
Use a dedicated GitHub Actions workflow for linting TypeScript/JavaScript code
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 perform the unrelated operation of linting the project's TypeScript and JavaScript code. This monolithic approach is harmful for multiple reasons: * Makes it difficult to interpret a failed workflow run * Unnecessarily adds a significant amount of extra content to the already extensive logs produced by the build process * Makes the build workflow more difficult to maintain * Increases the length of a build workflow run * Increases the impact of a spurious failure * Increases the turnaround time for contributors and maintainers to get feedback from the CI system The linting operation is hereby moved to a dedicated workflow, consistent with standard practices for Arduino Tooling projects.
1 parent 4f8b980 commit 6e69542

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed

.github/workflows/build.yml

-1
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ jobs:
395395
yarn --cwd arduino-ide-extension build
396396
yarn test
397397
yarn --cwd arduino-ide-extension test:slow
398-
yarn --cwd arduino-ide-extension lint
399398
400399
yarn --cwd electron-app rebuild
401400
yarn --cwd electron-app build
+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-javascript-task.md
2+
name: Check JavaScript
3+
4+
env:
5+
# See: https://github.com/actions/setup-node/#readme
6+
NODE_VERSION: 18.17
7+
8+
# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
9+
on:
10+
create:
11+
push:
12+
paths:
13+
- '.github/workflows/check-javascript.ya?ml'
14+
- '**/.eslintignore'
15+
- '**/.eslintrc*'
16+
- '**/.npmrc'
17+
- '**/package.json'
18+
- '**/package-lock.json'
19+
- '**/yarn.lock'
20+
- '**.jsx?'
21+
pull_request:
22+
paths:
23+
- '.github/workflows/check-javascript.ya?ml'
24+
- '**/.eslintignore'
25+
- '**/.eslintrc*'
26+
- '**/.npmrc'
27+
- '**/package.json'
28+
- '**/package-lock.json'
29+
- '**/yarn.lock'
30+
- '**.jsx?'
31+
workflow_dispatch:
32+
repository_dispatch:
33+
34+
jobs:
35+
run-determination:
36+
runs-on: ubuntu-latest
37+
permissions: {}
38+
outputs:
39+
result: ${{ steps.determination.outputs.result }}
40+
steps:
41+
- name: Determine if the rest of the workflow should run
42+
id: determination
43+
run: |
44+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
45+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
46+
if [[
47+
"${{ github.event_name }}" != "create" ||
48+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
49+
]]; then
50+
# Run the other jobs.
51+
RESULT="true"
52+
else
53+
# There is no need to run the other jobs.
54+
RESULT="false"
55+
fi
56+
57+
echo "result=$RESULT" >> $GITHUB_OUTPUT
58+
59+
check:
60+
needs: run-determination
61+
if: needs.run-determination.outputs.result == 'true'
62+
runs-on: ubuntu-latest
63+
permissions:
64+
contents: read
65+
66+
steps:
67+
- name: Checkout repository
68+
uses: actions/checkout@v4
69+
70+
- name: Setup Node.js
71+
uses: actions/setup-node@v4
72+
with:
73+
cache: yarn
74+
node-version: ${{ env.NODE_VERSION }}
75+
76+
- name: Install npm package dependencies
77+
env:
78+
# Avoid failure of @vscode/ripgrep installation due to GitHub API rate limiting:
79+
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
run: |
82+
yarn install
83+
84+
- name: Lint
85+
run: |
86+
yarn \
87+
--cwd arduino-ide-extension \
88+
lint

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Arduino IDE 2.x
44

55
[![Arduino IDE](https://github.com/arduino/arduino-ide/workflows/Arduino%20IDE/badge.svg)](https://github.com/arduino/arduino-ide/actions?query=workflow%3A%22Arduino+IDE%22)
6+
[![Check JavaScript status](https://github.com/arduino/arduino-ide/actions/workflows/check-javascript.yml/badge.svg)](https://github.com/arduino/arduino-ide/actions/workflows/check-javascript.yml)
67

78
This repository contains the source code of the Arduino IDE 2.x. If you're looking for the old IDE, go to the [repository of the 1.x version](https://github.com/arduino/Arduino).
89

0 commit comments

Comments
 (0)