Skip to content

Commit 2ee48e4

Browse files
Add integration tests (#36)
This adds end to end testing of the tool to verify that the finished outputs are as expected. Co-authored-by: Silvano Cerza <3314350+silvanocerza@users.noreply.github.com>
1 parent 4084993 commit 2ee48e4

File tree

19 files changed

+2933
-4
lines changed

19 files changed

+2933
-4
lines changed

.codespellrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# See: https://github.com/codespell-project/codespell#using-a-config-file
22
[codespell]
33
# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here:
4-
ignore-words-list = pullrequest
4+
ignore-words-list = easly,pullrequest
55
builtin = clear,informal,en-GB_to_en-US
66
check-filenames =
77
check-hidden =

.flake8

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# See: https://flake8.pycqa.org/en/latest/user/configuration.html
2+
3+
[flake8]
4+
doctests = True
5+
# W503 and W504 are mutually exclusive. PEP 8 recommends line break before.
6+
ignore = W503
7+
max-complexity = 10
8+
max-line-length = 120
9+
select = E,W,F,C,N
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Check Python
2+
3+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
4+
on:
5+
push:
6+
paths:
7+
- ".github/workflows/check-python-task.ya?ml"
8+
- "**/.flake8"
9+
- "**/poetry.lock"
10+
- "**/pyproject.toml"
11+
- "**/setup.cfg"
12+
- "Taskfile.ya?ml"
13+
- "**/tox.ini"
14+
- "**.py"
15+
pull_request:
16+
paths:
17+
- ".github/workflows/check-python-task.ya?ml"
18+
- "**/.flake8"
19+
- "**/poetry.lock"
20+
- "**/pyproject.toml"
21+
- "**/setup.cfg"
22+
- "Taskfile.ya?ml"
23+
- "**/tox.ini"
24+
- "**.py"
25+
workflow_dispatch:
26+
repository_dispatch:
27+
28+
jobs:
29+
lint:
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v2
35+
36+
- name: Install Python
37+
uses: actions/setup-python@v2
38+
with:
39+
python-version: "3.9"
40+
41+
- name: Install Poetry
42+
run: pip install poetry
43+
44+
- name: Install Task
45+
uses: arduino/setup-task@v1
46+
with:
47+
repo-token: ${{ secrets.GITHUB_TOKEN }}
48+
version: 3.x
49+
50+
- name: Run flake8
51+
run: task python:lint
52+
53+
formatting:
54+
runs-on: ubuntu-latest
55+
56+
steps:
57+
- name: Checkout repository
58+
uses: actions/checkout@v2
59+
60+
- name: Install Python
61+
uses: actions/setup-python@v2
62+
with:
63+
python-version: "3.9"
64+
65+
- name: Install Poetry
66+
run: pip install poetry
67+
68+
- name: Install Task
69+
uses: arduino/setup-task@v1
70+
with:
71+
repo-token: ${{ secrets.GITHUB_TOKEN }}
72+
version: 3.x
73+
74+
- name: Format Python code
75+
run: task python:format
76+
77+
- name: Check formatting
78+
run: git diff --color --exit-code
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Test Integration
2+
3+
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
4+
on:
5+
push:
6+
paths:
7+
- ".github/workflows/test-integration.yml"
8+
- "Taskfile.yml"
9+
- "**.go"
10+
- "go.mod"
11+
- "go.sum"
12+
- "poetry.lock"
13+
- "pyproject.toml"
14+
- "test/**"
15+
pull_request:
16+
paths:
17+
- ".github/workflows/test-integration.yml"
18+
- "Taskfile.yml"
19+
- "**.go"
20+
- "go.mod"
21+
- "go.sum"
22+
- "poetry.lock"
23+
- "pyproject.toml"
24+
- "test/**"
25+
workflow_dispatch:
26+
repository_dispatch:
27+
28+
jobs:
29+
test:
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v2
35+
36+
- name: Install Go
37+
uses: actions/setup-go@v2
38+
with:
39+
go-version: "1.14"
40+
41+
- name: Install Python
42+
uses: actions/setup-python@v2
43+
with:
44+
python-version: "3.9"
45+
46+
- name: Install Poetry
47+
run: pip install poetry
48+
49+
- name: Install Arduino Lint
50+
run: |
51+
ARDUINO_LINT_INSTALLATION_PATH="${{ runner.temp }}/arduino-lint"
52+
mkdir --parents "$ARDUINO_LINT_INSTALLATION_PATH"
53+
curl \
54+
-fsSL \
55+
https://raw.githubusercontent.com/arduino/arduino-lint/main/etc/install.sh \
56+
| \
57+
BINDIR="$ARDUINO_LINT_INSTALLATION_PATH" \
58+
sh
59+
60+
# Add installation folder to path to path
61+
echo "$ARDUINO_LINT_INSTALLATION_PATH" >> "$GITHUB_PATH"
62+
63+
- name: Install Taskfile
64+
uses: arduino/setup-task@v1
65+
with:
66+
repo-token: ${{ secrets.GITHUB_TOKEN }}
67+
version: 3.x
68+
69+
- name: Run integration tests
70+
run: task go:test-integration

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ libraries-repository-engine.exe
66
repository
77
repository.exe
88
test/arduino/cc/repository/libraries/testdata/test_db.json
9-
config.json
10-
repos.txt
9+
/config.json
10+
/repos.txt
11+
__pycache__/
1112

1213
# Created by .gitignore support plugin (hsz.mobi)
1314
### Go template

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# See: https://prettier.io/docs/en/ignore.html#ignoring-files-prettierignore
2+
3+
/test/testdata/golden/logs/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# libraries-repository-engine
22

33
[![Test Go status](https://github.com/arduino/libraries-repository-engine/actions/workflows/test-go.yml/badge.svg)](https://github.com/arduino/libraries-repository-engine/actions/workflows/test-go.yml)
4+
[![Integration Test status](https://github.com/arduino/libraries-repository-engine/actions/workflows/test-integration.yml/badge.svg)](https://github.com/arduino/libraries-repository-engine/actions/workflows/test-integration.yml)
45
[![Check Go status](https://github.com/arduino/libraries-repository-engine/actions/workflows/check-go.yml/badge.svg)](https://github.com/arduino/libraries-repository-engine/actions/workflows/check-go.yml)
56
[![Check Prettier Formatting status](https://github.com/arduino/libraries-repository-engine/actions/workflows/check-prettier-formatting-task.yml/badge.svg)](https://github.com/arduino/libraries-repository-engine/actions/workflows/check-prettier-formatting-task.yml)
67
[![Check Taskfiles status](https://github.com/arduino/libraries-repository-engine/actions/workflows/check-taskfiles.yml/badge.svg)](https://github.com/arduino/libraries-repository-engine/actions/workflows/check-taskfiles.yml)

Taskfile.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@ tasks:
1717
- task: general:check-spelling
1818
- task: go:lint
1919
- task: go:test
20+
- task: go:test-integration
2021
- task: go:vet
22+
- task: python:lint
2123

2224
format:
2325
desc: Correct the formatting of the project's files
2426
deps:
2527
- task: general:format-prettier
2628
- task: go:format
29+
- task: python:format
2730

2831
go:build:
2932
desc: Build the project
@@ -35,6 +38,13 @@ tasks:
3538
cmds:
3639
- go test -v -short -run '{{default ".*" .GO_TEST_REGEX}}' {{default "-timeout 10m -coverpkg=./... -covermode=atomic" .GO_TEST_FLAGS}} -coverprofile=coverage_unit.txt {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
3740

41+
go:test-integration:
42+
desc: Run integration tests
43+
cmds:
44+
- task: go:build
45+
- poetry install --no-root
46+
- poetry run pytest test
47+
3848
go:check:
3949
desc: Check for problems with Go code
4050
deps:
@@ -71,6 +81,18 @@ tasks:
7181
cmds:
7282
- go fmt {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
7383

84+
python:lint:
85+
desc: Lint Python code
86+
cmds:
87+
- poetry install --no-root
88+
- poetry run flake8 --show-source
89+
90+
python:format:
91+
desc: Automatically formats Python files
92+
cmds:
93+
- poetry install --no-root
94+
- poetry run black .
95+
7496
general:format-prettier:
7597
desc: Format all supported files with Prettier
7698
cmds:

0 commit comments

Comments
 (0)