-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
243 lines (215 loc) · 8.92 KB
/
test.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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
name: Test
on:
# Run CI on all pushes to the master and release/** branches, and on all new
# pull requests, and on all pushes to pull requests (even if a pull request
# is not against master).
push:
branches:
- "master"
- "release/**"
pull_request:
schedule:
- cron: "0 0,12 * * *"
concurrency:
group: ${{ github.ref_name || github.sha }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
e2e-test:
if: github.repository_owner == 'getsentry'
runs-on: ubuntu-22.04
name: "Sentry self-hosted end-to-end tests"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: self-hosted
- name: End to end tests
uses: getsentry/action-self-hosted-e2e-tests@main
with:
project_name: self-hosted
unit-test:
if: github.repository_owner == 'getsentry'
runs-on: ubuntu-22.04
name: "unit tests"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Unit Tests
run: ./unit-test.sh
upgrade-test:
if: github.repository_owner == 'getsentry'
runs-on: ubuntu-22.04
name: "Sentry upgrade test"
env:
REPORT_SELF_HOSTED_ISSUES: 0
steps:
- name: Get latest self-hosted release version
run: |
LATEST_TAG=$(curl -s https://api.github.com/repos/getsentry/self-hosted/releases/latest | jq -r '.tag_name')
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
- name: Checkout latest release
uses: actions/checkout@v4
with:
ref: ${{ env.LATEST_TAG }}
- name: Get Compose
run: |
# Docker Compose v1 is installed here, remove it
sudo rm -f "/usr/local/bin/docker-compose"
sudo rm -f "/usr/local/lib/docker/cli-plugins/docker-compose"
sudo mkdir -p "/usr/local/lib/docker/cli-plugins"
sudo curl -L https://github.com/docker/compose/releases/download/v2.26.0/docker-compose-`uname -s`-`uname -m` -o "/usr/local/lib/docker/cli-plugins/docker-compose"
sudo chmod +x "/usr/local/lib/docker/cli-plugins/docker-compose"
- name: Prepare Docker Volume Caching
id: cache_key
run: |
# Set permissions for docker volumes so we can cache and restore
sudo chmod o+x /var/lib/docker
sudo chmod -R o+rwx /var/lib/docker/volumes
source .env
SENTRY_IMAGE_SHA=$(docker buildx imagetools inspect $SENTRY_IMAGE --format "{{println .Manifest.Digest}}")
echo "SENTRY_IMAGE_SHA=$SENTRY_IMAGE_SHA" >> $GITHUB_OUTPUT
SNUBA_IMAGE_SHA=$(docker buildx imagetools inspect $SNUBA_IMAGE --format "{{println .Manifest.Digest}}")
echo "SNUBA_IMAGE_SHA=$SNUBA_IMAGE_SHA" >> $GITHUB_OUTPUT
- name: Restore DB Volumes Cache
id: restore_cache
uses: actions/cache/restore@v4
with:
key: db-volumes-v4-${{ steps.cache_key.outputs.SENTRY_IMAGE_SHA }}-${{ steps.cache_key.outputs.SNUBA_IMAGE_SHA }}
restore-keys: |
db-volumes-v4-${{ steps.cache_key.outputs.SENTRY_IMAGE_SHA }}
db-volumes-v4-
path: |
/var/lib/docker/volumes/sentry-postgres/_data
/var/lib/docker/volumes/sentry-clickhouse/_data
- name: Install ${{ env.LATEST_TAG }}
run: ./install.sh
- name: Prepare Docker Volume Caching
run: |
# Set permissions for docker volumes so we can cache and restore
sudo chmod o+x /var/lib/docker
sudo chmod -R o+rx /var/lib/docker/volumes
- name: Save DB Volumes Cache
if: steps.restore_cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ steps.restore_cache.outputs.cache-primary-key }}
path: |
/var/lib/docker/volumes/sentry-postgres/_data
/var/lib/docker/volumes/sentry-clickhouse/_data
- name: Checkout current ref
uses: actions/checkout@v4
- name: Install current ref
run: ./install.sh
integration-test:
if: github.repository_owner == 'getsentry'
runs-on: ubuntu-22.04
name: integration test ${{ matrix.compose_version }} - customizations ${{ matrix.customizations }}
strategy:
fail-fast: false
matrix:
customizations: ["disabled", "enabled"]
compose_version: ["v2.19.0", "v2.26.0"]
include:
- compose_version: "v2.19.0"
compose_path: "/usr/local/lib/docker/cli-plugins"
- compose_version: "v2.26.0"
compose_path: "/usr/local/lib/docker/cli-plugins"
env:
COMPOSE_PROJECT_NAME: self-hosted-${{ strategy.job-index }}
REPORT_SELF_HOSTED_ISSUES: 0
SELF_HOSTED_TESTING_DSN: ${{ vars.SELF_HOSTED_TESTING_DSN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup dev environment
run: |
pip install -r requirements-dev.txt
echo "PY_COLORS=1" >> "$GITHUB_ENV"
### pytest-sentry configuration ###
if [ "$GITHUB_REPOSITORY" = "getsentry/self-hosted" ]; then
echo "PYTEST_SENTRY_DSN=$SELF_HOSTED_TESTING_DSN" >> $GITHUB_ENV
echo "PYTEST_SENTRY_TRACES_SAMPLE_RATE=0" >> $GITHUB_ENV
# This records failures on master to sentry in order to detect flakey tests, as it's
# expected that people have failing tests on their PRs
if [ "$GITHUB_REF" = "refs/heads/master" ]; then
echo "PYTEST_SENTRY_ALWAYS_REPORT=1" >> $GITHUB_ENV
fi
fi
- name: Get Compose
run: |
# Always remove `docker compose` support as that's the newer version
# and comes installed by default nowadays.
sudo rm -f "/usr/local/lib/docker/cli-plugins/docker-compose"
# Docker Compose v1 is installed here, remove it
sudo rm -f "/usr/local/bin/docker-compose"
sudo rm -f "${{ matrix.compose_path }}/docker-compose"
sudo mkdir -p "${{ matrix.compose_path }}"
sudo curl -L https://github.com/docker/compose/releases/download/${{ matrix.compose_version }}/docker-compose-`uname -s`-`uname -m` -o "${{ matrix.compose_path }}/docker-compose"
sudo chmod +x "${{ matrix.compose_path }}/docker-compose"
- name: Prepare Docker Volume Caching
id: cache_key
run: |
# Set permissions for docker volumes so we can cache and restore
sudo chmod o+x /var/lib/docker
sudo chmod -R o+rwx /var/lib/docker/volumes
source .env
SENTRY_IMAGE_SHA=$(docker buildx imagetools inspect $SENTRY_IMAGE --format "{{println .Manifest.Digest}}")
echo "SENTRY_IMAGE_SHA=$SENTRY_IMAGE_SHA" >> $GITHUB_OUTPUT
SNUBA_IMAGE_SHA=$(docker buildx imagetools inspect $SNUBA_IMAGE --format "{{println .Manifest.Digest}}")
echo "SNUBA_IMAGE_SHA=$SNUBA_IMAGE_SHA" >> $GITHUB_OUTPUT
- name: Restore DB Volumes Cache
id: restore_cache
uses: actions/cache/restore@v4
with:
key: db-volumes-v4-${{ steps.cache_key.outputs.SENTRY_IMAGE_SHA }}-${{ steps.cache_key.outputs.SNUBA_IMAGE_SHA }}
restore-keys: |
db-volumes-v4-${{ steps.cache_key.outputs.SENTRY_IMAGE_SHA }}
db-volumes-v4-
path: |
/var/lib/docker/volumes/sentry-postgres/_data
/var/lib/docker/volumes/sentry-clickhouse/_data
- name: Install self-hosted
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: ./install.sh
- name: Prepare Docker Volume Caching
run: |
# Set permissions for docker volumes so we can cache and restore
sudo chmod o+x /var/lib/docker
sudo chmod -R o+rx /var/lib/docker/volumes
- name: Save DB Volumes Cache
if: steps.restore_cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ steps.restore_cache.outputs.cache-primary-key }}
path: |
/var/lib/docker/volumes/sentry-postgres/_data
/var/lib/docker/volumes/sentry-clickhouse/_data
- name: Integration Test
run: |
docker compose up --wait
if [ "${{ matrix.compose_version }}" = "v2.19.0" ]; then
pytest --reruns 3 --cov --junitxml=junit.xml _integration-test/ --customizations=${{ matrix.customizations }}
else
pytest --cov --junitxml=junit.xml _integration-test/ --customizations=${{ matrix.customizations }}
fi
- name: Inspect failure
if: failure()
run: |
docker compose ps
docker compose logs
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: getsentry/self-hosted
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}