8000 Publish generated list of rules on documentation website by per1234 · Pull Request #261 · arduino/arduino-lint · GitHub
[go: up one dir, main page]

Skip to content

Publish generated list of rules on documentation website #261

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 12 commits into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add multi-module support to project infrastructure
This projects contains two Go modules, one in the root and one in the `docsgen` subfolder. More will be added. In order
to support checks on the supplemental modules in the project subfolders, it's necessary to configure the commands to run
from their path. This is passed to the task via the GO_MODULE_PATH environment variable. If this variable is not defined,
the default root module path is used as default, preserving the previous task behavior.

The workflows use a job matrix to allow easy configuration for any number of module paths and a dedicated parallel job
for each module.
  • Loading branch information
per1234 committed Aug 25, 2021
commit 8096c62deb1192722b84a9901433fb57d85f1e21
44 changes: 44 additions & 0 deletions .github/workflows/check-go-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,19 @@ jobs:
echo "::set-output name=result::$RESULT"

check-errors:
name: check-errors (${{ matrix.module.path }})
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
module:
- path: ./
- path: docsgen

steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand All @@ -70,13 +79,24 @@ 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 }})
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
module:
- path: ./
- path: docsgen

steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand All @@ -93,16 +113,27 @@ 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 }})
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
module:
- path: ./
- path: docsgen

steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand All @@ -122,13 +153,24 @@ 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 }})
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
module:
- path: ./
- path: docsgen

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

- name: Format code
env:
GO_MODULE_PATH: ${{ matrix.module.path }}
run: task go:format

- name: Check formatting
Expand Down
20 changes: 14 additions & 6 deletions .github/workflows/test-go-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ on:
paths:
- ".github/workflows/test-go-task.ya?ml"
- "codecov.ya?ml"
- "go.mod"
- "go.sum"
- "**/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"
- "**/go.mod"
- "**/go.sum"
- "Taskfile.ya?ml"
- "**.go"
- "**/testdata/**"
Expand Down Expand Up @@ -54,15 +54,21 @@ jobs:
echo "::set-output name=result::$RESULT"

test:
name: test (${{ matrix.module.path }} - ${{ matrix.operating-system }})
needs: run-determination
if: needs.run-determination.outputs.result == 'true'

strategy:
fail-fast: false

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

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

Expand All @@ -82,12 +88,14 @@ jobs:
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: ./coverage_unit.txt
flags: unit
file: ${{ matrix.module.path }}coverage_unit.txt
flags: ${{ matrix.module.codecov-flags }}
fail_ci_if_error: ${{ github.repository == 'arduino/arduino-lint' }}
19 changes: 18 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,19 @@ vars:
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/release-go-task/Taskfile.yml
PROJECT_NAME: "arduino-lint"
DIST_DIR: "dist"
# Path of the project's primary Go module:
DEFAULT_GO_MODULE_PATH: ./
DEFAULT_GO_PACKAGES:
sh: echo $(go list ./... | grep --invert-match 'github.com/arduino/arduino-lint/internal/rule/schema/schemadata' | tr '\n' ' ')
sh: |
echo $( \
cd {{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}} \
&& \
go list ./... | \
grep --invert-match 'github.com/arduino/arduino-lint/internal/rule/schema/schemadata' | \
tr '\n' ' ' \
|| \
echo '"ERROR: Unable to discover Go packages"' \
)
# build vars
COMMIT:
sh: echo "$(git log --no-show-signature -n 1 --format=%h)"
Expand Down Expand Up @@ -134,6 +145,7 @@ 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: "{{.DEFAULT_GO_MODULE_PATH}}"
cmds:
- go build -v {{.LDFLAGS}}

Expand All @@ -150,12 +162,14 @@ tasks:
# 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: "{{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:format:
desc: Format Go code
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
cmds:
- go fmt {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}

Expand All @@ -172,6 +186,7 @@ tasks:
# 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: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
cmds:
- |
if ! which golint &>/dev/null; then
Expand All @@ -186,6 +201,7 @@ tasks:
# 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 \
Expand All @@ -208,6 +224,7 @@ tasks:
# 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: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
cmds:
- go vet {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}

Expand Down
0