-
-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (132 loc) · 3.8 KB
/
build.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: build
run-name: '🛠️ Build - ${{ github.ref_name }}'
on:
push:
branches:
- main
pull_request_target:
branches:
- main
types:
- opened
- reopened
- synchronize
permissions:
contents: read
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
build:
name: Go Build
runs-on: ubuntu-latest
steps:
- name: Checkout 💻
uses: actions/[email protected]
- name: Setup Go environment ⚙️
uses: actions/[email protected]
with:
go-version-file: 'go.mod'
cache: true
- name: Go pkg Install 📦
run: go mod download
- name: Go Build 🛠️
run: go build -v ./...
test-unit:
name: Go Unit Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version:
- '1.23'
needs:
- build
steps:
- name: Checkout 💻
uses: actions/[email protected]
- name: Setup Go environment ⚙️
uses: actions/[email protected]
with:
go-version: ${{ matrix.go-version }}
- name: Go pkg Install 📦
run: go mod download
- name: Go Unit Test 🧪
run: go test ./... -v -coverprofile=unit-test.lcov -json > unit-test.log
- name: Upload Unit Test Artifacts ⏫
uses: actions/[email protected]
if: ${{ success() }}
with:
name: unit-test-reports-${{ github.sha }}
path: |
unit-test.lcov
unit-test.log
retention-days: 7
overwrite: true
compression-level: 1 # best speed
test-acc:
name: Go Acceptance Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tf-version:
- '1.8.*'
steps:
- name: Checkout 💻
uses: actions/[email protected]
- name: Setup Go environment ⚙️
uses: actions/[email protected]
with:
go-version: '1.23'
- name: Terraform Setup 🏗️
uses: hashicorp/[email protected]
with:
terraform_version: ${{ matrix.tf-version }}
terraform_wrapper: false
- name: Go Acceptance Test 🧪
run: go test ./internal/provider -v -coverprofile=acc-test.lcov -json > acc-test.log
env:
TF_ACC: '1'
- name: Upload coverage reports to Codecov ☂️
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
files: unit-test.lcov,acc-test.lcov
- name: Upload Acceptance Test Artifacts ⏫
uses: actions/[email protected]
if: ${{ success() }}
with:
name: acc-test-reports-${{ github.sha }}
path: |
acc-test.lcov
acc-test.log
retention-days: 7
overwrite: true
compression-level: 1 # best speed
sonarcloud:
name: SonarCloud Scan
runs-on: ubuntu-latest
needs:
- build
- test-unit
- test-acc
steps:
- name: Checkout 💻
uses: actions/[email protected]
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: Download Unit Test Artifact ⏬
uses: actions/[email protected]
with:
name: unit-test-reports-${{ github.sha }}
- name: Download Acceptance Test Artifact ⏬
uses: actions/[email protected]
with:
name: acc-test-reports-${{ github.sha }}
- name: SonarCloud Scan 🎯
uses: sonarsource/[email protected] # See the latest version at https://github.com/marketplace/actions/sonarcloud-scan
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}