Skip to content

Commit e53d2f5

Browse files
[skip-changelog] Run integration tests concurrently (#1953)
* Run integration tests concurrently This enhancement reduces the amount of time needed to execute integration tests, since each test package no longer has to wait for the previous ones to be completed. In order to do this, a regex is used to match each test file. It is also specified the path to the directory that contains the file. * Merge all test files that share a package into one Having different test files that shared the same package was inefficient, because the whole package test was run one time for each file. This enhancement avoids repeating the same tests more than once.
1 parent ec3e71c commit e53d2f5

14 files changed

+715
-845
lines changed

.github/workflows/test-go-task.yml

+50-2
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,61 @@ jobs:
5858
5959
echo "result=$RESULT" >> $GITHUB_OUTPUT
6060
61-
test:
61+
tests-collector:
62+
runs-on: ubuntu-latest
6263
needs: run-determination
6364
if: needs.run-determination.outputs.result == 'true'
65+
outputs:
66+
tests-data: ${{ steps.collection.outputs.tests-data }}
67+
steps:
68+
- name: Checkout repository
69+
uses: actions/checkout@v3
70+
71+
- name: Collect tests
72+
id: collection
73+
run: |
74+
echo "tests-data=$(go list ./internal/integrationtest/... | grep integrationtest/ | tr "/" " " | cut -d " " -f 6 | jq -cR '[inputs]')" >> $GITHUB_OUTPUT
6475
76+
test-integration:
77+
needs: tests-collector
6578
strategy:
66-
fail-fast: false
79+
matrix:
80+
operating-system:
81+
- ubuntu-latest
82+
- windows-latest
83+
- macos-latest
84+
tests: ${{ fromJSON(needs.tests-collector.outputs.tests-data) }}
85+
86+
runs-on: ${{ matrix.operating-system }}
87+
88+
steps:
89+
# By default, actions/checkout converts the repo's LF line endings to CRLF on the Windows runner.
90+
- name: Disable EOL conversions
91+
run: git config --global core.autocrlf false
6792

93+
- name: Checkout repository
94+
uses: actions/checkout@v3
95+
96+
- name: Install Go
97+
uses: actions/setup-go@v3
98+
with:
99+
go-version: ${{ env.GO_VERSION }}
100+
101+
- name: Install Task
102+
uses: arduino/setup-task@v1
103+
with:
104+
repo-token: ${{ secrets.GITHUB_TOKEN }}
105+
version: 3.x
106+
107+
- name: Run tests
108+
shell: bash
109+
run: |
110+
export GO_TEST_PACKAGE="github.com/arduino/arduino-cli/internal/integrationtest/${{ matrix.tests }}"
111+
task go:integration-test
112+
113+
test:
114+
needs: run-determination
115+
strategy:
68116
matrix:
69117
operating-system:
70118
- ubuntu-latest

Taskfile.yml

+22-2
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,23 @@ tasks:
105105
{{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}} \
106106
{{.TEST_LDFLAGS}}
107107
108+
go:integration-test:
109+
desc: Run the Go-based integration tests
110+
deps:
111+
- task: go:build
112+
dir: '{{default "./" .GO_MODULE_PATH}}'
113+
cmds:
114+
- |
115+
go test \
116+
-v \
117+
-short \
118+
{{ .GO_TEST_PACKAGE }} \
119+
-run '{{default ".*" .GO_TEST_REGEX}}' \
120+
{{default "-timeout 20m -coverpkg=./... -covermode=atomic" .GO_TEST_FLAGS}} \
121+
-coverprofile=coverage_unit.txt \
122+
{{default .DEFAULT_INTEGRATIONTEST_GO_PACKAGES .GO_PACKAGES}} \
123+
{{.TEST_LDFLAGS}}
124+
108125
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-go-integration-task/Taskfile.yml
109126
go:test-integration:
110127
desc: Run integration tests
@@ -342,10 +359,13 @@ tasks:
342359
vars:
343360
PROJECT_NAME: "arduino-cli"
344361
DIST_DIR: "dist"
345-
# all modules of this project except for "legacy/..." module
362+
# all modules of this project except for "legacy/..." module and integration test
346363
DEFAULT_GO_PACKAGES:
347364
sh: |
348-
echo $(cd {{default "./" .GO_MODULE_PATH}} && go list ./... | grep -v legacy | tr '\n' ' ' || echo '"ERROR: Unable to discover Go packages"')
365+
echo $(cd {{default "./" .GO_MODULE_PATH}} && go list ./... | grep -v internal/integrationtest | grep -v legacy | tr '\n' ' ' || echo '"ERROR: Unable to discover Go packages"')
366+
DEFAULT_INTEGRATIONTEST_GO_PACKAGES:
367+
sh: |
368+
echo $(cd {{default "./" .GO_MODULE_PATH}} && go list ./... | grep internal/integrationtest | tr '\n' ' ' || echo '"ERROR: Unable to discover Go packages"')
349369
# build vars
350370
COMMIT:
351371
sh: echo "$(git log --no-show-signature -n 1 --format=%h)"

internal/integrationtest/board/board_list_test.go

-63
This file was deleted.

internal/integrationtest/board/board_test.go

+39
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,45 @@ import (
2929
"gopkg.in/src-d/go-git.v4/plumbing"
3030
)
3131

32+
func TestCorrectBoardListOrdering(t *testing.T) {
33+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
34+
defer env.CleanUp()
35+
36+
_, _, err := cli.Run("core", "install", "arduino:avr")
37+
require.NoError(t, err)
38+
jsonOut, _, err := cli.Run("board", "listall", "--format", "json")
39+
require.NoError(t, err)
40+
requirejson.Query(t, jsonOut, "[.boards[] | .fqbn]", `[
41+
"arduino:avr:yun",
42+
"arduino:avr:uno",
43+
"arduino:avr:unomini",
44+
"arduino:avr:diecimila",
45+
"arduino:avr:nano",
46+
"arduino:avr:mega",
47+
"arduino:avr:megaADK",
48+
"arduino:avr:leonardo",
49+
"arduino:avr:leonardoeth",
50+
"arduino:avr:micro",
51+
"arduino:avr:esplora",
52+
"arduino:avr:mini",
53+
"arduino:avr:ethernet",
54+
"arduino:avr:fio",
55+
"arduino:avr:bt",
56+
"arduino:avr:LilyPadUSB",
57+
"arduino:avr:lilypad",
58+
"arduino:avr:pro",
59+
"arduino:avr:atmegang",
60+
"arduino:avr:robotControl",
61+
"arduino:avr:robotMotor",
62+
"arduino:avr:gemma",
63+
"arduino:avr:circuitplay32u4cat",
64+
"arduino:avr:yunmini",
65+
"arduino:avr:chiwawa",
66+
"arduino:avr:one",
67+
"arduino:avr:unowifi"
68+
]`)
69+
}
70+
3271
func TestBoardList(t *testing.T) {
3372
if os.Getenv("CI") != "" {
3473
t.Skip("VMs have no serial ports")

internal/integrationtest/compile/compile_part_2_test.go

-162
This file was deleted.

0 commit comments

Comments
 (0)