Skip to content

Commit 9331d2e

Browse files
committed
Use a dedicated GitHub Actions workflow for testing 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 running the project's test suites. 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 test run operation is hereby moved to a dedicated workflow, consistent with standard practices for Arduino Tooling projects.
1 parent 6e69542 commit 9331d2e

File tree

3 files changed

+136
-9
lines changed

3 files changed

+136
-9
lines changed

.github/workflows/build.yml

-8
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,6 @@ jobs:
372372
IS_NIGHTLY: ${{ needs.build-type-determination.outputs.is-nightly }}
373373
IS_RELEASE: ${{ needs.build-type-determination.outputs.is-release }}
374374
CAN_SIGN: ${{ secrets[matrix.config.certificate-secret] != '' }}
375-
# The CREATE_* environment vars are only used to run tests. These secrets are optional. Dependent tests will
376-
# be skipped if not available.
377-
CREATE_USERNAME: ${{ secrets.CREATE_USERNAME }}
378-
CREATE_PASSWORD: ${{ secrets.CREATE_PASSWORD }}
379-
CREATE_CLIENT_SECRET: ${{ secrets.CREATE_CLIENT_SECRET }}
380375
working-directory: ${{ matrix.config.working-directory || './' }}
381376
run: |
382377
# See: https://www.electron.build/code-signing
@@ -393,9 +388,6 @@ jobs:
393388
yarn install --immutable
394389
395390
yarn --cwd arduino-ide-extension build
396-
yarn test
397-
yarn --cwd arduino-ide-extension test:slow
398-
399391
yarn --cwd electron-app rebuild
400392
yarn --cwd electron-app build
401393
yarn --cwd electron-app package

.github/workflows/test-javascript.yml

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Test JavaScript
2+
3+
env:
4+
# See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
5+
GO_VERSION: '1.21'
6+
# See: https://github.com/actions/setup-node/#readme
7+
NODE_VERSION: 18.17
8+
9+
on:
10+
push:
11+
paths:
12+
- ".github/workflows/test-javascript.ya?ml"
13+
- "**/.mocharc.js"
14+
- "**/.mocharc.jsonc?"
15+
- "**/.mocharc.ya?ml"
16+
- "**/package.json"
17+
- "**/package-lock.json"
18+
- "**/yarn.lock"
19+
- "tests/testdata/**"
20+
- "**/tsconfig.json"
21+
- "**.[jt]sx?"
22+
pull_request:
23+
paths:
24+
- ".github/workflows/test-javascript.ya?ml"
25+
- "**/.mocharc.js"
26+
- "**/.mocharc.jsonc?"
27+
- "**/.mocharc.ya?ml"
28+
- "**/package.json"
29+
- "**/package-lock.json"
30+
- "**/yarn.lock"
31+
- "tests/testdata/**"
32+
- "**/tsconfig.json"
33+
- "**.[jt]sx?"
34+
workflow_dispatch:
35+
repository_dispatch:
36+
37+
jobs:
38+
run-determination:
39+
runs-on: ubuntu-latest
40+
permissions: {}
41+
outputs:
42+
result: ${{ steps.determination.outputs.result }}
43+
steps:
44+
- name: Determine if the rest of the workflow should run
45+
id: determination
46+
run: |
47+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
48+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
49+
if [[
50+
"${{ github.event_name }}" != "create" ||
51+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
52+
]]; then
53+
# Run the other jobs.
54+
RESULT="true"
55+
else
56+
# There is no need to run the other jobs.
57+
RESULT="false"
58+
fi
59+
60+
echo "result=$RESULT" >> $GITHUB_OUTPUT
61+
62+
test:
63+
name: test (${{ matrix.project.path }}, ${{ matrix.operating-system }})
64+
needs: run-determination
65+
if: needs.run-determination.outputs.result == 'true'
66+
runs-on: ${{ matrix.operating-system }}
67+
defaults:
68+
run:
69+
shell: bash
70+
permissions:
71+
contents: read
72+
73+
strategy:
74+
fail-fast: false
75+
matrix:
76+
project:
77+
- path: .
78+
operating-system:
79+
- macos-latest
80+
- ubuntu-latest
81+
- windows-latest
82+
83+
steps:
84+
- name: Checkout
85+
uses: actions/checkout@v4
86+
87+
- name: Setup Node.js
88+
uses: actions/setup-node@v4
89+
with:
90+
cache: yarn
91+
node-version: ${{ env.NODE_VERSION }}
92+
93+
# See: https://github.com/eclipse-theia/theia/blob/master/doc/Developing.md#prerequisites
94+
- name: Install Python
95+
uses: actions/setup-python@v5
96+
with:
97+
python-version: '3.11.x'
98+
99+
- name: Install Go
100+
uses: actions/setup-go@v5
101+
with:
102+
go-version: ${{ env.GO_VERSION }}
103+
104+
- name: Install Taskfile
105+
uses: arduino/setup-task@v2
106+
with:
107+
repo-token: ${{ secrets.GITHUB_TOKEN }}
108+
version: 3.x
109+
110+
- name: Install npm package dependencies
111+
env:
112+
# Avoid failure of @vscode/ripgrep installation due to GitHub API rate limiting:
113+
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note
114+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
115+
run: |
116+
yarn install
117+
118+
- name: Compile TypeScript
119+
run: |
120+
yarn \
121+
--cwd arduino-ide-extension \
122+
build
123+
124+
- name: Run tests
125+
env:
126+
# These secrets are optional. Dependent tests will be skipped if not available.
127+
CREATE_USERNAME: ${{ secrets.CREATE_USERNAME }}
128+
CREATE_PASSWORD: ${{ secrets.CREATE_PASSWORD }}
129+
CREATE_CLIENT_SECRET: ${{ secrets.CREATE_CLIENT_SECRET }}
130+
run: |
131+
yarn test
132+
yarn \
133+
--cwd arduino-ide-extension \
134+
test:slow

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
# Arduino IDE 2.x
44

5-
[![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)
5+
[![Build status](https://github.com/arduino/arduino-ide/actions/workflows/build.yml/badge.svg)](https://github.com/arduino/arduino-ide/actions/workflows/build.yml)
66
[![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)
7+
[![Test JavaScript status](https://github.com/arduino/arduino-ide/actions/workflows/test-javascript.yml/badge.svg)](https://github.com/arduino/arduino-ide/actions/workflows/test-javascript.yml)
78

89
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).
910

0 commit comments

Comments
 (0)