Skip to content

Commit 8c1653d

Browse files
authored
ci: Skip DB ops during install completely on cache hit (#3496)
Follow up to #3488 A new record: 2m 8s for installing self-hosted: ![image](https://github.com/user-attachments/assets/7cc6409d-5388-49ba-ad87-b7a1e99c9acc)
1 parent 8653327 commit 8c1653d

File tree

2 files changed

+54
-26
lines changed

2 files changed

+54
-26
lines changed

.github/workflows/test.yml

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,24 @@ jobs:
9494
path: |
9595
/var/lib/docker/volumes/sentry-postgres/_data
9696
/var/lib/docker/volumes/sentry-clickhouse/_data
97+
/var/lib/docker/volumes/sentry-kafka/_data
9798
9899
- name: Install ${{ env.LATEST_TAG }}
99-
run: ./install.sh
100+
env:
101+
SKIP_DB_MIGRATIONS: ${{ steps.restore_cache.outputs.cache-hit == 'true' && '1' || '' }}
102+
run: |
103+
# This is for the cache restore on Kafka to work in older releases
104+
docker run --rm -v "sentry-kafka:/data" busybox chown -R 1000:1000 /data
105+
./install.sh
100106
101107
- name: Prepare Docker Volume Caching
102108
run: |
103109
# Set permissions for docker volumes so we can cache and restore
104110
sudo chmod o+x /var/lib/docker
105111
sudo chmod -R o+rx /var/lib/docker/volumes
112+
# Set tar ownership for it to be able to read
113+
# From: https://github.com/actions/toolkit/issues/946#issuecomment-1726311681
114+
sudo chown root /usr/bin/tar && sudo chmod u+s /usr/bin/tar
106115
107116
- name: Save DB Volumes Cache
108117
if: steps.restore_cache.outputs.cache-hit != 'true'
@@ -112,12 +121,22 @@ jobs:
112121
path: |
113122
/var/lib/docker/volumes/sentry-postgres/_data
114123
/var/lib/docker/volumes/sentry-clickhouse/_data
124+
/var/lib/docker/volumes/sentry-kafka/_data
115125
116126
- name: Checkout current ref
117127
uses: actions/checkout@v4
118128

119129
- name: Install current ref
120-
run: ./install.sh
130+
run: |
131+
# This is for the cache restore on Kafka to work in older releases
132+
docker run --rm -v "sentry-kafka:/data" busybox chown -R 1000:1000 /data
133+
./install.sh
134+
135+
- name: Inspect failure
136+
if: failure()
137+
run: |
138+
docker compose ps
139+
docker compose logs
121140
122141
integration-test:
123142
if: github.repository_owner == 'getsentry'
@@ -192,19 +211,24 @@ jobs:
192211
path: |
193212
/var/lib/docker/volumes/sentry-postgres/_data
194213
/var/lib/docker/volumes/sentry-clickhouse/_data
214+
/var/lib/docker/volumes/sentry-kafka/_data
195215
196216
- name: Install self-hosted
197-
uses: nick-fields/retry@v3
198-
with:
199-
timeout_minutes: 10
200-
max_attempts: 3
201-
command: ./install.sh
217+
env:
218+
SKIP_DB_MIGRATIONS: ${{ steps.restore_cache.outputs.cache-hit == 'true' && '1' || '' }}
219+
run: |
220+
# This is for the cache restore on Kafka to work in older releases
221+
docker run --rm -v "sentry-kafka:/data" busybox chown -R 1000:1000 /data
222+
./install.sh
202223
203224
- name: Prepare Docker Volume Caching
204225
run: |
205226
# Set permissions for docker volumes so we can cache and restore
206227
sudo chmod o+x /var/lib/docker
207228
sudo chmod -R o+rx /var/lib/docker/volumes
229+
# Set tar ownership for it to be able to read
230+
# From: https://github.com/actions/toolkit/issues/946#issuecomment-1726311681
231+
sudo chown root /usr/bin/tar && sudo chmod u+s /usr/bin/tar
208232
209233
- name: Save DB Volumes Cache
210234
if: steps.restore_cache.outputs.cache-hit != 'true'
@@ -214,6 +238,7 @@ jobs:
214238
path: |
215239
/var/lib/docker/volumes/sentry-postgres/_data
216240
/var/lib/docker/volumes/sentry-clickhouse/_data
241+
/var/lib/docker/volumes/sentry-kafka/_data
217242
218243
- name: Integration Test
219244
run: |
Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
11
echo "${_group}Setting up / migrating database ..."
22

3-
# Fixes https://github.com/getsentry/self-hosted/issues/2758, where a migration fails due to indexing issue
4-
$dc up --wait postgres
3+
if [[ -z "${SKIP_DB_MIGRATIONS:-}" ]]; then
4+
# Fixes https://github.com/getsentry/self-hosted/issues/2758, where a migration fails due to indexing issue
5+
$dc up --wait postgres
56

6-
os=$($dc exec postgres cat /etc/os-release | grep 'ID=debian')
7-
if [[ -z $os ]]; then
8-
echo "Postgres image debian check failed, exiting..."
9-
exit 1
10-
fi
7+
os=$($dc exec postgres cat /etc/os-release | grep 'ID=debian')
8+
if [[ -z $os ]]; then
9+
echo "Postgres image debian check failed, exiting..."
10+
exit 1
11+
fi
1112

12-
# Using django ORM to provide broader support for users with external databases
13-
$dcr web shell -c "
13+
# Using django ORM to provide broader support for users with external databases
14+
$dcr web shell -c "
1415
from django.db import connection
1516
1617
with connection.cursor() as cursor:
1718
cursor.execute('ALTER TABLE IF EXISTS sentry_groupedmessage DROP CONSTRAINT IF EXISTS sentry_groupedmessage_project_id_id_515aaa7e_uniq;')
1819
cursor.execute('DROP INDEX IF EXISTS sentry_groupedmessage_project_id_id_515aaa7e_uniq;')
1920
"
2021

21-
if [[ -n "${CI:-}" || "${SKIP_USER_CREATION:-0}" == 1 ]]; then
22-
$dcr web upgrade --noinput --create-kafka-topics
23-
echo ""
24-
echo "Did not prompt for user creation. Run the following command to create one"
25-
echo "yourself (recommended):"
26-
echo ""
27-
echo " $dc_base run --rm web createuser"
28-
echo ""
22+
if [[ -n "${CI:-}" || "${SKIP_USER_CREATION:-0}" == 1 ]]; then
23+
$dcr web upgrade --noinput --create-kafka-topics
24+
echo ""
25+
echo "Did not prompt for user creation. Run the following command to create one"
26+
echo "yourself (recommended):"
27+
echo ""
28+
echo " $dc_base run --rm web createuser"
29+
echo ""
30+
else
31+
$dcr web upgrade --create-kafka-topics
32+
fi
2933
else
30-
$dcr web upgrade --create-kafka-topics
34+
echo "Skipped DB migrations due to SKIP_DB_MIGRATIONS=$SKIP_DB_MIGRATIONS"
3135
fi
32-
3336
echo "${_endgroup}"

0 commit comments

Comments
 (0)