Skip to content

Commit d9bbba5

Browse files
committed
Add CI workflow to run integration tests
On every push and pull request that affects relevant files, run the integration tests.
1 parent 152e61d commit d9bbba5

File tree

5 files changed

+142
-126
lines changed

5 files changed

+142
-126
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/test-go-integration-task.md
2+
name: Test Integration
3+
4+
env:
5+
# See: https://github.com/actions/setup-go/tree/v2#readme
6+
GO_VERSION: "1.14"
7+
# See: https://github.com/actions/setup-python/tree/v2#available-versions-of-python
8+
PYTHON_VERSION: "3.9"
9+
10+
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
11+
on:
12+
create:
13+
push:
14+
paths:
15+
- ".github/workflows/test-go-integration-task.ya?ml"
16+
- "Taskfile.ya?ml"
17+
- "**.go"
18+
- "go.mod"
19+
- "go.sum"
20+
- "poetry.lock"
21+
- "pyproject.toml"
22+
- "tests/**"
23+
pull_request:
24+
paths:
25+
- ".github/workflows/test-go-integration-task.ya?ml"
26+
- "Taskfile.ya?ml"
27+
- "**.go"
28+
- "go.mod"
29+
- "go.sum"
30+
- "poetry.lock"
31+
- "pyproject.toml"
32+
- "tests/**"
33+
workflow_dispatch:
34+
repository_dispatch:
35+
36+
jobs:
37+
run-determination:
38+
runs-on: ubuntu-latest
39+
outputs:
40+
result: ${{ steps.determination.outputs.result }}
41+
steps:
42+
- name: Determine if the rest of the workflow should run
43+
id: determination
44+
run: |
45+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
46+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
47+
if [[ \
48+
"${{ github.event_name }}" != "create" || \
49+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX \
50+
]]; then
51+
# Run the other jobs.
52+
RESULT="true"
53+
else
54+
# There is no need to run the other jobs.
55+
RESULT="false"
56+
fi
57+
58+
echo "::set-output name=result::$RESULT"
59+
60+
test:
61+
needs: run-determination
62+
if: needs.run-determination.outputs.result == 'true'
63+
64+
strategy:
65+
matrix:
66+
operating-system:
67+
- ubuntu-latest
68+
- windows-latest
69+
- macos-latest
70+
71+
runs-on: ${{ matrix.operating-system }}
72+
73+
steps:
74+
- name: Checkout repository
75+
uses: actions/checkout@v2
76+
77+
- name: Install Go
78+
uses: actions/setup-go@v2
79+
with:
80+
go-version: ${{ env.GO_VERSION }}
81+
82+
- name: Install Python
83+
uses: actions/setup-python@v2
84+
with:
85+
python-version: ${{ env.PYTHON_VERSION }}
86+
87+
- name: Install Poetry
88+
run: pip install poetry
89+
90+
- name: Install Task
91+
uses: arduino/setup-task@v1
92+
with:
93+
repo-token: ${{ secrets.GITHUB_TOKEN }}
94+
version: 3.x
95+
96+
# build the agent without GUI support (no tray icon) for integration testing
97+
- name: Build the Agent-cli
98+
run: task go:build-cli
99+
if: matrix.operating-system != 'windows-latest'
100+
101+
- name: Build the Agent-cli for win
102+
run: task go:build-win-cli
103+
if: matrix.operating-system == 'windows-latest'
104+
105+
- name: Run integration tests
106+
run: task go:test-integration

.github/workflows/test.yml

