Skip to content

Commit 817245d

Browse files
authored
Merge pull request #141 from per1234/default-go-module-path-var
Use taskfile variable to define primary Go module path
2 parents dd3f587 + 99475c8 commit 817245d

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

workflow-templates/assets/check-go-task/Taskfile.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ tasks:
1212
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
1313
go:vet:
1414
desc: Check for errors in Go code
15-
dir: '{{default "./" .GO_MODULE_PATH}}'
15+
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
1616
cmds:
1717
- go vet {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
1818

1919
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
2020
go:fix:
2121
desc: Modernize usages of outdated APIs
22-
dir: '{{default "./" .GO_MODULE_PATH}}'
22+
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
2323
cmds:
2424
- go fix {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
2525

2626
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
2727
go:lint:
2828
desc: Lint Go code
29-
dir: '{{default "./" .GO_MODULE_PATH}}'
29+
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
3030
cmds:
3131
- |
3232
if ! which golint &>/dev/null; then
@@ -41,6 +41,6 @@ tasks:
4141
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
4242
go:format:
4343
desc: Format Go code
44-
dir: '{{default "./" .GO_MODULE_PATH}}'
44+
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
4545
cmds:
4646
- go fmt {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}

workflow-templates/assets/go-task/Taskfile.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
version: "3"
33

44
vars:
5+
# Path of the project's primary Go module:
6+
DEFAULT_GO_MODULE_PATH: ./
57
DEFAULT_GO_PACKAGES:
68
sh: |
7-
echo $(cd {{default "./" .GO_MODULE_PATH}} && go list ./... | tr '\n' ' ' || echo '"ERROR: Unable to discover Go packages"')
9+
echo $(cd {{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}} && go list ./... | tr '\n' ' ' || echo '"ERROR: Unable to discover Go packages"')
810
LDFLAGS:
911

1012
tasks:
1113
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/go-task/Taskfile.yml
1214
go:build:
1315
desc: Build the Go code
16+
dir: "{{.DEFAULT_GO_MODULE_PATH}}"
1417
cmds:
1518
- go build -v {{.LDFLAGS}}

workflow-templates/assets/test-go-task/Taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ tasks:
55
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-go-task/Taskfile.yml
66
go:test:
77
desc: Run unit tests
8-
dir: '{{default "./" .GO_MODULE_PATH}}'
8+
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
99
cmds:
1010
- |
1111
go test \

workflow-templates/check-go-task.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Install the [`check-go-task.yml`](check-go-task.yml) GitHub Actions workflow to
1212

1313
- [`Taskfile.yml`](assets/check-go-task/Taskfile.yml) - Linting and formatting [tasks](https://taskfile.dev/).
1414
- Install to: repository root (or merge into the existing `Taskfile.yml`).
15-
- [`Taskfile.yml`](assets/go-task/Taskfile.yml) - `DEFAULT_GO_PACKAGES` variable
15+
- [`Taskfile.yml`](assets/go-task/Taskfile.yml) - `DEFAULT_GO_MODULE_PATH` and `DEFAULT_GO_PACKAGES` variables
1616
- Merge into `Taskfile.yml`
1717

1818
### Configuration

workflow-templates/test-go-task.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Install the [`test-go-task.yml`](test-go-task.yml) GitHub Actions workflow to `.
1414

1515
- [`Taskfile.yml`](assets/test-go-task/Taskfile.yml)
1616
- Install to: repository root (or merge into the existing `Taskfile.yml`).
17-
- [`Taskfile.yml`](assets/go-task/Taskfile.yml) - `DEFAULT_GO_PACKAGES` variable
17+
- [`Taskfile.yml`](assets/go-task/Taskfile.yml) - `DEFAULT_GO_MODULE_PATH` and `DEFAULT_GO_PACKAGES` variables
1818
- Merge into `Taskfile.yml`
1919

2020
### Configuration

0 commit comments

Comments
 (0)