Unverified Commit 3e414555 authored by per1234's avatar per1234 Committed by GitHub

Sync testing infrastructure with "template" assets (#1388)

* [skip changelog] Sync testing infrastructure with "template" assets

We have assembled a collection of reusable project assets:
https://github.com/arduino/tooling-project-assets
These will be used in the repositories of all Arduino tooling projects.

Some minor improvements and standardizations have been made in the upstream "template" assets, and those are hereby
introduced to this repository.

Notable:

- Configure paths filters to avoid unnecessary workflow runs
- Increased parallelism
- Improved maintainability

* Remove obsolete testing tasks

The sync with the template testing assets has resulted in new standardized names for some of the test runner tasks:

- `test-unit` -> `go:test`
- `test-integration` -> `go:test-integration`

* [skip changelog] Update package names in imports

As of Go 1.7 the `golang.org/x/net/context` package is available in the standard library under the name `context`.

* [skip changelog] Tidy root module dependencies

Result of running `go mod tidy` with Go 1.16.6.

* [skip changelog] Tidy `github.com/arduino/arduino-cli/arduino/discovery/discovery_client` module's dependencies

Result of running `go mod tidy` with Go 1.16.6.

* [skip changelog] Tidy `github.com/arduino/arduino-cli/term_example` module's dependencies

Result of running `go mod tidy` with Go 1.16.6.

* [skip changelog] Tidy `github.com/arduino/arduino-cli/docsgen` module's dependencies

Result of running `go mod tidy` with Go 1.16.6.
parent 5bce623f
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-task.md
name: Check Go
env:
# See: https://github.com/actions/setup-go/tree/v2#readme
GO_VERSION: "1.16"
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/check-go-task.ya?ml"
- "Taskfile.ya?ml"
- "**/go.mod"
- "**/go.sum"
- "**.go"
pull_request:
paths:
- ".github/workflows/check-go-task.ya?ml"
- "Taskfile.ya?ml"
- "**/go.mod"
- "**/go.sum"
- "**.go"
workflow_dispatch:
repository_dispatch:
jobs:
check-errors:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Install Task
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- name: Check for errors
run: task go:vet
check-outdated:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Install Task
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- name: Modernize usages of outdated APIs
run: task go:fix
- name: Check if any fixes were needed
run: git diff --color --exit-code
check-style:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Install Task
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- name: Install golint
run: go install golang.org/x/lint/golint@latest
- name: Check style
run: task --silent go:lint
check-formatting:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Install Task
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- name: Format code
run: task go:format
- name: Check formatting
run: git diff --color --exit-code
check-config:
name: check-config (${{ matrix.module.path }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
module:
- path: ./
- path: arduino/discovery/discovery_client
- path: client_example
- path: commands/daemon/term_example
- path: docsgen
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Run go mod tidy
working-directory: ${{ matrix.module.path }}
run: go mod tidy
- name: Check whether any tidying was needed
run: git diff --color --exit-code
# Do a simple "smoke test" build for the modules with no other form of validation
build:
name: build (${{ matrix.module.path }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
module:
- path: arduino/discovery/discovery_client
- path: client_example
- path: commands/daemon/term_example
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Build
working-directory: ${{ matrix.module.path }}
run: go build
name: Check Internationalization
env:
# See: https://github.com/actions/setup-go/tree/v2#readme
GO_VERSION: "1.16"
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/check-i18n-task.ya?ml"
- "Taskfile.ya?ml"
- "go.mod"
- "go.sum"
- "**.go"
- "i18n/**"
pull_request:
paths:
- ".github/workflows/check-i18n-task.ya?ml"
- "Taskfile.ya?ml"
- "go.mod"
- "go.sum"
- "**.go"
- "i18n/**"
workflow_dispatch:
repository_dispatch:
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Install go.rice
run: go get github.com/cmaglie/go.rice/rice
- name: Install Task
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- name: Check for errors
run: task i18n:check
name: Check Protocol Buffers
env:
# See: https://github.com/actions/setup-go/tree/v2#readme
GO_VERSION: "1.16"
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/check-protobuf-task.ya?ml"
- "Taskfile.ya?ml"
- "rpc/**"
pull_request:
paths:
- ".github/workflows/check-protobuf-task.ya?ml"
- "Taskfile.ya?ml"
- "rpc/**"
workflow_dispatch:
repository_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Install protoc compiler
uses: arduino/setup-protoc@v1
with:
version: v3.16.0
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Go deps
run: |
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26.0
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1.0
- name: Install Task
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- name: Check protocol buffers compile correctly
if: runner.os == 'Linux'
run: task protoc:compile
check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Install buf (protoc linter)
run: |
go install github.com/bufbuild/buf/cmd/buf@latest
go install github.com/bufbuild/buf/cmd/protoc-gen-buf-breaking@latest
go install github.com/bufbuild/buf/cmd/protoc-gen-buf-lint@latest
- name: Install Task
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- name: Lint protocol buffers
run: task protoc:check
# 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"
- "DistTasks.ya?ml"
- "**.go"
pull_request:
paths:
- ".github/workflows/publish-go-tester-task.ya?ml"
- "go.mod"
- "go.sum"
- "Taskfile.ya?ml"
- "DistTasks.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 Task
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- name: Build
run: |
PACKAGE_NAME_PREFIX="test"
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 }}
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/test-go-integration-task.md
name: Test Integration
env:
# See: https://github.com/actions/setup-go/tree/v2#readme
GO_VERSION: "1.16"
# See: https://github.com/actions/setup-python/tree/v2#available-versions-of-python
PYTHON_VERSION: "3.9"
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
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/**"
workflow_dispatch:
repository_dispatch:
jobs:
test:
strategy:
matrix:
operating-system:
- ubuntu-latest
- windows-latest
- macos-latest
runs-on: ${{ matrix.operating-system }}
steps:
# By default, actions/checkout converts the repo's LF line endings to CRLF on the Windows runner.
- name: Disable EOL conversions
run: git config --global core.autocrlf false
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Poetry
run: pip install poetry
- name: Install Task
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- name: Run integration tests
run: task go:test-integration
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/test-go-task.md
name: Test Go
env:
# See: https://github.com/actions/setup-go/tree/v2#readme
GO_VERSION: "1.16"
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/test-go-task.ya?ml"
- "codecov.ya?ml"
- "go.mod"
- "go.sum"
- "Taskfile.ya?ml"
- "**.go"
- "**/testdata/**"
pull_request:
paths:
- ".github/workflows/test-go-task.ya?ml"
- "codecov.ya?ml"
- "go.mod"
- "go.sum"
- "Taskfile.ya?ml"
- "**.go"
- "**/testdata/**"
workflow_dispatch:
repository_dispatch:
jobs:
test:
strategy:
matrix:
operating-system:
- ubuntu-latest
- windows-latest
- macos-latest
runs-on: ${{ matrix.operating-system }}
steps:
# By default, actions/checkout converts the repo's LF line endings to CRLF on the Windows runner.
- name: Disable EOL conversions
run: git config --global core.autocrlf false
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Install Task
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- name: Run tests
run: task go:test
- name: Run unit tests on the legacy package
# Run legacy tests on one platform only
if: runner.os == 'Linux'
run: task test-legacy
- name: Send unit tests coverage to Codecov
if: >
runner.os == 'Linux' &&
github.event_name == 'push'
uses: codecov/codecov-action@v2
with:
file: ./coverage_unit.txt
flags: unit
fail_ci_if_error: true
- name: Send legacy tests coverage to Codecov
if: >
runner.os == 'Linux' &&
github.event_name == 'push'
uses: codecov/codecov-action@v2.0.2
with:
file: ./coverage_legacy.txt
flags: unit
name: test
on:
push:
pull_request:
jobs:
test-matrix:
strategy:
matrix:
operating-system: [ubuntu-20.04, windows-latest, macOS-latest]
runs-on: ${{ matrix.operating-system }}
steps:
- name: Disable EOL conversions
run: git config --global core.autocrlf false
- name: Checkout
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "1.16"
- name: Install Go deps
# Since 10/23/2019 pwsh is the default shell
# on Windows, but pwsh fails to install protoc-gen-go so
# we force bash as default shell for all OSes in this task
run: |
go get github.com/golangci/govet
go get golang.org/x/lint/golint
go get github.com/golang/protobuf/protoc-gen-go
go get github.com/cmaglie/go.rice/rice
go get google.golang.org/grpc/cmd/protoc-gen-go-grpc
shell: bash
- 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.2.2
with:
python-version: "3.8"
architecture: "x64"
- name: Install Poetry
run: pip install poetry
- name: Install buf (protoc linter)
if: runner.os == 'Linux'
run: |
go install github.com/bufbuild/buf/cmd/buf@latest
go install github.com/bufbuild/buf/cmd/protoc-gen-buf-breaking@latest
go install github.com/bufbuild/buf/cmd/protoc-gen-buf-lint@latest
shell: bash
- name: Check the code is good
if: runner.os == 'Linux'
run: task check
- name: Install protoc compiler
if: runner.os == 'Linux'
uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Check protocol buffers compile correctly
if: runner.os == 'Linux'
run: task protoc:compile
- name: Build the CLI
run: task build
- name: Run unit tests
run: task test-unit
- name: Run unit tests on the legacy package
# Run legacy tests on one platform only
if: matrix.operating-system == 'ubuntu-20.04'
run: task test-legacy
- name: Run integration tests
run: task test-integration
- name: Send unit tests coverage to Codecov
if: >
matrix.operating-system == 'ubuntu-20.04' &&
github.event_name == 'push'
uses: codecov/codecov-action@v2.0.2
with:
file: ./coverage_unit.txt
flags: unit
- name: Send legacy tests coverage to Codecov
if: >
matrix.operating-system == 'ubuntu-20.04' &&
github.event_name == 'push'
uses: codecov/codecov-action@v2.0.2
with:
file: ./coverage_legacy.txt
flags: unit
- name: Send integration tests coverage to Codecov
if: >
matrix.operating-system == 'ubuntu-20.04' &&
github.event_name == 'push'
uses: codecov/codecov-action@v2.0.2
with:
file: ./coverage_integ.txt
flags: integ
create-test-artifacts:
runs-on: ubuntu-20.04
needs: test-matrix
steps:
- name: checkout
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
# Uploads all architectures as separate artifacts
- name: Upload Linux 32 bit artifact
uses: actions/upload-artifact@v2
with:
name: Linux_32bit
path: dist/*Linux_32bit.tar.gz
- name: Upload Linux 64 bit artifact
uses: actions/upload-artifact@v2
with:
name: Linux_64bit
path: dist/*Linux_64bit.tar.gz
- name: Upload Windows 32 bit artifact
uses: actions/upload-artifact@v2
with:
name: Windows_32bit
path: dist/*Windows_32bit.zip
- name: Upload Windows 64 bit artifact
uses: actions/upload-artifact@v2
with:
name: Windows_64bit
path: dist/*Windows_64bit.zip
- name: Upload Linux ARMv6 artifact
uses: actions/upload-artifact@v2
with:
name: Linux_ARMv6
path: dist/*Linux_ARMv6.tar.gz
- name: Upload Linux ARMv7 artifact
uses: actions/upload-artifact@v2
with:
name: Linux_ARMv7
path: dist/*Linux_ARMv7.tar.gz
- name: Upload Linux ARM64 artifact
uses: actions/upload-artifact@v2
with:
name: Linux_ARM64
path: dist/*Linux_ARM64.tar.gz
- name: Upload MacOS 64 bit artifact
uses: actions/upload-artifact@v2
with:
name: macOS_64bit
path: dist/*macOS_64bit.tar.gz
- name: Upload checksums
uses: actions/upload-artifact@v2
with:
name: checksums
path: dist/*checksums.txt
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/release-go-task/DistTasks.yml
version: "3"
# This taskfile is ideally meant to be project agnostic and could be dropped in
......
......@@ -5,10 +5,11 @@
Arduino CLI is an all-in-one solution that provides Boards/Library Managers, sketch builder, board detection, uploader,
and many other tools needed to use any Arduino compatible board and platform.
[![tests-badge]](https://github.com/Arduino/arduino-cli/actions?workflow=test)
[![Test Go status](https://github.com/arduino/arduino-cli/actions/workflows/test-go-task.yml/badge.svg)](https://github.com/arduino/arduino-cli/actions/workflows/test-go-task.yml)
[![Test Integration status](https://github.com/arduino/arduino-cli/actions/workflows/test-go-integration-task.yml/badge.svg)](https://github.com/arduino/arduino-cli/actions/workflows/test-go-integration-task.yml)
[![nightly-badge]](https://github.com/Arduino/arduino-cli/actions?workflow=nightly)
[![Deploy Website status](https://github.com/arduino/arduino-cli/actions/workflows/deploy-cobra-mkdocs-versioned-poetry.yml/badge.svg)](https://github.com/arduino/arduino-cli/actions/workflows/deploy-cobra-mkdocs-versioned-poetry.yml)
[![codecov-badge]](https://codecov.io/gh/arduino/arduino-cli)
[![Codecov](https://codecov.io/gh/arduino/arduino-cli/branch/main/graph/badge.svg)](https://codecov.io/gh/arduino/arduino-cli)
> **Note:** this software is currently under active development: anything can change at any time, API and UI must be
> considered unstable until we release version 1.0.0.
......
......@@ -26,6 +26,12 @@ tasks:
cmds:
- npx prettier --write .
# 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}}
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/deploy-cobra-mkdocs-versioned-poetry/Taskfile.yml
go:cli-docs:
desc: Generate command line interface reference documentation
......@@ -36,6 +42,61 @@ tasks:
# The binary is invoked like this instead of `./{{.PROJECT_NAME}}` to remove the `./` chars from the examples
- PATH=. {{.PROJECT_NAME}} ../docs/commands
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
go:fix:
desc: Modernize usages of outdated APIs
cmds:
- go fix {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
go:format:
desc: Format Go code
cmds:
- go fmt {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
go:lint:
desc: Lint Go code
cmds:
- |
if ! which golint &>/dev/null; then
echo "golint not installed or not in PATH. Please install: https://github.com/golang/lint#installation"
exit 1
fi
- |
golint \
{{default "-min_confidence 0.8 -set_exit_status" .GO_LINT_FLAGS}} \
{{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
# 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 \
-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_LDFLAGS}}
# 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:
- poetry run pytest test
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
go:vet:
desc: Check for errors in Go code
cmds:
- go vet {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
markdown:check-links:
desc: Check for broken links
......@@ -132,25 +193,14 @@ tasks:
build:
desc: Build the project
cmds:
- go build -v {{.LDFLAGS}}
deps:
- task: go:build
test:
desc: Run the full testsuite, `legacy` will be skipped
cmds:
- task: test-unit
- task: test-integration
test-unit:
desc: Run unit tests only
cmds:
- go test -short -run '{{ default ".*" .TEST_REGEX }}' {{ default "-v" .GOFLAGS }} -coverprofile=coverage_unit.txt {{ default .DEFAULT_TARGETS .TARGETS }} {{.TEST_LDFLAGS}}
test-integration:
desc: Run integration tests only
cmds:
- poetry install --no-root
- poetry run pytest test
- task: go:test
- task: go:test-integration
test-legacy:
desc: Run tests for the `legacy` package
......@@ -160,14 +210,13 @@ tasks:
test-unit-race:
desc: Run unit tests only with race condition detection
cmds:
- go test -short -race {{ default "-v" .GOFLAGS }} -coverprofile=coverage_race_unit.txt {{ default .DEFAULT_TARGETS .TARGETS }}
- go test -short -race {{ default "-v" .GOFLAGS }} -coverprofile=coverage_race_unit.txt {{ default .DEFAULT_GO_PACKAGES .TARGETS }}
check:
desc: Check fmt and lint, `legacy` will be skipped
cmds:
- test -z $(go fmt {{ default .DEFAULT_TARGETS .TARGETS }})
- go vet {{ default .DEFAULT_TARGETS .TARGETS }}
- "'{{.GOLINTBIN}}' {{.GOLINTFLAGS}} {{ default .DEFAULT_TARGETS .TARGETS }}"
- task: go:vet
- task: go:lint
- task: i18n:check
- task: python:check
- task: protoc:check
......@@ -247,8 +296,8 @@ vars:
PROJECT_NAME: "arduino-cli"
DIST_DIR: "dist"
# all modules of this project except for "legacy/..." module
DEFAULT_TARGETS:
sh: echo `go list ./... | grep -v legacy | tr '\n' ' '`
DEFAULT_GO_PACKAGES:
sh: echo $(go list ./... | grep -v legacy | tr '\n' ' ')
# build vars
COMMIT:
sh: echo "$(git log --no-show-signature -n 1 --format=%h)"
......@@ -257,27 +306,24 @@ vars:
TIMESTAMP_SHORT:
sh: echo "{{now | date "20060102"}}"
TAG:
sh: echo "`git tag --points-at=HEAD 2> /dev/null | head -n1`"
VERSION: "{{ if .NIGHTLY }}nightly-{{ .TIMESTAMP_SHORT }}{{ else if .TAG }}{{ .TAG }}{{ else }}{{ .PACKAGE_NAME_PREFIX }}git-snapshot{{ end }}"
LDFLAGS: >
sh: echo "$(git tag --points-at=HEAD 2> /dev/null | head -n1)"
VERSION: "{{if .NIGHTLY}}nightly-{{.TIMESTAMP_SHORT}}{{else if .TAG}}{{.TAG}}{{else}}{{.PACKAGE_NAME_PREFIX}}git-snapshot{{end}}"
CONFIGURATION_PACKAGE: "github.com/arduino/arduino-cli/version"
LDFLAGS: >-
-ldflags
'
-X github.com/arduino/arduino-cli/version.versionString={{.VERSION}}
-X github.com/arduino/arduino-cli/version.commit={{ .COMMIT }}
-X github.com/arduino/arduino-cli/version.date={{.TIMESTAMP}}
-X {{.CONFIGURATION_PACKAGE}}.versionString={{.VERSION}}
-X {{.CONFIGURATION_PACKAGE}}.commit={{.COMMIT}}
-X {{.CONFIGURATION_PACKAGE}}.date={{.TIMESTAMP}}
'
# test vars
GOFLAGS: "-timeout 10m -v -coverpkg=./... -covermode=atomic"
TEST_VERSION: "0.0.0-test.preview"
TEST_COMMIT: "deadbeef"
TEST_LDFLAGS: >
TEST_LDFLAGS: >-
-ldflags
'
-X github.com/arduino/arduino-cli/version.versionString={{.TEST_VERSION}}
-X github.com/arduino/arduino-cli/version.commit={{.TEST_COMMIT}}
-X github.com/arduino/arduino-cli/version.date={{.TIMESTAMP}}
-X {{.CONFIGURATION_PACKAGE}}.versionString={{.TEST_VERSION}}
-X {{.CONFIGURATION_PACKAGE}}.commit={{.TEST_COMMIT}}
-X {{.CONFIGURATION_PACKAGE}}.date={{.TIMESTAMP}}
'
# check-lint vars
GOLINTBIN:
sh: go list -f {{"{{"}}".Target{{"}}"}}" golang.org/x/lint/golint
GOLINTFLAGS: "-min_confidence 0.8 -set_exit_status"
......@@ -10,10 +10,8 @@ github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYU
github.com/arduino/board-discovery v0.0.0-20180823133458-1ba29327fb0c/go.mod h1:HK7SpkEax/3P+0w78iRQx1sz1vCDYYw9RXwHjQTB5i8=
github.com/arduino/go-paths-helper v1.0.1/go.mod h1:HpxtKph+g238EJHq4geEPv9p+gl3v5YYu35Yb+w31Ck=
github.com/arduino/go-paths-helper v1.2.0/go.mod h1:HpxtKph+g238EJHq4geEPv9p+gl3v5YYu35Yb+w31Ck=
github.com/arduino/go-paths-helper v1.6.0 h1:S7/d7DqB9XlnvF9KrgSiGmo2oWKmYW6O/DTjj3Bijx4=
github.com/arduino/go-paths-helper v1.6.0/go.mod h1:V82BWgAAp4IbmlybxQdk9Bpkz8M4Qyx+RAFKaG9NuvU=
github.com/arduino/go-properties-orderedmap v1.3.0 h1:4No/vQopB36e7WUIk6H6TxiSEJPiMrVOCZylYmua39o=
github.com/arduino/go-properties-orderedmap v1.3.0/go.mod h1:DKjD2VXY/NZmlingh4lSFMEYCVubfeArCsGPGDwb2yk=
github.com/arduino/go-paths-helper v1.6.1 h1:lha+/BuuBsx0qTZ3gy6IO1kU23lObWdQ/UItkzVWQ+0=
github.com/arduino/go-paths-helper v1.6.1/go.mod h1:V82BWgAAp4IbmlybxQdk9Bpkz8M4Qyx+RAFKaG9NuvU=
github.com/arduino/go-properties-orderedmap v1.5.0 h1:istmr13qQN3nneuU3lsqlMvI6jqB3u8QUfVU1tX/t/8=
github.com/arduino/go-properties-orderedmap v1.5.0/go.mod h1:DKjD2VXY/NZmlingh4lSFMEYCVubfeArCsGPGDwb2yk=
github.com/arduino/go-timeutils v0.0.0-20171220113728-d1dd9e313b1b/go.mod h1:uwGy5PpN4lqW97FiLnbcx+xx8jly5YuPMJWfVwwjJiQ=
......@@ -25,6 +23,7 @@ github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+Ce
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cmaglie/go.rice v1.0.3 h1:ZBLmBdQp6ejc+n8eMNH0uuRSKkg6kKe6ORjXKnyHBYw=
github.com/cmaglie/go.rice v1.0.3/go.mod h1:AF3bOWkvdOpp8/S3UL8qbQ4N7DiISIbJtj54GWFPAsc=
github.com/cmaglie/pb v1.0.27/go.mod h1:GilkKZMXYjBA4NxItWFfO+lwkp59PLHQ+IOW/b/kmZI=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
......@@ -39,6 +38,7 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsr
github.com/creack/goselect v0.1.1/go.mod h1:a/NhLweNvqIYMuxcMOuWY516Cimucms3DglDzQP3hKY=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/daaku/go.zipexe v1.0.0 h1:VSOgZtH418pH9L16hC/JrgSNJbbAL26pj7lmD1+CGdY=
github.com/daaku/go.zipexe v1.0.0/go.mod h1:z8IiR6TsVLEYKwXAoE/I+8ys/sDkgTzSL0CLnGVd57E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
......@@ -124,6 +124,7 @@ github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leonelquinteros/gotext v1.4.0 h1:2NHPCto5IoMXbrT0bldPrxj0qM5asOCwtb1aUQZ1tys=
github.com/leonelquinteros/gotext v1.4.0/go.mod h1:yZGXREmoGTtBvZHNcc+Yfug49G/2spuF/i/Qlsvz1Us=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
......@@ -137,7 +138,7 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5
github.com/mdlayher/genetlink v0.0.0-20190313224034-60417448a851/go.mod h1:EsbsAEUEs15qC1cosAwxgCWV0Qhd8TmkxnA9Kw1Vhl4=
github.com/mdlayher/netlink v0.0.0-20190313131330-258ea9dff42c/go.mod h1:eQB3mZE4aiYnlUsyGGCOpPETfdQq4Jhsgf1fk3cwQaA=
github.com/mdlayher/taskstats v0.0.0-20190313225729-7cbba52ee072/go.mod h1:sGdS7A6CAETR53zkdjGkgoFlh1vSm7MtX+i8XfEsTMA=
github.com/miekg/dns v1.0.5/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM=
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
......@@ -247,6 +248,7 @@ golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
......@@ -255,6 +257,7 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
......@@ -270,6 +273,7 @@ golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
......
......@@ -16,6 +16,7 @@
package lib
import (
"context"
"fmt"
"os"
"sort"
......@@ -30,7 +31,6 @@ import (
"github.com/fatih/color"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"golang.org/x/net/context"
)
func initExamplesCommand() *cobra.Command {
......
......@@ -16,6 +16,7 @@
package lib
import (
"context"
"fmt"
"os"
"sort"
......@@ -29,7 +30,6 @@ import (
"github.com/arduino/arduino-cli/table"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"golang.org/x/net/context"
)
func initListCommand() *cobra.Command {
......
......@@ -6,6 +6,6 @@ replace github.com/arduino/arduino-cli => ../../..
require (
github.com/arduino/arduino-cli v0.0.0-20200109150215-ffa84fdaab21
google.golang.org/grpc v1.27.0
google.golang.org/protobuf v1.25.0
google.golang.org/grpc v1.37.0
google.golang.org/protobuf v1.26.0
)
This diff is collapsed.
......@@ -109,13 +109,13 @@ task check
To run unit tests:
```shell
task test-unit
task go:test
```
To run integration tests (these will take some time and require special setup, see following paragraph):
```shell
task test-integration
task go:test-integration
```
#### Running only some tests
......@@ -124,19 +124,19 @@ By default, all tests from all go packages are run. To run only unit tests from
set the TARGETS environment variable, e.g.:
```
TARGETS=./arduino/cores/packagemanager task test-unit
TARGETS=./arduino/cores/packagemanager task go:test
```
Alternatively, to run only some specific test(s), you can specify a regex to match against the test function name:
```
TEST_REGEX='^TestTryBuild.*' task test-unit
TEST_REGEX='^TestTryBuild.*' task go:test
```
Both can be combined as well, typically to run only a specific test:
```
TEST_REGEX='^TestFindBoardWithFQBN$' TARGETS=./arduino/cores/packagemanager task test-unit
TEST_REGEX='^TestFindBoardWithFQBN$' TARGETS=./arduino/cores/packagemanager task go:test
```
### Integration tests
......@@ -181,7 +181,7 @@ For more installation options read the [official documentation][poetry-docs].
After the software requirements have been installed you should be able to run the tests with:
```shell
task test-integration
task go:test-integration
```
This will automatically install the necessary dependencies, if not already installed, and run the integration tests
......
......@@ -70,7 +70,6 @@ github.com/fluxio/iohelpers v0.0.0-20160419043813-3a4dd67a94d2 h1:C6sOwknxwWfLBE
github.com/fluxio/iohelpers v0.0.0-20160419043813-3a4dd67a94d2/go.mod h1:c7sGIpDbBo0JZZ1tKyC1p5smWf8QcUjK4bFtZjHAecg=
github.com/fluxio/multierror v0.0.0-20160419044231-9c68d39025e5 h1:R8jFW6G/bjoXjWPFrEfw9G5YQDlYhwV4AC+Eonu6wmk=
github.com/fluxio/multierror v0.0.0-20160419044231-9c68d39025e5/go.mod h1:BEUDl7FG1cc76sM0J0x8dqr6RhiL4uqvk6oFkwuNyuM=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
......
......@@ -43,7 +43,7 @@ require (
go.bug.st/serial v1.1.2
go.bug.st/serial.v1 v0.0.0-20180827123349-5f7892a7bb45 // indirect
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125 // indirect
golang.org/x/sys v0.0.0-20210503173754-0981d6026fa6 // indirect
golang.org/x/text v0.3.6
google.golang.org/genproto v0.0.0-20210504143626-3b2ad6ccc450
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment