This repository was archived by the owner on Oct 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
219 lines (202 loc) · 6.51 KB
/
run-pr-tests.yaml
File metadata and controls
219 lines (202 loc) · 6.51 KB
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
207
208
209
210
211
212
213
214
215
216
217
218
219
name: run-pr-tests
# Note: Don't expose secrets to scripts controlled by the fork.
# Only the workflow definition is taken from the context of the base repository.
# https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#pull_request_target
on:
# run for labeled PRs from forks
pull_request_target:
types: [labeled]
env:
GOPROXY: "https://proxy.golang.org"
DOCKER_IMAGE_ORG: ghcr.io/cfcontainerizationbot
DOCKER_IMAGE_REPOSITORY: quarks-operator-dev
DOCKER_IMAGE_TAG: "${{ github.sha }}"
jobs:
# The first thing we do is to check that the PR has the pr-test-queue label
# If it doesn't have it, the flow stops. If it does, we remove it (approval is good for one run only).
dequeue:
name: dequeue
runs-on: ubuntu-20.04
# run for PRs with the 'pr-test-queue' label, opened from forks
if: contains(github.event.pull_request.labels.*.name, 'pr-test-queue')
steps:
- uses: actions-ecosystem/action-remove-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: pr-test-queue
unit-tests:
needs: [dequeue]
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16.3
- name: Checkout forked repository
uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install dependencies
run: |
sudo gem install bosh-template
go install github.com/onsi/ginkgo/ginkgo@v1.16.0
- name: Install shared tools
run: |
bin/tools
- name: Run lint
run: |
go list ./... | xargs go vet
- name: Run unit tests
run: |
bin/test-unit
dockerbuild:
needs: [unit-tests]
runs-on: ubuntu-16.04
# Cannot run for pushes in forked repos, without adapting this workflow
if: github.repository == 'cloudfoundry-incubator/quarks-operator'
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16.3
- name: Checkout forked repository
uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install shared tools
run: |
bin/tools
git config user.email "no-reply@quarks.cloudfoundry.org"
git config user.name "$GITHUB_ACTOR"
- name: Prepare docker build
run: |
go mod vendor
- uses: whoan/docker-build-with-cache-action@v5
with:
username: cfcontainerizationbot
# container registry personal access token
password: "${{ secrets.CR_PAT }}"
registry: "${{ env.DOCKER_IMAGE_ORG }}"
image_name: "${{ env.DOCKER_IMAGE_REPOSITORY }}"
image_tag: "${{ env.DOCKER_IMAGE_TAG }}"
e2e-tests:
needs: [dockerbuild]
runs-on: ubuntu-16.04
strategy:
matrix:
kubernetes_version: [v1.16.15,v1.18.15,v1.20.2]
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16.3
- name: Checkout forked repository
uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Go dependencies
run: |
sudo gem install bosh-template
go install github.com/onsi/ginkgo/ginkgo@v1.16.0
- name: Install shared tools
run: |
bin/tools
git config user.email "no-reply@quarks.cloudfoundry.org"
git config user.name "$GITHUB_ACTOR"
- name: Create k8s Kind Cluster
uses: engineerd/setup-kind@v0.5.0
with:
config: .github/kind-config.yaml
version: v0.10.0
image: kindest/node:${{matrix.kubernetes_version}}
- name: Run cluster tests
run: |
bin/build-helm
bin/test-cli-e2e
bin/test-helm-e2e
bin/test-helm-e2e-storage
bin/test-helm-e2e-upgrade
env:
NODES: "3"
OPERATOR_TEST_STORAGE_CLASS: "standard"
PROJECT: "quarks-operator"
CF_OPERATOR_WEBHOOK_SERVICE_HOST: 172.17.0.1
- uses: actions/upload-artifact@v2
if: success()
with:
name: helm chart
path: "helm/quarks-*.tgz"
integration-tests:
needs: [dockerbuild]
runs-on: ubuntu-16.04
strategy:
matrix:
kubernetes_version: [v1.16.15,v1.18.15,v1.20.2]
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16.3
- name: Checkout forked repository
uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Go dependencies
run: |
sudo gem install bosh-template
go install github.com/onsi/ginkgo/ginkgo@v1.16.0
- name: Install shared tools
run: |
bin/tools
git config user.email "no-reply@quarks.cloudfoundry.org"
git config user.name "$GITHUB_ACTOR"
- name: Create k8s Kind Cluster
uses: engineerd/setup-kind@v0.5.0
with:
config: .github/kind-config.yaml
version: v0.10.0
image: kindest/node:${{matrix.kubernetes_version}}
- name: Run cluster tests
run: |
bin/test-integration
INTEGRATION_SUITE=storage bin/test-integration
INTEGRATION_SUITE=util bin/test-integration
env:
NODES: "3"
DEBUG: "no"
OPERATOR_TEST_STORAGE_CLASS: "standard"
PROJECT: "quarks-operator"
CF_OPERATOR_WEBHOOK_SERVICE_HOST: 172.17.0.1
- uses: actions/upload-artifact@v2
if: failure()
with:
name: ginkgo debug logs
path: "**/ginkgo-node-*.log"