-
Notifications
You must be signed in to change notification settings - Fork 47
206 lines (179 loc) · 6.93 KB
/
fabric_acctest.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: Fabric Acceptance Tests
# This workflow determines whether a PR comes from an external fork
# (which requires approval from us) or from a branch on this repository
# (which means it was made by us and can run immediately). Once a PR
# is approved, the PR code gains access to secrets referenced in this
# workflow.
# The 'build' job and subsequent jobs, are executed only when the pull
# request is not a draft, regardless of whether it is from an internal
# branch or external fork.
# Any changes to this job, even from internal contributors, require heavy scrutiny.
on:
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'go.mod'
- 'go.sum'
- '**fabric**'
- '!LICENSE'
- '!**.md'
- '!website/**'
- '!docs/**'
- '!.github/ISSUE_TEMPLATE/**'
workflow_dispatch:
permissions:
pull-requests: read
contents: read
jobs:
authorize:
if: (github.event_name == 'workflow_dispatch') || (github.event_name == 'pull_request_target' && github.event.pull_request.draft == false)
environment:
${{ github.event_name == 'pull_request_target' &&
github.event.pull_request.head.repo.full_name != github.repository &&
'external' || 'internal' }}
runs-on: ubuntu-latest
concurrency:
group: ${{ github.event_name == 'pull_request_target' && format('fabric-acctest-authorize-pr-{0}', github.event.pull_request.number) || 'fabric-acctest-authorize' }}
cancel-in-progress: true
steps:
- run: true
build:
name: Build
needs: authorize
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
id: go
- name: Get dependencies
run: |
go mod download
- name: Build
run: |
go build -v .
test-PFNV:
name: Matrix Test
needs: build
runs-on: ubuntu-latest
env:
EQUINIX_API_ENDPOINT: "https://uatapi.equinix.com"
timeout-minutes: 240
strategy:
fail-fast: false
matrix:
version:
- stable
terraform:
- '1.5'
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
id: go
- name: Get dependencies
run: |
go mod download
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- name: TF Fabric PNFV acceptance tests
timeout-minutes: 180
env:
TF_ACC: "1"
TF_ACC_FABRIC_CONNECTIONS_TEST_DATA: ${{ secrets.TF_ACC_FABRIC_CONNECTIONS_TEST_DATA }}
TF_ACC_FABRIC_DEDICATED_PORTS: ${{ secrets.TF_ACC_FABRIC_DEDICATED_PORTS }}
EQUINIX_API_CLIENTID: ${{ secrets.EQUINIX_API_CLIENTID_PNFV }}
EQUINIX_API_CLIENTSECRET: ${{ secrets.EQUINIX_API_CLIENTSECRET_PNFV }}
METAL_AUTH_TOKEN: ${{ secrets.METAL_AUTH_TOKEN }}
run: |
go test ./... -v -coverprofile coverage_pnfv.txt -covermode=atomic -count 1 -parallel 8 -run "(PNFV)" -timeout 180m
- name: Sweeper PNFV
if: ${{ always() }}
env:
EQUINIX_API_CLIENTID: ${{ secrets.EQUINIX_API_CLIENTID_PNFV }}
EQUINIX_API_CLIENTSECRET: ${{ secrets.EQUINIX_API_CLIENTSECRET_PNFV }}
METAL_AUTH_TOKEN: ${{ secrets.METAL_AUTH_TOKEN }}
SWEEP: "all" #Flag required to define the regions that the sweeper is to be ran in
SWEEP_ALLOW_FAILURES: "true" #Enable to allow Sweeper Tests to continue after failures
SWEEP_DIR: "./equinix"
run: |
# Added sweep-run to filter Fabric PNFV test
go test $(go list ./... | grep 'internal/sweep\|equinix/equinix') -v -timeout 180m -sweep=${SWEEP} -sweep-allow-failures=${SWEEP_ALLOW_FAILURES} -sweep-run=$(grep -or 'AddTestSweepers("[^"]*"' | grep "_fabric_" | cut -d '"' -f2 | paste -s -d, -)
- name: Upload coverage to Codecov
if: ${{ always() }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage_pnfv.txt
test-PFCR:
name: Matrix Test
needs: build
runs-on: ubuntu-latest
env:
EQUINIX_API_ENDPOINT: "https://uatapi.equinix.com"
timeout-minutes: 240
strategy:
fail-fast: false
matrix:
version:
- stable
terraform:
- '1.5'
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
id: go
- name: Get dependencies
run: |
go mod download
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- name: TF Fabric PFCR acceptance tests
timeout-minutes: 180
env:
TF_ACC: "1"
TF_ACC_FABRIC_CONNECTIONS_TEST_DATA: ${{ secrets.TF_ACC_FABRIC_CONNECTIONS_TEST_DATA }}
TF_ACC_FABRIC_DEDICATED_PORTS: ${{ secrets.TF_ACC_FABRIC_DEDICATED_PORTS }}
EQUINIX_API_CLIENTID: ${{ secrets.EQUINIX_API_CLIENTID_PFCR }}
EQUINIX_API_CLIENTSECRET: ${{ secrets.EQUINIX_API_CLIENTSECRET_PFCR }}
METAL_AUTH_TOKEN: ${{ secrets.METAL_AUTH_TOKEN }}
run: |
go test ./... -v -coverprofile coverage_pfcr.txt -covermode=atomic -count 1 -parallel 8 -run "(PFCR)" -timeout 180m
- name: Sweeper PFCR
if: ${{ always() }}
env:
EQUINIX_API_CLIENTID: ${{ secrets.EQUINIX_API_CLIENTID_PFCR }}
EQUINIX_API_CLIENTSECRET: ${{ secrets.EQUINIX_API_CLIENTSECRET_PFCR }}
METAL_AUTH_TOKEN: ${{ secrets.METAL_AUTH_TOKEN }}
SWEEP: "all" #Flag required to define the regions that the sweeper is to be ran in
SWEEP_ALLOW_FAILURES: "true" #Enable to allow Sweeper Tests to continue after failures
run: |
# Added sweep-run to filter Fabric PFCR test
go test $(go list ./... | grep 'internal/sweep\|equinix/equinix') -v -timeout 180m -sweep=${SWEEP} -sweep-allow-failures=${SWEEP_ALLOW_FAILURES} -sweep-run=$(grep -or 'AddTestSweepers("[^"]*"' | grep "_fabric_" | cut -d '"' -f2 | paste -s -d, -)
- name: Upload coverage to Codecov
if: ${{ always() }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage_pfcr.txt