Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[flake8]
doctests = True
ignore =
# W503 and W504 are mutually exclusive, so one or the other must be ignored.
# PEP 8 recommends line break before, so we keep W504.
W503
max-complexity = 10
max-line-length = 120
select = E,W,F,C,N
40 changes: 40 additions & 0 deletions .github/workflows/lint-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Lint Python code

on:
push:
paths:
- "**.py"
- ".flake8"
- "pyproject.toml"
- "Taskfile.yml"
pull_request:
paths:
- "**.py"
- ".flake8"
- "pyproject.toml"
- "Taskfile.yml"

jobs:
lint-python:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install Taskfile
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: "3.8"

- name: Install Poetry
run: pip install poetry

- name: Lint Python files
run: task python:check
18 changes: 13 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x

- name: Build native
shell: bash
run: task build

- name: Cross-build for 386
if: matrix.os != 'macos-latest'
env:
Expand All @@ -48,5 +44,17 @@ jobs:
GOARCH: "arm"
run: task build

- name: Run unit tests
- name: Build native
shell: bash
run: task build

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: "3.8"

- name: Install Poetry
run: pip install poetry

- name: Run unit and integration tests
run: task test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.idea
coverage_*.txt
/dist
__pycache__/

# Misc.
.DS_Store
29 changes: 29 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,21 @@ tasks:

test:
desc: Run tests
cmds:
- task: test-unit
- task: test-integration

test-unit:
desc: Run unit tests
cmds:
- go test -short -race -run '.*' {{ default "-v" .GOFLAGS }} -coverprofile=coverage_unit.txt ./... {{.TEST_LDFLAGS}}

test-integration:
desc: Run integration tests
cmds:
- poetry install --no-root
- poetry run pytest test

check:
desc: Check fmt and lint
cmds:
Expand All @@ -44,6 +56,7 @@ tasks:
- "'{{.GOLINTBIN}}' {{.GOLINTFLAGS}} ./..."
- task: docs:check
- task: config:check
- task: python:check

config:check:
desc: Check linting of configuration and supporting files
Expand All @@ -55,6 +68,22 @@ tasks:
cmds:
- npx {{ .PRETTIER }} --write "**/*.{yml,yaml}"

python:check:
cmds:
- task: python:lint

python:lint:
desc: Lint Python code
cmds:
- poetry install --no-root
- poetry run flake8

python:format:
desc: Automatically formats Python files
cmds:
- poetry install --no-root
- poetry run black .

vars:
PROJECT_NAME: "FirmwareUploader"
DIST_DIR: "dist"
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTk
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
Expand Down
Loading