@@ -23,10 +23,65 @@ permissions:
2323env :
2424 CI_COMMIT_AUTHOR : trvon
2525 CI_COMMIT_EMAIL :
[email protected] 26+ GO_VERSION : ' 1.22'
2627
2728jobs :
29+ lint :
30+ name : Lint
31+ runs-on : ubuntu-latest
32+ timeout-minutes : 10
33+ steps :
34+ - name : Checkout
35+ uses : actions/checkout@v4
36+
37+ - name : Set up Go
38+ uses : actions/setup-go@v4
39+ with :
40+ go-version : ${{ env.GO_VERSION }}
41+ cache : true
42+
43+ - name : Run golangci-lint
44+ uses : golangci/golangci-lint-action@v6
45+ with :
46+ version : latest
47+ args : --timeout=5m
48+
49+ - name : Run go vet
50+ run : go vet ./...
51+
52+ - name : Check formatting
53+ run : |
54+ if [ -n "$(gofmt -s -l .)" ]; then
55+ echo "Go code is not formatted:"
56+ gofmt -s -d .
57+ exit 1
58+ fi
59+
60+ security :
61+ name : Security Checks
62+ runs-on : ubuntu-latest
63+ timeout-minutes : 10
64+ steps :
65+ - name : Checkout
66+ uses : actions/checkout@v4
67+
68+ - name : Set up Go
69+ uses : actions/setup-go@v4
70+ with :
71+ go-version : ${{ env.GO_VERSION }}
72+ cache : true
73+
74+ - name : Run govulncheck
75+ run : |
76+ go install golang.org/x/vuln/cmd/govulncheck@latest
77+ govulncheck ./...
78+
79+ - name : Run tests with race detector
80+ run : go test -race -short ./...
81+
2882 unit-tests :
2983 name : Unit Tests
84+ needs : [lint]
3085 runs-on : ubuntu-latest
3186 timeout-minutes : 15
3287 steps :
@@ -38,24 +93,33 @@ jobs:
3893 - name : Set up Go
3994 uses : actions/setup-go@v4
4095 with :
41- go-version : ' 1.18 '
96+ go-version : ${{ env.GO_VERSION }}
4297 cache : true
4398
4499 - name : Unit Tests
45100 run : |
46- go test ./... -v -timeout=120s
101+ go test ./... -v -timeout=120s -coverprofile=coverage.out
47102 timeout-minutes : 5
48103
104+ - name : Upload coverage
105+ uses : codecov/codecov-action@v4
106+ if : always()
107+ with :
108+ files : ./coverage.out
109+ flags : unittests
110+ fail_ci_if_error : false
111+
49112 acceptance-tests :
50113 name : Acceptance Tests
114+ needs : [lint]
51115 runs-on : ubuntu-latest
52116 timeout-minutes : 20
53117 container :
54118 image : gns3/openvswitch:latest
55119 volumes :
56120 - /lib/modules:/lib/modules
57121 options : --cap-add=NET_ADMIN --privileged
58-
122+
59123 steps :
60124 - name : Install dependencies
61125 run : |
@@ -67,15 +131,15 @@ jobs:
67131 uses : actions/checkout@v4
68132 with :
69133 fetch-depth : 0
70-
134+
71135 - name : Verify and setup Go
72136 run : |
73137 echo "Go binary location: $(which go)"
74138 go version
75139 echo "GOPATH: $GOPATH"
76140 # Make sure Go binaries are in PATH
77141 echo "PATH=$PATH:/usr/local/go/bin:$(go env GOPATH)/bin" >> $GITHUB_ENV
78-
142+
79143 - name : Start Open vSwitch service
80144 run : |
81145 /usr/share/openvswitch/scripts/ovs-ctl start
@@ -91,15 +155,19 @@ jobs:
91155
92156 integration-tests :
93157 name : Integration Tests
94- needs : [unit-tests, acceptance-tests]
158+ needs : [unit-tests, acceptance-tests, security ]
95159 runs-on : ubuntu-latest
96160 timeout-minutes : 30
161+ strategy :
162+ matrix :
163+ terraform_version : ['1.6.0', '1.10.5']
164+ opentofu_version : ['1.6.0', '1.8.10']
97165 container :
98166 image : gns3/openvswitch:latest
99167 volumes :
100168 - /lib/modules:/lib/modules
101169 options : --cap-add=NET_ADMIN --privileged
102-
170+
103171 steps :
104172 - name : Install dependencies
105173 run : |
@@ -131,8 +199,8 @@ jobs:
131199
132200 - name : Install Terraform
133201 run : |
134- wget https://releases.hashicorp.com/terraform/1.6.0/terraform_1.6.0_linux_amd64 .zip
135- unzip terraform_1.6.0_linux_amd64 .zip
202+ wget https://releases.hashicorp.com/terraform/${{ matrix.terraform_version }}/terraform_${{ matrix.terraform_version }}_linux_amd64 .zip
203+ unzip terraform_${{ matrix.terraform_version }}_linux_amd64 .zip
136204 mv terraform /usr/local/bin/
137205 terraform version
138206 timeout-minutes : 5
@@ -155,9 +223,10 @@ jobs:
155223
156224 - name : Install OpenTofu
157225 run : |
158- wget https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_linux_amd64 .zip
159- unzip -o tofu_1.6.0_linux_amd64 .zip
226+ wget https://github.com/opentofu/opentofu/releases/download/v${{ matrix.opentofu_version }}/tofu_${{ matrix.opentofu_version }}_linux_amd64 .zip
227+ unzip -o tofu_${{ matrix.opentofu_version }}_linux_amd64 .zip
160228 mv tofu /usr/local/bin/
229+ tofu version
161230 timeout-minutes : 5
162231
163232 - name : Test with OpenTofu
@@ -209,21 +278,21 @@ jobs:
209278 - name : Set up Go
210279 uses : actions/setup-go@v4
211280 with :
212- go-version : ' 1.18 '
281+ go-version : ${{ env.GO_VERSION }}
213282 cache : true
214283
215284 - name : ' Terraform Provider Release'
216285 uses : hashicorp/ghaction-terraform-provider-release/.github/workflows/community.yml@v4
217286 with :
218287 gpg-private-key : ' ${{ secrets.GPG_PRIVATE_KEY }}'
219288 setup-go-version-file : ' go.mod'
220-
289+
221290 - name : Generate Release Notes
222291 run : |
223292 cd .changes
224293 sed -e "1{/# /d;}" -e "2{/^$/d;}" ${{ steps.version.outputs.CHANGELOG_VERSION }}.md > /tmp/release-notes.txt
225294 timeout-minutes : 2
226-
295+
227296 - name : GH Release
228297 run : |
229298 gh release create "${{ github.event.inputs.versionNumber }}" --notes-file /tmp/release-notes.txt --title "${{ github.event.inputs.versionNumber }}"
0 commit comments