Skip to content

Sync test assets workflow with templates #227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
94c1820
Move integration test runs to dedicated workflow
per1234 Aug 4, 2021
683d54e
Move generated code sync check to dedicated workflow
per1234 Aug 4, 2021
78c8d43
Move tester build generation to dedicated workflow
per1234 Aug 4, 2021
94e425d
Use standardized filename for test runner workflow
per1234 Aug 4, 2021
5dc498b
Replace discouraged shell syntax in taskfile dynamic variable
per1234 Aug 5, 2021
745aa44
Use standardized name for build and test tasks
per1234 Aug 5, 2021
35421dd
Use Python dependency installation task in integration test task
per1234 Aug 5, 2021
f9a2457
Move build task to the `go:test-integration` task's `deps` key
per1234 Aug 5, 2021
e957cf5
Use standardized name for integration test folder
per1234 Aug 5, 2021
9c9f5b0
Remove project-specific references from integration test files
per1234 Aug 5, 2021
3b7e653
Improve formatting of integration test helper functions
per1234 Aug 5, 2021
bf9cb89
Make integration test work directory path canonical
per1234 Aug 5, 2021
59f0894
Clean up integration test working directory
per1234 Aug 5, 2021
db50dfd
Bump pytest integration testing dependency to ^6.2.4
per1234 Aug 5, 2021
6015029
Bump `invoke` integration test dependency to ^1.5.0
per1234 Aug 5, 2021
b338cfb
Add linebreaks to `go test` command
per1234 Aug 5, 2021
75ab8aa
Use more specific override variable name for unit test regex
per1234 Aug 5, 2021
fd35878
Fix error in `go test` command template
per1234 Aug 5, 2021
3bc729c
Add source URL comments to testing assets
per1234 Aug 5, 2021
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
47 changes: 47 additions & 0 deletions .github/workflows/check-code-generation-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Check Code Generation

on:
push:
paths:
- ".github/workflows/check-code-generation-task.ya?ml"
- "Taskfile.yml"
- "go.mod"
- "go.sum"
- "**/*.go"
- "etc/schemas/**/*.json"
pull_request:
paths:
- ".github/workflows/check-code-generation-task.ya?ml"
- "Taskfile.yml"
- "go.mod"
- "go.sum"
- "**/*.go"
- "etc/schemas/**/*.json"

env:
BUILDS_ARTIFACT: build-artifacts

jobs:
test-go:
runs-on: ubuntu-latest

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

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "1.16"

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

- name: Generate code
run: task go:generate

- name: Check for forgotten code generation
run: git diff --color --exit-code
Original file line number Diff line number Diff line change
@@ -1,94 +1,37 @@
name: Run tests
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/publish-go-tester-task.md
name: Publish Tester Build

# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/test.yml"
- "Taskfile.yml"
- ".github/workflows/publish-go-tester-task.ya?ml"
- "go.mod"
- "go.sum"
- "**/*.go"
- "**/testdata/**"
- "etc/schemas/**/*.json"
- "pyproject.toml"
- "test/**"
- "Taskfile.yml"
- "Taskfile.ya?ml"
- "**.go"
pull_request:
paths:
- ".github/workflows/test.yml"
- "Taskfile.yml"
- ".github/workflows/publish-go-tester-task.ya?ml"
- "go.mod"
- "go.sum"
- "**/*.go"
- "**/testdata/**"
- "etc/schemas/**/*.json"
- "pyproject.toml"
- "test/**"
- "Taskfile.yml"
- "Taskfile.ya?ml"
- "**.go"
workflow_dispatch:
repository_dispatch:

env:
# As defined by the Taskfile's DIST_DIR variable
DIST_DIR: dist
BUILDS_ARTIFACT: build-artifacts

jobs:
test-go:
strategy:
matrix:
operating-system:
- ubuntu-latest
- windows-latest
- macOS-latest

runs-on: ${{ matrix.operating-system }}

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

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "1.16"

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

- name: Generate code
run: task go:generate

- name: Check for forgotten code generation
run: git diff --color --exit-code

- name: Run unit tests
run: task go:test-unit

- name: Send unit tests coverage to Codecov
if: matrix.operating-system == 'ubuntu-latest'
uses: codecov/codecov-action@v1
with:
file: ./coverage_unit.txt
flags: unit
fail_ci_if_error: true

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

- name: Install Poetry
run: pip install poetry

- name: Run integration tests
run: task test-integration

build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
fetch-depth: 0

Expand All @@ -112,7 +55,7 @@ jobs:
- name: Upload combined builds artifact
uses: actions/upload-artifact@v2
with:
path: dist/
path: ${{ env.DIST_DIR }}
name: ${{ env.BUILDS_ARTIFACT }}

artifacts:
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/test-go-integration-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Test Integration

on:
push:
paths:
- ".github/workflows/test-go-integration-task.ya?ml"
- "Taskfile.ya?ml"
- "**.go"
- "go.mod"
- "go.sum"
- "poetry.lock"
- "pyproject.toml"
- "tests/**"
pull_request:
paths:
- ".github/workflows/test-go-integration-task.ya?ml"
- "Taskfile.ya?ml"
- "**.go"
- "go.mod"
- "go.sum"
- "poetry.lock"
- "pyproject.toml"
- "tests/**"

