-
Notifications
You must be signed in to change notification settings - Fork 3
193 lines (163 loc) · 5.66 KB
/
test.yaml
File metadata and controls
193 lines (163 loc) · 5.66 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
name: Test spread-plus
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
name: Build Spread
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
env:
GOCHANNEL: 1.24/stable
run: |
sudo snap install go --classic --channel "$GOCHANNEL"
- name: Build spread
run: |
go build -o spread-plus cmd/spread/main.go
- name: Upload spread logs
uses: actions/upload-artifact@v4
with:
name: "spread-plus-${{ github.run_id }}"
path: "spread-plus"
integration-tests:
name: Integration Tests
needs: [build]
runs-on: [self-hosted, spread-enabled]
steps:
- name: Ensure the workspace is clean
run: |
rm -rf "${{ github.workspace }}"
mkdir "${{ github.workspace }}"
- name: Checkout code
uses: actions/checkout@v4
- name: Download spread-plus
uses: actions/download-artifact@v4
with:
name: "spread-plus-${{ github.run_id }}"
path: "${{ github.workspace }}/bin"
- name: Integration tests
env:
SPREAD_GOOGLE_KEY: ${{ secrets.SPREAD_GOOGLE_KEY }}
run: |
chmod +x "${{ github.workspace }}"/bin/spread-plus
"${{ github.workspace }}/bin/spread-plus" google:tests/
- name: Discard spread workers
if: always()
run: |
shopt -s nullglob;
for r in .spread-reuse.*.yaml; do
spread -discard -reuse-pid="$(echo "$r" | grep -o -E '[0-9]+')";
done
- name: Cleanup job workspace after run tests
if: always()
run: |
rm -rf "${{ github.workspace }}"
mkdir "${{ github.workspace }}"
smoke-tests:
name: Smoke Tests
needs: [build]
runs-on: [self-hosted, spread-enabled]
steps:
- name: Ensure the workspace is clean
run: |
rm -rf "${{ github.workspace }}"
mkdir "${{ github.workspace }}"
- name: Checkout code
uses: actions/checkout@v4
- name: Download spread-plus
uses: actions/download-artifact@v4
with:
name: "spread-plus-${{ github.run_id }}"
path: "${{ github.workspace }}/bin"
- name: Smoke tests with google backend
env:
SPREAD_GOOGLE_KEY: ${{ secrets.SPREAD_GOOGLE_KEY }}
run: |
cd "${{ github.workspace }}"/smoke
chmod +x "${{ github.workspace }}"/bin/spread-plus
"${{ github.workspace }}/bin/spread-plus" google:tests/
- name: Smoke tests with openstack backend
env:
OS_AUTH_URL: ${{ secrets.OS_AUTH_URL }}
OS_IDENTITY_API_VERSION: ${{ vars.OS_IDENTITY_API_VERSION }}
OS_INTERFACE: ${{ vars.OS_INTERFACE }}
OS_PASSWORD: ${{ secrets.OS_PASSWORD }}
OS_PROJECT_DOMAIN_NAME: ${{ vars.OS_PROJECT_DOMAIN_NAME }}
OS_PROJECT_NAME: ${{ secrets.OS_PROJECT_NAME }}
OS_REGION_NAME: ${{ secrets.OS_REGION_NAME }}
OS_USER_DOMAIN_NAME: ${{ vars.OS_USER_DOMAIN_NAME }}
OS_USERNAME: ${{ secrets.OS_USERNAME }}
OS_SKIP: ${{ vars.SKIP_OPENSTACK }}
run: |
if [ "$OS_SKIP" == true ]; then
echo "Skipping openstack smoke tests..."
exit
fi
cd "${{ github.workspace }}"/smoke
"${{ github.workspace }}/bin/spread-plus" openstack:tests/
- name: Smoke tests with testflinger backend
env:
TF_SKIP: ${{ vars.SKIP_TESTFLINGER }}
run: |
if [ "$TF_SKIP" == true ]; then
echo "Skipping testflinger smoke tests..."
exit
fi
cd "${{ github.workspace }}"/smoke
"${{ github.workspace }}/bin/spread-plus" testflinger:tests/
- name: Discard spread workers
if: always()
run: |
shopt -s nullglob;
for r in .spread-reuse.*.yaml; do
spread -discard -reuse-pid="$(echo "$r" | grep -o -E '[0-9]+')";
done
- name: Cleanup job workspace after run tests
if: always()
run: |
rm -rf "${{ github.workspace }}"
mkdir "${{ github.workspace }}"
upload:
name: Upload binary to GCE
runs-on: ubuntu-latest
needs: [integration-tests, smoke-tests]
steps:
- name: Download spread-plus
uses: actions/download-artifact@v4
with:
name: "spread-plus-${{ github.run_id }}"
path: "${{ github.workspace }}/bin"
- name: Upload to google bucket
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
GCLOUD_SA_KEY: ${{ secrets.GCLOUD_SA_KEY }}
SPREAD_FILE: spread-plus-amd64
run: |
sudo snap install google-cloud-sdk --classic
echo "$GCLOUD_SA_KEY" > sa.json
gcloud auth activate-service-account --key-file=sa.json
rm -f sa.json
mv "${{ github.workspace }}"/bin/spread-plus spread
chmod +x spread
tar -czf "$SPREAD_FILE".tar.gz spread
# Back up previous spread if it is published
if gsutil ls gs://snapd-spread-tests/spread/"$SPREAD_FILE".tar.gz; then
gsutil cp gs://snapd-spread-tests/spread/"$SPREAD_FILE".tar.gz gs://snapd-spread-tests/spread/"$SPREAD_FILE"-old.tar.gz
fi
gsutil cp "$SPREAD_FILE".tar.gz gs://snapd-spread-tests/spread/"$SPREAD_FILE".tar.gz
- name: Logout from Google Cloud
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
gcloud auth revoke
- name: Cleanup job workspace after run tests
if: always()
run: |
rm -rf "${{ github.workspace }}"
mkdir "${{ github.workspace }}"