From 94c1820f2f4b92d2e82c465cd5e8102795e4580b Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 4 Aug 2021 16:23:41 -0700 Subject: [PATCH 01/19] Move integration test runs to dedicated workflow Due to the tests being located in a dedicated folder and written in Python, there are unique paths filter requirements for the GitHub Actions workflow that runs the project's integration tests. For this reason, and also to enable the unit test workflow to be applied to projects that use other integration testing approaches (i.e., none at all), it is better to use separate workflows to run unit tests vs. integration tests. --- .../workflows/test-go-integration-task.yml | 60 +++++++++++++++++++ .github/workflows/test.yml | 17 ------ README.md | 1 + 3 files changed, 61 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/test-go-integration-task.yml diff --git a/.github/workflows/test-go-integration-task.yml b/.github/workflows/test-go-integration-task.yml new file mode 100644 index 00000000..52dbdab7 --- /dev/null +++ b/.github/workflows/test-go-integration-task.yml @@ -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" + - "test/**" + pull_request: + paths: + - ".github/workflows/test-go-integration-task.ya?ml" + - "Taskfile.ya?ml" + - "**.go" + - "go.mod" + - "go.sum" + - "poetry.lock" + - "pyproject.toml" + - "test/**" + +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 test-integration diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 552cc2fd..5ed74edb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,9 +10,6 @@ on: - "**/*.go" - "**/testdata/**" - "etc/schemas/**/*.json" - - "pyproject.toml" - - "test/**" - - "Taskfile.yml" pull_request: paths: - ".github/workflows/test.yml" @@ -22,9 +19,6 @@ on: - "**/*.go" - "**/testdata/**" - "etc/schemas/**/*.json" - - "pyproject.toml" - - "test/**" - - "Taskfile.yml" env: BUILDS_ARTIFACT: build-artifacts @@ -72,17 +66,6 @@ jobs: 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 diff --git a/README.md b/README.md index 135a3f55..e06850ca 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # 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 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) [![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) From 683d54e345f8bbbd824af1378a211ba2a49ccd6e Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 4 Aug 2021 16:33:10 -0700 Subject: [PATCH 02/19] Move generated code sync check to dedicated workflow I have found that the approach of focusing each GitHub Actions workflows on a specific type of task can have some significant benefits - Improved efficiency due to being able to use a refined paths filter to prevent pointless runs of the workflow - Easier for contributors to interpret the results in the event of a failure - Easier to maintain - More likely to be applicable as a "template" to arbitrary projects This check really had no business being in the test runner workflow. It could be argued that it is suitable for inclusion in the "Check Go" workflow, but it does have unique paths filter requirements and is also not in that workflow's "template". So, at least for now, I am putting it in a dedicated workflow. --- .../workflows/check-code-generation-task.yml | 47 +++++++++++++++++++ .github/workflows/test.yml | 8 ---- README.md | 1 + 3 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/check-code-generation-task.yml diff --git a/.github/workflows/check-code-generation-task.yml b/.github/workflows/check-code-generation-task.yml new file mode 100644 index 00000000..074b9e7c --- /dev/null +++ b/.github/workflows/check-code-generation-task.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5ed74edb..c61deb99 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,6 @@ on: - "go.sum" - "**/*.go" - "**/testdata/**" - - "etc/schemas/**/*.json" pull_request: paths: - ".github/workflows/test.yml" @@ -18,7 +17,6 @@ on: - "go.sum" - "**/*.go" - "**/testdata/**" - - "etc/schemas/**/*.json" env: BUILDS_ARTIFACT: build-artifacts @@ -49,12 +47,6 @@ jobs: 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 diff --git a/README.md b/README.md index e06850ca..50b02e28 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![Tests Status](https://github.com/arduino/arduino-lint/workflows/Run%20tests/badge.svg)](https://github.com/arduino/arduino-lint/actions?workflow=Run+tests) [![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 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) From 78c8d43b8e0fb53d7a3fc523ed2f8dd23f8c9796 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 4 Aug 2021 16:46:18 -0700 Subject: [PATCH 03/19] Move tester build generation to dedicated workflow This process had no business being in the unit test runner workflow, not being related to the running of unit tests. --- .github/workflows/publish-go-tester-task.yml | 109 +++++++++++++++++++ .github/workflows/test.yml | 82 -------------- README.md | 1 + 3 files changed, 110 insertions(+), 82 deletions(-) create mode 100644 .github/workflows/publish-go-tester-task.yml diff --git a/.github/workflows/publish-go-tester-task.yml b/.github/workflows/publish-go-tester-task.yml new file mode 100644 index 00000000..80fd3ef8 --- /dev/null +++ b/.github/workflows/publish-go-tester-task.yml @@ -0,0 +1,109 @@ +# 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/publish-go-tester-task.ya?ml" + - "go.mod" + - "go.sum" + - "Taskfile.ya?ml" + - "**.go" + pull_request: + paths: + - ".github/workflows/publish-go-tester-task.ya?ml" + - "go.mod" + - "go.sum" + - "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: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install Taskfile + uses: arduino/setup-task@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x + + - name: Build + run: | + PACKAGE_NAME_PREFIX="${{ github.workflow }}" + if [ "${{ github.event_name }}" = "pull_request" ]; then + PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.event.number }}" + fi + PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.sha }}-" + export PACKAGE_NAME_PREFIX + task dist:all + + # Transfer builds to artifacts job + - name: Upload combined builds artifact + uses: actions/upload-artifact@v2 + with: + path: ${{ env.DIST_DIR }} + name: ${{ env.BUILDS_ARTIFACT }} + + artifacts: + name: ${{ matrix.artifact.name }} artifact + needs: build + runs-on: ubuntu-latest + + strategy: + matrix: + artifact: + - path: "*checksums.txt" + name: checksums + - path: "*Linux_32bit.tar.gz" + name: Linux_X86-32 + - path: "*Linux_64bit.tar.gz" + name: Linux_X86-64 + - path: "*Linux_ARM64.tar.gz" + name: Linux_ARM64 + - path: "*Linux_ARMv6.tar.gz" + name: Linux_ARMv6 + - path: "*Linux_ARMv7.tar.gz" + name: Linux_ARMv7 + - path: "*macOS_64bit.tar.gz" + name: macOS_64 + - path: "*Windows_32bit.zip" + name: Windows_X86-32 + - path: "*Windows_64bit.zip" + name: Windows_X86-64 + + steps: + - name: Download combined builds artifact + uses: actions/download-artifact@v2 + with: + name: ${{ env.BUILDS_ARTIFACT }} + path: ${{ env.BUILDS_ARTIFACT }} + + - name: Upload individual build artifact + uses: actions/upload-artifact@v2 + with: + path: ${{ env.BUILDS_ARTIFACT }}/${{ matrix.artifact.path }} + name: ${{ matrix.artifact.name }} + + clean: + needs: artifacts + runs-on: ubuntu-latest + + steps: + - name: Remove unneeded combined builds artifact + uses: geekyeggo/delete-artifact@v1 + with: + name: ${{ env.BUILDS_ARTIFACT }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c61deb99..3c4ea361 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -57,85 +57,3 @@ jobs: file: ./coverage_unit.txt flags: unit fail_ci_if_error: true - - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v1 - with: - fetch-depth: 0 - - - name: Install Taskfile - uses: arduino/setup-task@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - version: 3.x - - - name: Build - run: | - PACKAGE_NAME_PREFIX="${{ github.workflow }}" - if [ "${{ github.event_name }}" = "pull_request" ]; then - PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.event.number }}" - fi - PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.sha }}-" - export PACKAGE_NAME_PREFIX - task dist:all - - # Transfer builds to artifacts job - - name: Upload combined builds artifact - uses: actions/upload-artifact@v2 - with: - path: dist/ - name: ${{ env.BUILDS_ARTIFACT }} - - artifacts: - name: ${{ matrix.artifact.name }} artifact - needs: build - runs-on: ubuntu-latest - - strategy: - matrix: - artifact: - - path: "*checksums.txt" - name: checksums - - path: "*Linux_32bit.tar.gz" - name: Linux_X86-32 - - path: "*Linux_64bit.tar.gz" - name: Linux_X86-64 - - path: "*Linux_ARM64.tar.gz" - name: Linux_ARM64 - - path: "*Linux_ARMv6.tar.gz" - name: Linux_ARMv6 - - path: "*Linux_ARMv7.tar.gz" - name: Linux_ARMv7 - - path: "*macOS_64bit.tar.gz" - name: macOS_64 - - path: "*Windows_32bit.zip" - name: Windows_X86-32 - - path: "*Windows_64bit.zip" - name: Windows_X86-64 - - steps: - - name: Download combined builds artifact - uses: actions/download-artifact@v2 - with: - name: ${{ env.BUILDS_ARTIFACT }} - path: ${{ env.BUILDS_ARTIFACT }} - - - name: Upload individual build artifact - uses: actions/upload-artifact@v2 - with: - path: ${{ env.BUILDS_ARTIFACT }}/${{ matrix.artifact.path }} - name: ${{ matrix.artifact.name }} - - clean: - needs: artifacts - runs-on: ubuntu-latest - - steps: - - name: Remove unneeded combined builds artifact - uses: geekyeggo/delete-artifact@v1 - with: - name: ${{ env.BUILDS_ARTIFACT }} diff --git a/README.md b/README.md index 50b02e28..d9b25dc3 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![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) From 94e425db0e66c142a4975657c65b0e3ecf220764 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 4 Aug 2021 16:51:38 -0700 Subject: [PATCH 04/19] Use standardized filename for test runner workflow This is the template workflow filename, which is intended to serve as a unique identifier, and thus must be a bit more verbose. --- .github/workflows/{test.yml => test-go-task.yml} | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename .github/workflows/{test.yml => test-go-task.yml} (92%) diff --git a/.github/workflows/test.yml b/.github/workflows/test-go-task.yml similarity index 92% rename from .github/workflows/test.yml rename to .github/workflows/test-go-task.yml index 3c4ea361..0313788d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test-go-task.yml @@ -3,7 +3,7 @@ name: Run tests on: push: paths: - - ".github/workflows/test.yml" + - ".github/workflows/test-go-task.ya?ml" - "Taskfile.yml" - "go.mod" - "go.sum" @@ -11,7 +11,7 @@ on: - "**/testdata/**" pull_request: paths: - - ".github/workflows/test.yml" + - ".github/workflows/test-go-task.ya?ml" - "Taskfile.yml" - "go.mod" - "go.sum" diff --git a/README.md b/README.md index d9b25dc3..a1380d75 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 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) From 5dc498b54d18db0abbdd62b3c362f67438bb9989 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 4 Aug 2021 17:06:10 -0700 Subject: [PATCH 05/19] Replace discouraged shell syntax in taskfile dynamic variable The backticks command substitution syntax is discouraged in favor of the modern `$()` syntax for the reasons described here: http://mywiki.wooledge.org/BashFAQ/082 The modern syntax is already in use for other dynamic variables in the taskfile, so this change also provides consistency. --- Taskfile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Taskfile.yml b/Taskfile.yml index 1920bcd5..63f5a9f0 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -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)" From 745aa441864f6f5284deac142b553219ad3f8630 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 4 Aug 2021 17:20:46 -0700 Subject: [PATCH 06/19] Use standardized name for build and test tasks This is the naming convention established in the standardized template project assets. --- .github/workflows/test-go-integration-task.yml | 2 +- .github/workflows/test-go-task.yml | 2 +- Taskfile.yml | 18 ++++++++++++------ docs/CONTRIBUTING.md | 10 +++++----- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test-go-integration-task.yml b/.github/workflows/test-go-integration-task.yml index 52dbdab7..4aa9a8c1 100644 --- a/.github/workflows/test-go-integration-task.yml +++ b/.github/workflows/test-go-integration-task.yml @@ -57,4 +57,4 @@ jobs: run: pip install poetry - name: Run integration tests - run: task test-integration + run: task go:test-integration diff --git a/.github/workflows/test-go-task.yml b/.github/workflows/test-go-task.yml index 0313788d..8c07e24b 100644 --- a/.github/workflows/test-go-task.yml +++ b/.github/workflows/test-go-task.yml @@ -48,7 +48,7 @@ jobs: version: 3.x - name: Run unit tests - run: task go:test-unit + run: task go:test - name: Send unit tests coverage to Codecov if: matrix.operating-system == 'ubuntu-latest' diff --git a/Taskfile.yml b/Taskfile.yml index 63f5a9f0..ee2727c3 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -41,14 +41,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 @@ -60,12 +66,12 @@ tasks: - go generate ./... - task: go:format - go:test-unit: + 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}} - test-integration: + go:test-integration: desc: Run integration tests cmds: - task: build diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 26821b8a..6ab5894f 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -118,26 +118,26 @@ task test To run only the Go unit tests, run: ``` -task go:test-unit +task go:test ``` By default, all tests for all Arduino Lint's Go packages are run. To run unit tests for only one or more specific packages, you can set the `TARGETS` environment variable, e.g.: ``` -TARGETS=./internal/rule task go:test-unit +TARGETS=./internal/rule task go:test ``` Alternatively, to run only some specific test(s), you can specify a regex to match against the test function name, e.g.: ``` -TEST_REGEX='^TestLibraryProperties.*' task go:test-unit +TEST_REGEX='^TestLibraryProperties.*' task go:test ``` Both can be combined as well, typically to run only a specific test: ``` -TEST_REGEX='^TestFindProjects$' TARGETS=./internal/project task go:test-unit +TEST_REGEX='^TestFindProjects$' TARGETS=./internal/project task go:test ``` #### Integration tests @@ -153,7 +153,7 @@ For these reasons, in addition to regular unit tests the project has a suite of After the software requirements have been installed, you should be able to run the tests with: ``` -task test-integration +task go:test-integration ``` This will automatically install the necessary dependencies, if not already installed, and run the integration tests From 35421ddee9c2da0519398ce23e4f5e9c70d3b1d8 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 4 Aug 2021 17:23:28 -0700 Subject: [PATCH 07/19] Use Python dependency installation task in integration test task A dedicated task has been added for installing the project's Python dependencies, and this should be used throughout the taskfile in place of redundant direct commands. --- Taskfile.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Taskfile.yml b/Taskfile.yml index ee2727c3..36ad4956 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -73,9 +73,10 @@ tasks: go:test-integration: desc: Run integration tests + deps: + - task: poetry:install-deps cmds: - task: build - - poetry install --no-root - poetry run pytest test check: From f9a245723662debd73df88b2741b821918a88e28 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 4 Aug 2021 17:24:29 -0700 Subject: [PATCH 08/19] Move build task to the `go:test-integration` task's `deps` key This allows the dependency tasks to run in parallel. --- Taskfile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Taskfile.yml b/Taskfile.yml index 36ad4956..5bafc0c1 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -74,9 +74,9 @@ tasks: go:test-integration: desc: Run integration tests deps: + - task: go:build - task: poetry:install-deps cmds: - - task: build - poetry run pytest test check: From e957cf54f09d38ebde91462af40a490423642255 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 4 Aug 2021 19:05:49 -0700 Subject: [PATCH 09/19] Use standardized name for integration test folder This is the naming convention established in the standardized template project assets. --- .github/workflows/test-go-integration-task.yml | 4 ++-- Taskfile.yml | 2 +- docs/CONTRIBUTING.md | 2 +- {test => tests}/__init__.py | 0 {test => tests}/pytest.ini | 0 {test => tests}/test_all.py | 0 .../ARDUINO_LINT_OFFICIAL/Arduino_Lib/library.properties | 0 .../ARDUINO_LINT_OFFICIAL/Arduino_Lib/src/Arduino_Lib.h | 0 {test => tests}/testdata/InvalidSketch/Invalid Sketch.ino | 0 {test => tests}/testdata/ValidSketch/LICENSE | 0 {test => tests}/testdata/ValidSketch/README.md | 0 {test => tests}/testdata/ValidSketch/ValidSketch.ino | 0 .../testdata/compliance/Invalid/Invalid Sketch.ino | 0 .../testdata/compliance/Permissive/MismatchedFilename.ino | 0 .../testdata/compliance/Specification/Specification.ino | 0 {test => tests}/testdata/compliance/Strict/LICENSE | 0 {test => tests}/testdata/compliance/Strict/README.md | 0 {test => tests}/testdata/compliance/Strict/Strict.ino | 0 .../ARDUINO_LINT_LIBRARY_MANAGER_INDEXING/Servo/Servo.h | 0 .../Servo/library.properties | 0 {test => tests}/testdata/library-manager/False/False.h | 0 {test => tests}/testdata/library-manager/Invalid/.gitkeep | 0 {test => tests}/testdata/library-manager/Submit/Submit.h | 0 .../testdata/library-manager/Submit/library.properties | 0 {test => tests}/testdata/library-manager/Update/Update.h | 0 .../testdata/library-manager/Update/library.properties | 0 {test => tests}/testdata/project-type/Library/Library.h | 0 .../testdata/project-type/Library/library.properties | 0 .../project-type/PackageIndex/package_valid_index.json | 0 {test => tests}/testdata/project-type/Platform/boards.txt | 0 {test => tests}/testdata/project-type/Sketch/Sketch.ino | 0 .../recursive/SpecificationSketch/SpecificationSketch.ino | 0 {test => tests}/testdata/verbose/HasWarnings/HasWarnings.ino | 0 33 files changed, 4 insertions(+), 4 deletions(-) rename {test => tests}/__init__.py (100%) rename {test => tests}/pytest.ini (100%) rename {test => tests}/test_all.py (100%) rename {test => tests}/testdata/ARDUINO_LINT_OFFICIAL/Arduino_Lib/library.properties (100%) rename {test => tests}/testdata/ARDUINO_LINT_OFFICIAL/Arduino_Lib/src/Arduino_Lib.h (100%) rename {test => tests}/testdata/InvalidSketch/Invalid Sketch.ino (100%) rename {test => tests}/testdata/ValidSketch/LICENSE (100%) rename {test => tests}/testdata/ValidSketch/README.md (100%) rename {test => tests}/testdata/ValidSketch/ValidSketch.ino (100%) rename {test => tests}/testdata/compliance/Invalid/Invalid Sketch.ino (100%) rename {test => tests}/testdata/compliance/Permissive/MismatchedFilename.ino (100%) rename {test => tests}/testdata/compliance/Specification/Specification.ino (100%) rename {test => tests}/testdata/compliance/Strict/LICENSE (100%) rename {test => tests}/testdata/compliance/Strict/README.md (100%) rename {test => tests}/testdata/compliance/Strict/Strict.ino (100%) rename {test => tests}/testdata/library-manager/ARDUINO_LINT_LIBRARY_MANAGER_INDEXING/Servo/Servo.h (100%) rename {test => tests}/testdata/library-manager/ARDUINO_LINT_LIBRARY_MANAGER_INDEXING/Servo/library.properties (100%) rename {test => tests}/testdata/library-manager/False/False.h (100%) rename {test => tests}/testdata/library-manager/Invalid/.gitkeep (100%) rename {test => tests}/testdata/library-manager/Submit/Submit.h (100%) rename {test => tests}/testdata/library-manager/Submit/library.properties (100%) rename {test => tests}/testdata/library-manager/Update/Update.h (100%) rename {test => tests}/testdata/library-manager/Update/library.properties (100%) rename {test => tests}/testdata/project-type/Library/Library.h (100%) rename {test => tests}/testdata/project-type/Library/library.properties (100%) rename {test => tests}/testdata/project-type/PackageIndex/package_valid_index.json (100%) rename {test => tests}/testdata/project-type/Platform/boards.txt (100%) rename {test => tests}/testdata/project-type/Sketch/Sketch.ino (100%) rename {test => tests}/testdata/recursive/SpecificationSketch/SpecificationSketch.ino (100%) rename {test => tests}/testdata/verbose/HasWarnings/HasWarnings.ino (100%) diff --git a/.github/workflows/test-go-integration-task.yml b/.github/workflows/test-go-integration-task.yml index 4aa9a8c1..7664a0f0 100644 --- a/.github/workflows/test-go-integration-task.yml +++ b/.github/workflows/test-go-integration-task.yml @@ -10,7 +10,7 @@ on: - "go.sum" - "poetry.lock" - "pyproject.toml" - - "test/**" + - "tests/**" pull_request: paths: - ".github/workflows/test-go-integration-task.ya?ml" @@ -20,7 +20,7 @@ on: - "go.sum" - "poetry.lock" - "pyproject.toml" - - "test/**" + - "tests/**" jobs: test-go: diff --git a/Taskfile.yml b/Taskfile.yml index 5bafc0c1..08e8ea31 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -77,7 +77,7 @@ tasks: - task: go:build - task: poetry:install-deps cmds: - - poetry run pytest test + - poetry run pytest tests check: desc: Lint and check formatting of all files diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 6ab5894f..de9065c6 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -162,7 +162,7 @@ automatically. To run specific tests, you must run `pytest` from the virtual environment created by Poetry. ``` -poetry run pytest test/test_all.py::test_report_file +poetry run pytest tests/test_all.py::test_report_file ``` You can avoid writing the `poetry run` prefix each time by creating a new shell inside the virtual environment: diff --git a/test/__init__.py b/tests/__init__.py similarity index 100% rename from test/__init__.py rename to tests/__init__.py diff --git a/test/pytest.ini b/tests/pytest.ini similarity index 100% rename from test/pytest.ini rename to tests/pytest.ini diff --git a/test/test_all.py b/tests/test_all.py similarity index 100% rename from test/test_all.py rename to tests/test_all.py diff --git a/test/testdata/ARDUINO_LINT_OFFICIAL/Arduino_Lib/library.properties b/tests/testdata/ARDUINO_LINT_OFFICIAL/Arduino_Lib/library.properties similarity index 100% rename from test/testdata/ARDUINO_LINT_OFFICIAL/Arduino_Lib/library.properties rename to tests/testdata/ARDUINO_LINT_OFFICIAL/Arduino_Lib/library.properties diff --git a/test/testdata/ARDUINO_LINT_OFFICIAL/Arduino_Lib/src/Arduino_Lib.h b/tests/testdata/ARDUINO_LINT_OFFICIAL/Arduino_Lib/src/Arduino_Lib.h similarity index 100% rename from test/testdata/ARDUINO_LINT_OFFICIAL/Arduino_Lib/src/Arduino_Lib.h rename to tests/testdata/ARDUINO_LINT_OFFICIAL/Arduino_Lib/src/Arduino_Lib.h diff --git a/test/testdata/InvalidSketch/Invalid Sketch.ino b/tests/testdata/InvalidSketch/Invalid Sketch.ino similarity index 100% rename from test/testdata/InvalidSketch/Invalid Sketch.ino rename to tests/testdata/InvalidSketch/Invalid Sketch.ino diff --git a/test/testdata/ValidSketch/LICENSE b/tests/testdata/ValidSketch/LICENSE similarity index 100% rename from test/testdata/ValidSketch/LICENSE rename to tests/testdata/ValidSketch/LICENSE diff --git a/test/testdata/ValidSketch/README.md b/tests/testdata/ValidSketch/README.md similarity index 100% rename from test/testdata/ValidSketch/README.md rename to tests/testdata/ValidSketch/README.md diff --git a/test/testdata/ValidSketch/ValidSketch.ino b/tests/testdata/ValidSketch/ValidSketch.ino similarity index 100% rename from test/testdata/ValidSketch/ValidSketch.ino rename to tests/testdata/ValidSketch/ValidSketch.ino diff --git a/test/testdata/compliance/Invalid/Invalid Sketch.ino b/tests/testdata/compliance/Invalid/Invalid Sketch.ino similarity index 100% rename from test/testdata/compliance/Invalid/Invalid Sketch.ino rename to tests/testdata/compliance/Invalid/Invalid Sketch.ino diff --git a/test/testdata/compliance/Permissive/MismatchedFilename.ino b/tests/testdata/compliance/Permissive/MismatchedFilename.ino similarity index 100% rename from test/testdata/compliance/Permissive/MismatchedFilename.ino rename to tests/testdata/compliance/Permissive/MismatchedFilename.ino diff --git a/test/testdata/compliance/Specification/Specification.ino b/tests/testdata/compliance/Specification/Specification.ino similarity index 100% rename from test/testdata/compliance/Specification/Specification.ino rename to tests/testdata/compliance/Specification/Specification.ino diff --git a/test/testdata/compliance/Strict/LICENSE b/tests/testdata/compliance/Strict/LICENSE similarity index 100% rename from test/testdata/compliance/Strict/LICENSE rename to tests/testdata/compliance/Strict/LICENSE diff --git a/test/testdata/compliance/Strict/README.md b/tests/testdata/compliance/Strict/README.md similarity index 100% rename from test/testdata/compliance/Strict/README.md rename to tests/testdata/compliance/Strict/README.md diff --git a/test/testdata/compliance/Strict/Strict.ino b/tests/testdata/compliance/Strict/Strict.ino similarity index 100% rename from test/testdata/compliance/Strict/Strict.ino rename to tests/testdata/compliance/Strict/Strict.ino diff --git a/test/testdata/library-manager/ARDUINO_LINT_LIBRARY_MANAGER_INDEXING/Servo/Servo.h b/tests/testdata/library-manager/ARDUINO_LINT_LIBRARY_MANAGER_INDEXING/Servo/Servo.h similarity index 100% rename from test/testdata/library-manager/ARDUINO_LINT_LIBRARY_MANAGER_INDEXING/Servo/Servo.h rename to tests/testdata/library-manager/ARDUINO_LINT_LIBRARY_MANAGER_INDEXING/Servo/Servo.h diff --git a/test/testdata/library-manager/ARDUINO_LINT_LIBRARY_MANAGER_INDEXING/Servo/library.properties b/tests/testdata/library-manager/ARDUINO_LINT_LIBRARY_MANAGER_INDEXING/Servo/library.properties similarity index 100% rename from test/testdata/library-manager/ARDUINO_LINT_LIBRARY_MANAGER_INDEXING/Servo/library.properties rename to tests/testdata/library-manager/ARDUINO_LINT_LIBRARY_MANAGER_INDEXING/Servo/library.properties diff --git a/test/testdata/library-manager/False/False.h b/tests/testdata/library-manager/False/False.h similarity index 100% rename from test/testdata/library-manager/False/False.h rename to tests/testdata/library-manager/False/False.h diff --git a/test/testdata/library-manager/Invalid/.gitkeep b/tests/testdata/library-manager/Invalid/.gitkeep similarity index 100% rename from test/testdata/library-manager/Invalid/.gitkeep rename to tests/testdata/library-manager/Invalid/.gitkeep diff --git a/test/testdata/library-manager/Submit/Submit.h b/tests/testdata/library-manager/Submit/Submit.h similarity index 100% rename from test/testdata/library-manager/Submit/Submit.h rename to tests/testdata/library-manager/Submit/Submit.h diff --git a/test/testdata/library-manager/Submit/library.properties b/tests/testdata/library-manager/Submit/library.properties similarity index 100% rename from test/testdata/library-manager/Submit/library.properties rename to tests/testdata/library-manager/Submit/library.properties diff --git a/test/testdata/library-manager/Update/Update.h b/tests/testdata/library-manager/Update/Update.h similarity index 100% rename from test/testdata/library-manager/Update/Update.h rename to tests/testdata/library-manager/Update/Update.h diff --git a/test/testdata/library-manager/Update/library.properties b/tests/testdata/library-manager/Update/library.properties similarity index 100% rename from test/testdata/library-manager/Update/library.properties rename to tests/testdata/library-manager/Update/library.properties diff --git a/test/testdata/project-type/Library/Library.h b/tests/testdata/project-type/Library/Library.h similarity index 100% rename from test/testdata/project-type/Library/Library.h rename to tests/testdata/project-type/Library/Library.h diff --git a/test/testdata/project-type/Library/library.properties b/tests/testdata/project-type/Library/library.properties similarity index 100% rename from test/testdata/project-type/Library/library.properties rename to tests/testdata/project-type/Library/library.properties diff --git a/test/testdata/project-type/PackageIndex/package_valid_index.json b/tests/testdata/project-type/PackageIndex/package_valid_index.json similarity index 100% rename from test/testdata/project-type/PackageIndex/package_valid_index.json rename to tests/testdata/project-type/PackageIndex/package_valid_index.json diff --git a/test/testdata/project-type/Platform/boards.txt b/tests/testdata/project-type/Platform/boards.txt similarity index 100% rename from test/testdata/project-type/Platform/boards.txt rename to tests/testdata/project-type/Platform/boards.txt diff --git a/test/testdata/project-type/Sketch/Sketch.ino b/tests/testdata/project-type/Sketch/Sketch.ino similarity index 100% rename from test/testdata/project-type/Sketch/Sketch.ino rename to tests/testdata/project-type/Sketch/Sketch.ino diff --git a/test/testdata/recursive/SpecificationSketch/SpecificationSketch.ino b/tests/testdata/recursive/SpecificationSketch/SpecificationSketch.ino similarity index 100% rename from test/testdata/recursive/SpecificationSketch/SpecificationSketch.ino rename to tests/testdata/recursive/SpecificationSketch/SpecificationSketch.ino diff --git a/test/testdata/verbose/HasWarnings/HasWarnings.ino b/tests/testdata/verbose/HasWarnings/HasWarnings.ino similarity index 100% rename from test/testdata/verbose/HasWarnings/HasWarnings.ino rename to tests/testdata/verbose/HasWarnings/HasWarnings.ino From 9c9f5b0e5fcaf7bd904205a17702820136a7f29b Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 4 Aug 2021 19:17:21 -0700 Subject: [PATCH 10/19] Remove project-specific references from integration test files These don't provide any value and make these assets more difficult to use as "templates" to be applied to any project. --- tests/__init__.py | 3 --- tests/test_all.py | 9 +++------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/__init__.py b/tests/__init__.py index 83a466af..1941a5d2 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,9 +1,6 @@ -# This file is part of Arduino Lint. -# # Copyright 2020 ARDUINO SA(http: // www.arduino.cc/) # # This software is released under the GNU General Public License version 3, -# which covers the main part of Arduino Lint. # The terms of this license can be found at: # https: // www.gnu.org/licenses/gpl-3.0.en.html # diff --git a/tests/test_all.py b/tests/test_all.py index 038572a1..ddee28d5 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -1,9 +1,6 @@ -# This file is part of Arduino Lint. -# # Copyright 2020 ARDUINO SA(http: // www.arduino.cc/) # # This software is released under the GNU General Public License version 3, -# which covers the main part of Arduino Lint. # The terms of this license can be found at: # https: // www.gnu.org/licenses/gpl-3.0.en.html # @@ -265,7 +262,7 @@ def run_command(pytestconfig, working_dir) -> typing.Callable[..., invoke.runner http://docs.pyinvoke.org/en/1.4/api/runners.html#invoke.runners.Result """ - arduino_lint_path = pathlib.Path(pytestconfig.rootdir).parent / "arduino-lint" + executable_path = pathlib.Path(pytestconfig.rootdir).parent / "arduino-lint" def _run( cmd: list, custom_working_dir: typing.Optional[str] = None, custom_env: typing.Optional[dict] = None @@ -277,7 +274,7 @@ def _run( quoted_cmd = [] for token in cmd: quoted_cmd.append(f'"{token}"') - cli_full_line = '"{}" {}'.format(arduino_lint_path, " ".join(quoted_cmd)) + cli_full_line = '"{}" {}'.format(executable_path, " ".join(quoted_cmd)) run_context = invoke.context.Context() # It might happen that we need to change directories between drives on Windows, # in that case the "/d" flag must be used otherwise directory wouldn't change @@ -300,5 +297,5 @@ def working_dir(tmpdir_factory) -> str: """Create a temporary folder for the test to run in. It will be created before running each test and deleted at the end. This way all the tests work in isolation. """ - work_dir = tmpdir_factory.mktemp(basename="ArduinoLintTestWork") yield str(work_dir) + work_dir = tmpdir_factory.mktemp(basename="IntegrationTestWorkingDir") From 3b7e6535659f1d5a58ef6c1fc28e654958c8a04e Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 4 Aug 2021 19:18:33 -0700 Subject: [PATCH 11/19] Improve formatting of integration test helper functions --- tests/test_all.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/test_all.py b/tests/test_all.py index ddee28d5..93975022 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -265,7 +265,9 @@ def run_command(pytestconfig, working_dir) -> typing.Callable[..., invoke.runner executable_path = pathlib.Path(pytestconfig.rootdir).parent / "arduino-lint" def _run( - cmd: list, custom_working_dir: typing.Optional[str] = None, custom_env: typing.Optional[dict] = None + cmd: list, + custom_working_dir: typing.Optional[str] = None, + custom_env: typing.Optional[dict] = None, ) -> invoke.runners.Result: if cmd is None: cmd = [] @@ -286,7 +288,12 @@ def _run( # wrapping the path in quotation marks is the safest approach with run_context.prefix(f'{cd_command} "{custom_working_dir}"'): return run_context.run( - command=cli_full_line, echo=False, hide=True, warn=True, env=custom_env, encoding="utf-8" + command=cli_full_line, + echo=False, + hide=True, + warn=True, + env=custom_env, + encoding="utf-8", ) return _run From bf9cb89f1e4821c64a60abd3f70d542e075a890d Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 4 Aug 2021 19:21:11 -0700 Subject: [PATCH 12/19] Make integration test work directory path canonical This avoids the use of Windows "short paths" (e.g., C:\\Users\\RUNNER~1\\AppData\\Local) which may cause spurious test results. --- tests/test_all.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_all.py b/tests/test_all.py index 93975022..ccc0249e 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -10,6 +10,7 @@ # Arduino software without disclosing the source code of your own applications. # To purchase a commercial license, send an email to license@arduino.cc. import json +import os import pathlib import platform import typing @@ -304,5 +305,5 @@ def working_dir(tmpdir_factory) -> str: """Create a temporary folder for the test to run in. It will be created before running each test and deleted at the end. This way all the tests work in isolation. """ - yield str(work_dir) work_dir = tmpdir_factory.mktemp(basename="IntegrationTestWorkingDir") + yield os.path.realpath(work_dir) From 59f08949836c8f031d14fb3a267d18923dc8e7a4 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 4 Aug 2021 19:23:39 -0700 Subject: [PATCH 13/19] Clean up integration test working directory --- tests/test_all.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_all.py b/tests/test_all.py index ccc0249e..91e0e84c 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -13,6 +13,7 @@ import os import pathlib import platform +import shutil import typing import dateutil.parser @@ -307,3 +308,4 @@ def working_dir(tmpdir_factory) -> str: """ work_dir = tmpdir_factory.mktemp(basename="IntegrationTestWorkingDir") yield os.path.realpath(work_dir) + shutil.rmtree(work_dir, ignore_errors=True) From db50dfd55a23f15d0946a80ec6772e4e6dbc889d Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 4 Aug 2021 19:31:49 -0700 Subject: [PATCH 14/19] Bump pytest integration testing dependency to ^6.2.4 --- poetry.lock | 15 +++++++-------- pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/poetry.lock b/poetry.lock index 39cec3e2..5eee6d3e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -400,24 +400,23 @@ python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" [[package]] name = "pytest" -version = "6.1.2" +version = "6.2.4" description = "pytest: simple powerful testing with Python" category = "main" optional = false -python-versions = ">=3.5" +python-versions = ">=3.6" [package.dependencies] atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""} -attrs = ">=17.4.0" +attrs = ">=19.2.0" colorama = {version = "*", markers = "sys_platform == \"win32\""} iniconfig = "*" packaging = "*" -pluggy = ">=0.12,<1.0" +pluggy = ">=0.12,<1.0.0a1" py = ">=1.8.2" toml = "*" [package.extras] -checkqa_mypy = ["mypy (==0.780)"] testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xmlschema"] [[package]] @@ -536,7 +535,7 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytes [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "64ddf6ae94dabf07642e06bb8b54784702b1349abf5c7b398f6c35b4fb2d40e9" +content-hash = "4c1794427de3b582f65e1abedb1894088d7ca5610ca3febb08dfea8e2012ad2e" [metadata.files] appdirs = [ @@ -715,8 +714,8 @@ pyparsing = [ {file = "pyparsing-2.4.7.tar.gz", hash = "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"}, ] pytest = [ - {file = "pytest-6.1.2-py3-none-any.whl", hash = "sha256:4288fed0d9153d9646bfcdf0c0428197dba1ecb27a33bb6e031d002fa88653fe"}, - {file = "pytest-6.1.2.tar.gz", hash = "sha256:c0a7e94a8cdbc5422a51ccdad8e6f1024795939cc89159a0ae7f0b316ad3823e"}, + {file = "pytest-6.2.4-py3-none-any.whl", hash = "sha256:91ef2131a9bd6be8f76f1f08eac5c5317221d6ad1e143ae03894b862e8976890"}, + {file = "pytest-6.2.4.tar.gz", hash = "sha256:50bcad0a0b9c5a72c8e4e7c9855a3ad496ca6a881a3641b4260605450772c54b"}, ] python-dateutil = [ {file = "python-dateutil-2.8.1.tar.gz", hash = "sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c"}, diff --git a/pyproject.toml b/pyproject.toml index afcbe124..eb9c990d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ python = "^3.9" # Integration tests dependencies. invoke = "1.4.1" -pytest = "6.1.2" +pytest = "^6.2.4" python-dateutil = "^2.8.1" semver = "^2.13.0" From 6015029357f2cb32418d92d6dc83d3601a6c9a9a Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 4 Aug 2021 19:33:13 -0700 Subject: [PATCH 15/19] Bump `invoke` integration test dependency to ^1.5.0 --- poetry.lock | 10 +++++----- pyproject.toml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/poetry.lock b/poetry.lock index 5eee6d3e..f9008c4c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -164,7 +164,7 @@ python-versions = "*" [[package]] name = "invoke" -version = "1.4.1" +version = "1.6.0" description = "Pythonic task execution" category = "main" optional = false @@ -535,7 +535,7 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytes [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "4c1794427de3b582f65e1abedb1894088d7ca5610ca3febb08dfea8e2012ad2e" +content-hash = "34a7bca079636d788474fddc713c22b14e6830c62f1f5a0e09187d9f841ff4f2" [metadata.files] appdirs = [ @@ -594,9 +594,9 @@ iniconfig = [ {file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"}, ] invoke = [ - {file = "invoke-1.4.1-py2-none-any.whl", hash = "sha256:93e12876d88130c8e0d7fd6618dd5387d6b36da55ad541481dfa5e001656f134"}, - {file = "invoke-1.4.1-py3-none-any.whl", hash = "sha256:87b3ef9d72a1667e104f89b159eaf8a514dbf2f3576885b2bbdefe74c3fb2132"}, - {file = "invoke-1.4.1.tar.gz", hash = "sha256:de3f23bfe669e3db1085789fd859eb8ca8e0c5d9c20811e2407fa042e8a5e15d"}, + {file = "invoke-1.6.0-py2-none-any.whl", hash = "sha256:e6c9917a1e3e73e7ea91fdf82d5f151ccfe85bf30cc65cdb892444c02dbb5f74"}, + {file = "invoke-1.6.0-py3-none-any.whl", hash = "sha256:769e90caeb1bd07d484821732f931f1ad8916a38e3f3e618644687fc09cb6317"}, + {file = "invoke-1.6.0.tar.gz", hash = "sha256:374d1e2ecf78981da94bfaf95366216aaec27c2d6a7b7d5818d92da55aa258d3"}, ] jinja2 = [ {file = "Jinja2-2.11.2-py2.py3-none-any.whl", hash = "sha256:f0a4641d3cf955324a89c04f3d94663aa4d638abe8f733ecd3582848e1c37035"}, diff --git a/pyproject.toml b/pyproject.toml index eb9c990d..881ea065 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ authors = ["Arduino "] python = "^3.9" # Integration tests dependencies. -invoke = "1.4.1" +invoke = "^1.5.0" pytest = "^6.2.4" python-dateutil = "^2.8.1" semver = "^2.13.0" From b338cfb19ed71af47c83846564e506d8a0380326 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 4 Aug 2021 19:38:52 -0700 Subject: [PATCH 16/19] Add linebreaks to `go test` command Long commands, especially in this case where taskfile templating is involved, can be difficult to read and interpret. Adding strategic line breaks makes the structure of the command easy to follow. --- Taskfile.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Taskfile.yml b/Taskfile.yml index 08e8ea31..67298571 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -69,7 +69,13 @@ tasks: 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 \ + -short \ + -run '{{default ".*" .TEST_REGEX}}' \ + {{default "-v" .GOFLAGS}} \ + -coverprofile=coverage_unit.txt \ + {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}} go:test-integration: desc: Run integration tests From 75ab8aaaf0c8c9334a74e41ab0969c8f34eec8f5 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 4 Aug 2021 19:46:57 -0700 Subject: [PATCH 17/19] Use more specific override variable name for unit test regex Task has the capability for a default template value to be specified, which may be overridden by an environment variable set by the task user. The previous variable name chosen for this purpose was somewhat ambiguous. --- Taskfile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Taskfile.yml b/Taskfile.yml index 67298571..54db0e90 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -72,8 +72,8 @@ tasks: - | go test \ -short \ - -run '{{default ".*" .TEST_REGEX}}' \ {{default "-v" .GOFLAGS}} \ + -run '{{default ".*" .GO_TEST_REGEX}}' \ -coverprofile=coverage_unit.txt \ {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}} From fd3587891475565e1dba1c5d3b0d88c2bf046d40 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 4 Aug 2021 19:51:12 -0700 Subject: [PATCH 18/19] Fix error in `go test` command template Task's `default` template command uses the first value if the second is not defined. In this case, the second value was a variable defined by the workflow, so it was always defined! This made the default command and the first value useless. My interpretation is that the intent was, as is done successfully elsewhere, to allow the task user to make customizations by defining an environment variable from the command line which will override the default value. In order to accomplish that in a clean manner, I made the following changes: - Remove the frivolous taskfile variable, instead adding the flags directly to the template - Hard code the `-v` flag into the command - Add an override variable with a more relevant name --- Taskfile.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 54db0e90..84339ba0 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -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" @@ -71,9 +70,10 @@ tasks: cmds: - | go test \ + -v \ -short \ - {{default "-v" .GOFLAGS}} \ -run '{{default ".*" .GO_TEST_REGEX}}' \ + {{default "-timeout 10m -coverpkg=./... -covermode=atomic" .GO_TEST_FLAGS}} \ -coverprofile=coverage_unit.txt \ {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}} From 3bc729c237a3f3aec2e0f16a6279bd345f1361aa Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 4 Aug 2021 20:01:24 -0700 Subject: [PATCH 19/19] Add source URL comments to testing assets This will make it easier for the maintainers to sync fixes and improvements in either direction between the upstream "template" assets and their installation in this repository. --- Taskfile.yml | 2 ++ tests/__init__.py | 2 ++ tests/pytest.ini | 1 + tests/test_all.py | 2 ++ 4 files changed, 7 insertions(+) diff --git a/Taskfile.yml b/Taskfile.yml index 84339ba0..a44e8c77 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -65,6 +65,7 @@ tasks: - go generate ./... - task: go:format + # 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: @@ -77,6 +78,7 @@ tasks: -coverprofile=coverage_unit.txt \ {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}} + # 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: diff --git a/tests/__init__.py b/tests/__init__.py index 1941a5d2..947ae6b4 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,3 +1,5 @@ +# Source: +# https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-python/__init__.py # Copyright 2020 ARDUINO SA(http: // www.arduino.cc/) # # This software is released under the GNU General Public License version 3, diff --git a/tests/pytest.ini b/tests/pytest.ini index d3f2009f..b8beed3f 100644 --- a/tests/pytest.ini +++ b/tests/pytest.ini @@ -1,3 +1,4 @@ +# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-python/pytest.ini [pytest] filterwarnings = error diff --git a/tests/test_all.py b/tests/test_all.py index 91e0e84c..1faa8135 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -1,3 +1,5 @@ +# Source: +# https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-integration/test_all.py # Copyright 2020 ARDUINO SA(http: // www.arduino.cc/) # # This software is released under the GNU General Public License version 3,