jobs:
test-go:
strategy:
matrix:
operating-system:
- ubuntu-latest
- windows-latest
- macOS-latest

runs-on: ${{ matrix.operating-system }}

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

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "1.16"

- 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.9"

- name: Install Poetry
run: pip install poetry

- name: Run integration tests
run: task go:test-integration
59 changes: 59 additions & 0 deletions .github/workflows/test-go-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Run tests

on:
push:
paths:
- ".github/workflows/test-go-task.ya?ml"
- "Taskfile.yml"
- "go.mod"
- "go.sum"
- "**/*.go"
- "**/testdata/**"
pull_request:
paths:
- ".github/workflows/test-go-task.ya?ml"
- "Taskfile.yml"
- "go.mod"
- "go.sum"
- "**/*.go"
- "**/testdata/**"

env:
BUILDS_ARTIFACT: build-artifacts

jobs:
test-go:
strategy:
matrix:
operating-system:
- ubuntu-latest
- windows-latest
- macOS-latest

runs-on: ${{ matrix.operating-system }}

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

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "1.16"

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

- name: Run unit tests
run: task go:test

- name: Send unit tests coverage to Codecov
if: matrix.operating-system == 'ubuntu-latest'
uses: codecov/codecov-action@v1
with:
file: ./coverage_unit.txt
flags: unit
fail_ci_if_error: true
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Arduino Lint

[![Tests Status](https://github.com/arduino/arduino-lint/workflows/Run%20tests/badge.svg)](https://github.com/arduino/arduino-lint/actions?workflow=Run+tests)
[![Test Go status](https://github.com/arduino/arduino-lint/actions/workflows/test-go-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/test-go-task.yml)
[![Test Integration status](https://github.com/arduino/arduino-lint/actions/workflows/test-go-integration-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/test-go-integration-task.yml)
[![Check Go status](https://github.com/arduino/arduino-lint/actions/workflows/check-go-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-go-task.yml)
[![Check Code Generation status](https://github.com/arduino/arduino-lint/actions/workflows/check-code-generation-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-code-generation-task.yml)
[![Publish Tester Build status](https://github.com/arduino/arduino-lint/actions/workflows/publish-go-tester-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/publish-go-tester-task.yml)
[![Publish Nightly Build status](https://github.com/arduino/arduino-lint/actions/workflows/publish-go-nightly-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/publish-go-nightly-task.yml)
[![Check Python status](https://github.com/arduino/arduino-lint/actions/workflows/check-python-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-python-task.yml)
[![Check Markdown status](https://github.com/arduino/arduino-lint/actions/workflows/check-markdown-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-markdown-task.yml)
Expand Down
39 changes: 27 additions & 12 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ vars:
PROJECT_NAME: "arduino-lint"
DIST_DIR: "dist"
DEFAULT_GO_PACKAGES:
sh: echo `go list ./... | grep --invert-match 'github.com/arduino/arduino-lint/internal/rule/schema/schemadata' | tr '\n' ' '`
sh: echo $(go list ./... | grep --invert-match 'github.com/arduino/arduino-lint/internal/rule/schema/schemadata' | tr '\n' ' ')
# build vars
COMMIT:
sh: echo "$(git log --no-show-signature -n 1 --format=%h)"
Expand All @@ -28,7 +28,6 @@ vars:
-X {{.CONFIGURATION_PACKAGE}}.Commit={{.COMMIT}}
-X {{.CONFIGURATION_PACKAGE}}.Timestamp={{.TIMESTAMP}}
'
GOFLAGS: "-timeout 10m -v -coverpkg=./... -covermode=atomic"
DOCS_VERSION: dev
DOCS_ALIAS: ""
DOCS_REMOTE: "origin"
Expand All @@ -41,14 +40,20 @@ vars:
tasks:
build:
desc: Build the project
cmds:
- go build -v {{.LDFLAGS}}
deps:
- task: go:build

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

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/go-task/Taskfile.yml
go:build:
desc: Build the Go code
cmds:
- go build -v {{.LDFLAGS}}

go:generate:
desc: Generate Go code
Expand All @@ -60,17 +65,27 @@ tasks:
- go generate ./...
- task: go:format

go:test-unit:
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-go-task/Taskfile.yml
go:test:
desc: Run unit tests
cmds:
- go test -short -run '{{default ".*" .TEST_REGEX}}' {{default "-v" .GOFLAGS}} -coverprofile=coverage_unit.txt {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
- |
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}}

test-integration:
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-go-integration-task/Taskfile.yml
go:test-integration:
desc: Run integration tests
deps:
- task: go:build
- task: poetry:install-deps
cmds:
- task: build
- poetry install --no-root
- poetry run pytest test
- poetry run pytest tests

check:
desc: Lint and check formatting of all files
Expand Down
Loading