-115
This file was deleted.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[![License: GPL v2](https://img.shields.io/badge/License-GPL%20v2-blue.svg)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
22
[![Test Go status](https://github.com/arduino/arduino-create-agent/actions/workflows/test-go-task.yml/badge.svg)](https://github.com/arduino/arduino-create-agent/actions/workflows/test-go-task.yml)
33
[![Codecov](https://codecov.io/gh/arduino/arduino-create-agent/branch/main/graph/badge.svg)](https://codecov.io/gh/arduino/arduino-create-agent)
4+
[![Test Integration status](https://github.com/arduino/arduino-create-agent/actions/workflows/test-go-integration-task.yml/badge.svg)](https://github.com/arduino/arduino-create-agent/actions/workflows/test-go-integration-task.yml)
45

56
arduino-create-agent
67
====================

Taskfile.yml

+34-10
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,42 @@
11
version: '3'
22

33
tasks:
4-
5-
build:
4+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/go-task/Taskfile.yml
5+
go:build:
66
desc: Build the project, to use a specific version use `task build TAG_VERSION=x.x.x`
7+
dir: "{{.DEFAULT_GO_MODULE_PATH}}"
78
cmds:
89
- go build -v -i {{default "" .ADDITIONAL_FLAGS}} -o {{default "arduino-create-agent" .APP_NAME}} -ldflags '-X main.version={{default .TAG_TEST .TAG_VERSION}} -X main.git_revision={{.COMMIT}} {{default "" .WIN_FLAGS}}'
910
vars:
1011
COMMIT:
1112
sh: git log -n 1 --format=%h
1213

13-
build-cli:
14-
desc: Build the project without tray support
14+
go:build-cli:
15+
desc: Build the project without tray icon support
1516
cmds:
16-
- task: build
17+
- task: go:build
1718
vars:
1819
APP_NAME: arduino-create-agent_cli
1920
ADDITIONAL_FLAGS: -tags cli
2021

21-
build-win:
22+
go:build-win:
2223
desc: Build the project for win, to build 32bit `export GOARCH=386` and for 64 bit `export GOARCH=amd64` before `task build-win`
2324
cmds:
2425
- rsrc -arch {{.GOARCH}} -manifest manifest.xml # GOARCH shoud be either amd64 or 386
25-
- task: build
26+
- task: go:build
2627
vars:
2728
APP_NAME: arduino-create-agent.exe
2829
WIN_FLAGS: -H=windowsgui
2930
- rm *.syso # rm file to avoid compilation problems on other platforms
3031

32+
go:build-win-cli:
33+
desc: Build the project fow win without tray icon support
34+
cmds:
35+
- task: go:build
36+
vars:
37+
APP_NAME: arduino-create-agent_cli.exe
38+
ADDITIONAL_FLAGS: -tags cli
39+
3140
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-go-task/Taskfile.yml
3241
go:test:
3342
desc: Run unit tests
@@ -42,11 +51,26 @@ tasks:
4251
-coverprofile=coverage_unit.txt \
4352
{{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
4453
45-
test-e2e:
46-
desc: Run end 2 end tests
54+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-go-integration-task/Taskfile.yml
55+
go:test-integration:
56+
desc: Run integration tests
57+
deps:
58+
# - task: go:build # we build it in the CI and not in the task because _cli version is required and build procedure is different on win
59+
- task: poetry:install-deps
60+
cmds:
61+
- poetry run pytest tests
62+
63+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
64+
poetry:install-deps:
65+
desc: Install dependencies managed by Poetry
4766
cmds:
4867
- poetry install --no-root
49-
- poetry run pytest test
68+
69+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
70+
poetry:update-deps:
71+
desc: Update all dependencies managed by Poetry to their newest versions
72+
cmds:
73+
- poetry update
5074

5175
check:
5276
desc: Check fmt and lint

tests/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@pytest.fixture(scope="function")
1313
def agent(pytestconfig):
1414

15-
agent_cli = str(Path(pytestconfig.rootdir) / "arduino-create-agent")
15+
agent_cli = str(Path(pytestconfig.rootdir) / "arduino-create-agent_cli")
1616
env = {
1717
# "ARDUINO_DATA_DIR": data_dir,
1818
# "ARDUINO_DOWNLOADS_DIR": downloads_dir,

0 commit comments

Comments
 (0)