Skip to content

Commit e4a03e4

Browse files
chore: synced file(s) with orange-cloudavenue/workflows (#42)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 820a07e commit e4a03e4

9 files changed

+432
-1
lines changed

.golangci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ linters:
4949
- sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed. [fast: false, auto-fix: false]
5050
- stylecheck # Stylecheck is a replacement for golint [fast: false, auto-fix: false]
5151
- tagliatelle # Checks the struct tags. [fast: true, auto-fix: false]
52-
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17 [fast: false, auto-fix: false]
52+
- usetesting # Checks for the use of the testing package [fast: true, auto-fix: false]
5353
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes [fast: false, auto-fix: false]
5454
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code [fast: false, auto-fix: false]
5555
- unconvert # Remove unnecessary type conversions [fast: false, auto-fix: false]

.taskfiles/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Taskfiles
2+
3+
> [!WARNING]
4+
> All files in the `.taskfiles` directory are manager by centralized sync management system.
5+
> Do not edit this file directly, your changes will be overwritten.
6+
> See [https://github.com/orange-cloudavenue/workflows](https://github.com/orange-cloudavenue/workflows) for more information.

.taskfiles/golang.yml

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# yaml-language-server: $schema=https://taskfile.dev/schema.json
2+
version: "3"
3+
4+
includes:
5+
internal: internal.yml
6+
7+
# Lints
8+
tasks:
9+
# * Linters
10+
lint:
11+
desc: Run Go linters
12+
cmds:
13+
- for: [
14+
govulncheck,
15+
golangci-lint,
16+
"deps:verify",
17+
]
18+
task: lint:{{.ITEM}}
19+
20+
lint:govulncheck:
21+
desc: Run govulncheck
22+
internal: true
23+
cmds:
24+
- govulncheck ./...
25+
26+
lint:golangci-lint:
27+
desc: Run golangci-lint
28+
internal: true
29+
cmds:
30+
- golangci-lint run --fix -j 8 ./...
31+
32+
lint:deps:verify:
33+
internal: true
34+
desc: Run go mod verify
35+
cmds:
36+
- go mod verify
37+
38+
# * Init
39+
init:
40+
desc: Initialize the golang
41+
silent: true
42+
internal: true
43+
cmds:
44+
- defer: "echo ✅ Golang are initialized"
45+
46+
# * Install
47+
install:
48+
desc: Install required tools
49+
cmds:
50+
- for: [
51+
govulncheck,
52+
golangci-lint
53+
]
54+
task: internal:tools:brew
55+
vars:
56+
APP: '{{.ITEM}}'
57+
58+
# * Actions
59+
run:
60+
desc: Run golang actions
61+
cmds:
62+
- for: [
63+
deps,
64+
generate,
65+
]
66+
task: actions:{{.ITEM}}
67+
68+
69+
# ? Deps
70+
actions:deps:
71+
desc: Run go mod tidy and verify
72+
internal: true
73+
cmds:
74+
- for: [
75+
tidy,
76+
]
77+
task: actions:deps:{{.ITEM}}
78+
79+
actions:deps:tidy:
80+
internal: true
81+
desc: Run go mod tidy
82+
cmds:
83+
- go mod tidy
84+
85+
# ? Generate
86+
actions:generate:
87+
internal: true
88+
desc: Generate code
89+
cmds:
90+
- go generate ./...

.taskfiles/internal.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# yaml-language-server: $schema=https://taskfile.dev/schema.json
2+
version: "3"
3+
4+
tasks:
5+
tools:brew:
6+
desc: brew install
7+
internal: true
8+
silent: true
9+
preconditions:
10+
- sh: command -v brew
11+
msg: "brew is not installed. Please install brew. See CONTRIBUTING.md for the required tools"
12+
cmds:
13+
## Brew apps
14+
- cmd: |
15+
brew install {{.APP}} --quiet && \
16+
echo "✅ {{.APP}} installed successfully" || \
17+
echo "❌ Failed to install {{.APP}}"
18+
19+
tools:brew:optional:
20+
desc: brew install
21+
internal: true
22+
silent: true
23+
preconditions:
24+
- sh: command -v brew
25+
msg: "brew is not installed. Please install brew. See CONTRIBUTING.md for the required tools"
26+
cmds:
27+
## Brew apps
28+
- cmd: |
29+
if [ {{.INSTALL_REQUIRED}} = true ]; then \
30+
brew install {{.APP}} --quiet && \
31+
echo "✅ {{.APP}} installed successfully" || \
32+
echo "❌ Failed to install {{.APP}}"
33+
fi
34+
35+
tools:brew:tap:
36+
desc: brew tap
37+
internal: true
38+
silent: true
39+
preconditions:
40+
- sh: command -v brew
41+
msg: "brew is not installed. Please install brew"
42+
cmds:
43+
## Brew taps
44+
- cmd: |
45+
brew tap {{.APP}} --quiet && \
46+
echo "✅ {{.APP}} tapped successfully" || \
47+
echo "❌ Failed to tap {{.APP}} not tapped"

.taskfiles/license.yml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# yaml-language-server: $schema=https://taskfile.dev/schema.json
2+
version: "3"
3+
4+
includes:
5+
internal: internal.yml
6+
7+
tasks:
8+
# * Linters
9+
lint:
10+
desc: Run license linters
11+
cmds:
12+
- for: [
13+
license-header,
14+
]
15+
task: lint:{{.ITEM}}
16+
17+
lint:license-header:
18+
desc: Run license header
19+
internal: true
20+
preconditions:
21+
- sh: command -v license-eye
22+
msg: "license-eye is not installed. Please run `task license:install`"
23+
- sh: test -f .licenserc.yaml
24+
msg: "No .licenserc.yaml file found.`"
25+
cmds:
26+
- license-eye header check
27+
28+
# * Init
29+
init:
30+
desc: Initialize the license
31+
silent: true
32+
internal: true
33+
cmds:
34+
- defer: echo "✅ License are initialized"
35+
36+
# * Install
37+
install:
38+
desc: Install required tools
39+
cmds:
40+
- for: [
41+
license-eye,
42+
]
43+
task: internal:tools:brew
44+
vars:
45+
APP: '{{.ITEM}}'
46+
47+
# * Actions
48+
run:
49+
desc: Run license actions
50+
cmds:
51+
- for: [
52+
license-header-fix,
53+
]
54+
task: actions:{{.ITEM}}
55+
56+
# ? Generate
57+
actions:license-header-fix:
58+
desc: Run license header
59+
internal: true
60+
preconditions:
61+
- sh: command -v license-eye
62+
msg: "license-eye is not installed. Please run `task license:install`"
63+
- sh: test -f .licenserc.yaml
64+
msg: "No .licenserc.yaml file found.`"
65+
cmds:
66+
- license-eye header fix

.taskfiles/pre-commit.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# yaml-language-server: $schema=https://taskfile.dev/schema.json
2+
version: "3"
3+
4+
includes:
5+
internal: internal.yml
6+
7+
tasks:
8+
# * Linters
9+
lint:
10+
desc: Run pre-commit linters
11+
silent: true
12+
internal: true
13+
cmds:
14+
- echo "🚧 No linters available for pre-commit"
15+
16+
init:
17+
desc: Initialize the pre-commit
18+
silent: true
19+
preconditions:
20+
- sh: command -v pre-commit
21+
msg: "pre-commit is not installed. Please run `task install`"
22+
- sh: test -f .pre-commit-config.yaml
23+
msg: "No .pre-commit-config.yaml file found."
24+
cmds:
25+
- defer: echo "✅ Pre-commit are initialized"
26+
- pre-commit install
27+
- pre-commit install --install-hooks
28+
29+
install:
30+
desc: Install required tools
31+
cmds:
32+
- for: [
33+
pre-commit,
34+
]
35+
task: internal:tools:brew
36+
vars:
37+
APP: '{{.ITEM}}'

.taskfiles/terraform.yml

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# yaml-language-server: $schema=https://taskfile.dev/schema.json
2+
version: "3"
3+
4+
vars:
5+
IS_MODULE:
6+
# The pattern of terraform module name is terraform-cloudavenue-<nameofmodule>.
7+
# Detect if it's a module with the presence of the terraform-cloudavenue- keyword in the last part of the path
8+
sh: |
9+
if [[ $IS_MODULE == "" ]]; then
10+
awk -F/ '{print $NF}' <<< $(pwd) | grep -q "terraform-cloudavenue-" && echo "true" || echo "false"
11+
else
12+
echo $IS_MODULE
13+
fi
14+
15+
includes:
16+
internal: internal.yml
17+
18+
tasks:
19+
# * Init
20+
init:
21+
desc: Initialize the terraform
22+
silent: true
23+
internal: true
24+
cmds:
25+
- defer: "echo ✅ Terraform are initialized"
26+
- cmd: terraform init
27+
- cmd: tflint --init
28+
29+
# * Install
30+
install:
31+
desc: Install required tools
32+
cmds:
33+
- for: [
34+
hashicorp/tap,
35+
]
36+
task: internal:tools:brew:tap
37+
vars:
38+
APP: '{{.ITEM}}'
39+
- for: [
40+
hashicorp/tap/terraform,
41+
tflint,
42+
]
43+
task: internal:tools:brew
44+
vars:
45+
APP: '{{.ITEM}}'
46+
- task: install:module
47+
48+
install:module:
49+
desc: Install terraform module
50+
internal: true
51+
cmds:
52+
- for: [
53+
terraform-docs,
54+
]
55+
task: internal:tools:brew:optional
56+
vars:
57+
APP: '{{.ITEM}}'
58+
INSTALL_REQUIRED: '{{.IS_MODULE}}'
59+
60+
# * Lint
61+
lint:
62+
desc: Run terraform linters
63+
cmds:
64+
- for: [
65+
tf:fmt,
66+
tf:validate,
67+
tflint,
68+
]
69+
task: lint:{{.ITEM}}
70+
71+
# * Lint with terraform client
72+
lint:tf:fmt:
73+
desc: Run terraform fmt
74+
internal: true
75+
preconditions:
76+
- sh: command -v terraform
77+
msg: "terraform is not installed. Please run `task install`"
78+
cmds:
79+
- terraform fmt
80+
81+
lint:tf:fmt-specific-dir:
82+
desc: Run terraform fmt on a specific directory
83+
internal: true
84+
preconditions:
85+
- sh: command -v terraform
86+
msg: "terraform is not installed. Please run `task install`"
87+
cmds:
88+
- find {{.DIRECTORY}} -name "*.tf" -exec terraform fmt {} \;
89+
90+
lint:tf:validate:
91+
desc: Run terraform validate
92+
internal: true
93+
preconditions:
94+
- sh: command -v terraform
95+
msg: "terraform is not installed. Please run `task install`"
96+
cmds:
97+
- terraform validate
98+
99+
# * Lint with tflint
100+
lint:tflint:
101+
desc: Run tflint
102+
internal: true
103+
preconditions:
104+
- sh: command -v tflint
105+
msg: "tflint is not installed. Please run `task install`"
106+
- sh: test -f .tflint.hcl
107+
msg: "No .tflint.hcl file found."
108+
cmds:
109+
- tflint
110+
111+
# * Actions
112+
actions:docs:
113+
desc: Generate terraform docs
114+
cmds:
115+
- terraform-docs markdown . > README.md

0 commit comments

Comments
 (0)