Skip to content

Commit 64734b2

Browse files
authored
[skip-changelog] add testing and linting infrastructure (#39)
* [skip-changelog] add integration testing infrastructure * [skip-changelog] add linting infrastructure and apply formatting * fix prettier * move build native step to the bottom to fix test failing * apply suggestions from code review * add workflow to check general formatting using editorconfig
1 parent 6ae09d2 commit 64734b2

12 files changed

+640
-1
lines changed

.flake8

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[flake8]
2+
doctests = True
3+
ignore =
4+
# W503 and W504 are mutually exclusive, so one or the other must be ignored.
5+
# PEP 8 recommends line break before, so we keep W504.
6+
W503
7+
max-complexity = 10
8+
max-line-length = 120
9+
select = E,W,F,C,N
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Check General Formatting
2+
3+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
4+
on:
5+
push:
6+
pull_request:
7+
schedule:
8+
# Run every Tuesday at 8 AM UTC to catch breakage caused by changes to tools.
9+
- cron: "0 8 * * TUE"
10+
workflow_dispatch:
11+
repository_dispatch:
12+
13+
jobs:
14+
check:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v2
20+
21+
- name: Check formatting
22+
uses: editorconfig-checker/[email protected]

.github/workflows/lint-python.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Lint Python code
2+
3+
on:
4+
push:
5+
paths:
6+
- "**.py"
7+
- ".flake8"
8+
- "pyproject.toml"
9+
- "Taskfile.yml"
10+
pull_request:
11+
paths:
12+
- "**.py"
13+
- ".flake8"
14+
- "pyproject.toml"
15+
- "Taskfile.yml"
16+
17+
jobs:
18+
lint-python:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v2
24+
25+
- name: Install Taskfile
26+
uses: arduino/setup-task@v1
27+
with:
28+
repo-token: ${{ secrets.GITHUB_TOKEN }}
29+
version: 3.x
30+
31+
- name: Install Python
32+
uses: actions/setup-python@v2
33+
with:
34+
python-version: "3.8"
35+
36+
- name: Install Poetry
37+
run: pip install poetry
38+
39+
- name: Lint Python files
40+
run: task python:check

.github/workflows/test.yaml

+9-1
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,13 @@ jobs:
4848
GOARCH: "arm"
4949
run: task build
5050

51-
- name: Run unit tests
51+
- name: Install Python
52+
uses: actions/setup-python@v2
53+
with:
54+
python-version: "3.8"
55+
56+
- name: Install Poetry
57+
run: pip install poetry
58+
59+
- name: Run unit and integration tests
5260
run: task test

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
.idea
55
coverage_*.txt
66
/dist
7+
__pycache__/
78

89
# Misc.
910
.DS_Store

Taskfile.yml

+30
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,22 @@ tasks:
3333

3434
test:
3535
desc: Run tests
36+
cmds:
37+
- task: test-unit
38+
- task: test-integration
39+
40+
test-unit:
41+
desc: Run unit tests
3642
cmds:
3743
- go test -short -race -run '.*' {{ default "-v" .GOFLAGS }} -coverprofile=coverage_unit.txt ./... {{.TEST_LDFLAGS}}
3844

45+
test-integration:
46+
desc: Run integration tests
47+
cmds:
48+
- task: build
49+
- poetry install --no-root
50+
- poetry run pytest test
51+
3952
check:
4053
desc: Check fmt and lint
4154
cmds:
@@ -44,6 +57,7 @@ tasks:
4457
- "'{{.GOLINTBIN}}' {{.GOLINTFLAGS}} ./..."
4558
- task: docs:check
4659
- task: config:check
60+
- task: python:check
4761

4862
config:check:
4963
desc: Check linting of configuration and supporting files
@@ -55,6 +69,22 @@ tasks:
5569
cmds:
5670
- npx {{ .PRETTIER }} --write "**/*.{yml,yaml}"
5771

72+
python:check:
73+
cmds:
74+
- task: python:lint
75+
76+
python:lint:
77+
desc: Lint Python code
78+
cmds:
79+
- poetry install --no-root
80+
- poetry run flake8
81+
82+
python:format:
83+
desc: Automatically formats Python files
84+
cmds:
85+
- poetry install --no-root
86+
- poetry run black .
87+
5888
vars:
5989
PROJECT_NAME: "FirmwareUploader"
6090
DIST_DIR: "dist"

go.sum

+1
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTk
307307
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
308308
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
309309
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
310+
golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=
310311
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
311312
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
312313
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=

0 commit comments

Comments
 (0)