Skip to content
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
50 changes: 50 additions & 0 deletions .github/workflows/check-go-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,16 @@ on:

jobs:
check-errors:
name: check-errors (${{ matrix.module.path }})
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
module:
- path: .github/workflows/assets/validate-registry/

steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand All @@ -44,11 +52,21 @@ jobs:
version: 3.x

- name: Check for errors
env:
GO_MODULE_PATH: ${{ matrix.module.path }}
run: task go:vet

check-outdated:
name: check-outdated (${{ matrix.module.path }})
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
module:
- path: .github/workflows/assets/validate-registry/

steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand All @@ -65,14 +83,24 @@ jobs:
version: 3.x

- name: Modernize usages of outdated APIs
env:
GO_MODULE_PATH: ${{ matrix.module.path }}
run: task go:fix

- name: Check if any fixes were needed
run: git diff --color --exit-code

check-style:
name: check-style (${{ matrix.module.path }})
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
module:
- path: .github/workflows/assets/validate-registry/

steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand All @@ -92,11 +120,21 @@ jobs:
run: go install golang.org/x/lint/golint@latest

- name: Check style
env:
GO_MODULE_PATH: ${{ matrix.module.path }}
run: task --silent go:lint

check-formatting:
name: check-formatting (${{ matrix.module.path }})
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
module:
- path: .github/workflows/assets/validate-registry/

steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand All @@ -113,14 +151,24 @@ jobs:
version: 3.x

- name: Format code
env:
GO_MODULE_PATH: ${{ matrix.module.path }}
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: .github/workflows/assets/validate-registry/

steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand All @@ -137,6 +185,8 @@ jobs:
version: 3.x

- name: Run go mod tidy
env:
GO_MODULE_PATH: ${{ matrix.module.path }}
run: task go:tidy

- name: Check whether any tidying was needed
Expand Down
22 changes: 11 additions & 11 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
version: "3"

vars:
GO_PROJECT_PATH: .github/workflows/assets/validate-registry
LDFLAGS:
DEFAULT_GO_MODULE_PATH: .github/workflows/assets/validate-registry/
DEFAULT_GO_PACKAGES:
sh: cd "{{.GO_PROJECT_PATH}}" && echo $(go list ./... | tr '\n' ' ')
sh: |
echo $(cd {{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}} && go list ./... | tr '\n' ' ' || echo '"ERROR: Unable to discover Go packages"')

tasks:
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-workflows-task/Taskfile.yml
Expand Down Expand Up @@ -54,36 +55,35 @@ tasks:
# 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: "{{.GO_PROJECT_PATH}}"
dir: "{{.DEFAULT_GO_MODULE_PATH}}"
cmds:
- go build -v {{.LDFLAGS}}

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
go:check:
desc: Check for problems with Go code
dir: "{{.GO_PROJECT_PATH}}"
deps:
- task: go:vet
- task: go:lint

# 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
dir: "{{.GO_PROJECT_PATH}}"
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
cmds:
- go vet {{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:fix:
desc: Modernize usages of outdated APIs
dir: "{{.GO_PROJECT_PATH}}"
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
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:lint:
desc: Lint Go code
dir: "{{.GO_PROJECT_PATH}}"
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
cmds:
- |
if ! which golint &>/dev/null; then
Expand All @@ -98,20 +98,20 @@ tasks:
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
go:format:
desc: Format Go code
dir: "{{.GO_PROJECT_PATH}}"
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
cmds:
- go fmt {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}

go:tidy:
desc: Run go mod tidy
dir: "{{.GO_PROJECT_PATH}}"
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
cmds:
- go mod tidy

# 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
dir: "{{.GO_PROJECT_PATH}}"
dir: "{{.DEFAULT_GO_MODULE_PATH}}"
deps:
- task: go:build
- task: poetry:install-deps
Expand Down Expand Up @@ -152,7 +152,7 @@ tasks:
- task: go:build
cmds:
- |
"{{.GO_PROJECT_PATH}}/validate-registry" registry.txt
"{{.DEFAULT_GO_MODULE_PATH}}/validate-registry" registry.txt

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-yaml-task/Taskfile.yml
yaml:lint:
Expand Down