Skip to content

Sync testing assets with templates #106

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 1 commit into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
name: Run tests
name: Check Cross Build

env:
# See: https://github.com/actions/setup-go/tree/v2#readme
GO_VERSION: "1.15"

# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
on:
push:
branches:
- main
paths:
- ".github/workflows/check-go-cross-build-task.ya?ml"
- "go.mod"
- "go.sum"
- "Taskfile.ya?ml"
- "**.go"
pull_request:
paths:
- ".github/workflows/check-go-cross-build-task.ya?ml"
- "go.mod"
- "go.sum"
- "Taskfile.ya?ml"
- "**.go"
workflow_dispatch:
repository_dispatch:

jobs:
native-os-build:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
os:
- ubuntu-latest
- windows-latest
- macos-latest

runs-on: ${{ matrix.os }}

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.15"
go-version: ${{ env.GO_VERSION }}

- name: Install Taskfile
uses: arduino/setup-task@v1
Expand All @@ -33,7 +50,6 @@ jobs:
version: 3.x

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

- name: Cross-build for 386
Expand All @@ -47,14 +63,3 @@ jobs:
env:
GOARCH: "arm"
run: task build

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

- name: Install Poetry
run: pip install poetry

- name: Run unit and integration tests
run: task test
74 changes: 74 additions & 0 deletions .github/workflows/test-go-integration-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# 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.15"
# 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"
- "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/**"
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
79 changes: 79 additions & 0 deletions .github/workflows/test-go-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# 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.15"

# 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:
name: test (${{ matrix.module.path }} - ${{ matrix.operating-system }})

strategy:
fail-fast: false

matrix:
operating-system:
- ubuntu-latest
- windows-latest
- macos-latest
module:
- path: ./
codecov-flags: unit

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
env:
GO_MODULE_PATH: ${{ matrix.module.path }}
run: task go:test

- name: Send unit tests coverage to Codecov
if: runner.os == 'Linux'
uses: codecov/codecov-action@v2
with:
file: ${{ matrix.module.path }}coverage_unit.txt
flags: ${{ matrix.module.codecov-flags }}
fail_ci_if_error: ${{ github.repository == 'arduino/arduino-fwuploader' }}
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
The Arduino Firmware Uploader is a tool made to update the firmware and/or add SSL certificates for any Arduino board
equipped with WINC or NINA Wi-Fi module.

[![tests-badge]](https://github.com/arduino/arduino-fwuploader/actions/workflows/test.yaml)
[![Test Go status](https://github.com/arduino/arduino-fwuploader/actions/workflows/test-go-task.yml/badge.svg)](https://github.com/arduino/arduino-fwuploader/actions/workflows/test-go-task.yml)
[![Codecov](https://codecov.io/gh/arduino/arduino-fwuploader/branch/main/graph/badge.svg)](https://codecov.io/gh/arduino/arduino-fwuploader)
[![Test Integration status](https://github.com/arduino/arduino-fwuploader/actions/workflows/test-go-integration-task.yml/badge.svg)](https://github.com/arduino/arduino-fwuploader/actions/workflows/test-go-integration-task.yml)
[![Deploy Website status](https://github.com/arduino/arduino-fwuploader/actions/workflows/deploy-cobra-mkdocs-versioned-poetry.yml/badge.svg)](https://github.com/arduino/arduino-fwuploader/actions/workflows/deploy-cobra-mkdocs-versioned-poetry.yml)

## ❗❗❗Notice regarding versions before 2.0.0 ❗❗❗
Expand All @@ -28,7 +30,6 @@ and report the bug to our Security Team 🛡️ Thank you!

e-mail contact: [email protected]

[tests-badge]: https://github.com/arduino/arduino-fwuploader/actions/workflows/test.yaml/badge.svg
[security policy]: https://github.com/arduino/arduino-fwuploader/security/policy
[user documentation]: https://arduino.github.io/arduino-fwuploader/
[install]: https://arduino.github.io/arduino-fwuploader/latest/installation
Expand Down
37 changes: 28 additions & 9 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,27 +131,47 @@ tasks:
cmds:
- npx markdownlint-cli "**/*.md"

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

build:
desc: Build the project
deps:
- task: go:build

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

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
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
cmds:
- go test -short -race -run '.*' {{ default "-v" .GOFLAGS }} -coverprofile=coverage_unit.txt ./... {{.TEST_LDFLAGS}}
- |
go test \
-v \
-short \
-race \
-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}}

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
cmds:
- task: build
deps:
- task: go:build
- task: poetry:install-deps
cmds:
- poetry run pytest test

check:
Expand Down Expand Up @@ -235,7 +255,6 @@ vars:
-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: >
Expand Down
Loading