-
Notifications
You must be signed in to change notification settings - Fork 560
104 lines (98 loc) · 3.04 KB
/
acctest-terraform-basic.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Terrafrom Basic Checks
on:
pull_request:
paths:
- .github/workflows/acctest-terraform-basic.yml
- alicloud/*.go
branches:
- master
jobs:
BreakingChange:
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20.x'
- uses: actions/checkout@v3
with:
# Checkout as many commits as needed for the diff
fetch-depth: 2
- name: Attribute Breaking Change Check
run: |
git diff HEAD^ HEAD > diff.out
go run scripts/breaking_change_check.go -fileNames="diff.out"
Consistency:
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20.x'
- uses: actions/checkout@v3
with:
# Checkout as many commits as needed for the diff
fetch-depth: 2
- name: Attribute Consistency Check
run: |
git diff HEAD^ HEAD > diff.out
go run scripts/consistency_check.go -fileNames="diff.out"
Formatter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# Checkout as many commits as needed for the diff
fetch-depth: 2
- name: Set up Go Version
uses: actions/setup-go@v2
with:
go-version: '1.20.x'
- name: Get dependencies
run: |
go install golang.org/x/tools/cmd/[email protected]
go mod tidy
- name: Golang Formatter Check
run: |
if [[ $(git diff --name-only HEAD^ HEAD | grep -c "^alicloud/") -lt 1 ]]; then
echo -e "\033[33m[WARNING]\033[0m there are no go files were changed, skipped."
exit 0
fi
exitCode=0
echo "==> Checking that code complies with gofmt and goimports requirements..."
diffFiles=$(git diff --name-only HEAD^ HEAD | grep "^alicloud/")
for fileName in ${diffFiles[@]};
do
if [[ ! -f ${filename} ]]; then
continue
fi
goimpFile=$(goimports -l ${fileName})
if [[ -n ${goimpFile} ]]; then
goimports -d ${fileName}
exitCode=1
fi
gofmtFile=$(gofmt -l ${fileName})
if [[ -n ${gofmtFile} ]]; then
gofmt -d ${fileName}
exitCode=1
fi
done
if [[ ${exitCode} -gt 0 ]]; then
echo -e "\n\033[31m[Error]\033[0m==> gofmt or goimports needs running on the above files. You can use the command: \`make fmt\` to reformat code. \033[0m"
exit 1
fi
echo -e "==> PASS"
Compile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# Checkout as many commits as needed for the diff
fetch-depth: 2
- name: Set up Go Version
uses: actions/setup-go@v2
with:
go-version: '1.20.x'
- name: vet
run: |
make vet