-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathaction.yaml
160 lines (144 loc) · 6.67 KB
/
action.yaml
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
name: "Sentry self-hosted end-to-end tests"
inputs:
project_name:
required: false
description: "e.g. snuba, sentry, relay, self-hosted"
image_url:
required: false
description: "The URL to the built relay, snuba, sentry image to test against."
CODECOV_TOKEN:
required: false
description: "The Codecov token to upload coverage."
runs:
using: "composite"
steps:
- name: Configure to use the test image
if: inputs.project_name && inputs.image_url
shell: bash
run: |
image_var=$(echo ${{ inputs.project_name }}_IMAGE | tr '[:lower:]' '[:upper:]')
echo "${image_var}=${{ inputs.image_url }}" >> ${{ github.action_path }}/.env
- name: Setup dev environment
shell: bash
run: |
cd ${{ github.action_path }}
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
uses: getsentry/self-hosted/get-compose-action@master
- name: Compute Docker Volume Cache Keys
id: cache_key
shell: bash
run: |
source ${{ github.action_path }}/.env
# See https://explainshell.com/explain?cmd=ls%20-Rv1rpq
# for that long `ls` command
SENTRY_MIGRATIONS_MD5=$(docker run --rm --entrypoint bash $SENTRY_IMAGE -c '{ ls -Rv1rpq src/sentry/**/migrations/*; sed -n "/KAFKA_TOPIC_TO_CLUSTER/,/}/p" src/sentry/conf/server.py; }' | md5sum | cut -d ' ' -f 1)
echo "SENTRY_MIGRATIONS_MD5=$SENTRY_MIGRATIONS_MD5" >> $GITHUB_OUTPUT
SNUBA_MIGRATIONS_MD5=$(docker run --rm --entrypoint bash $SNUBA_IMAGE -c '{ ls -Rv1rpq snuba/snuba_migrations/**/*.py; sed -n "/^class Topic(Enum):/,/\\n\\n/p" snuba/utils/streams/topics.py; }' | md5sum | cut -d ' ' -f 1)
echo "SNUBA_MIGRATIONS_MD5=$SNUBA_MIGRATIONS_MD5" >> $GITHUB_OUTPUT
- name: Restore Sentry Volume Cache
id: restore_cache_sentry
uses: BYK/docker-volume-cache-action/restore@be89365902126f508dcae387a32ec3712df6b1cd
with:
key: db-volumes-sentry-v1-${{ steps.cache_key.outputs.SENTRY_MIGRATIONS_MD5 }}
restore-keys: |
db-volumes-sentry-v1-
volumes: |
sentry-postgres
- name: Restore Snuba Volume Cache
id: restore_cache_snuba
uses: BYK/docker-volume-cache-action/restore@be89365902126f508dcae387a32ec3712df6b1cd
with:
key: db-volumes-snuba-v1-${{ steps.cache_key.outputs.SNUBA_MIGRATIONS_MD5 }}
restore-keys: |
db-volumes-snuba-v1-
volumes: |
sentry-clickhouse
- name: Restore Kafka Volume Cache
id: restore_cache_kafka
uses: BYK/docker-volume-cache-action/restore@be89365902126f508dcae387a32ec3712df6b1cd
with:
key: db-volumes-kafka-v1-${{ steps.cache_key.outputs.SENTRY_MIGRATIONS_MD5 }}-${{ steps.cache_key.outputs.SNUBA_MIGRATIONS_MD5 }}
restore-keys: |
db-volumes-kafka-v1-${{ steps.cache_key.outputs.SENTRY_MIGRATIONS_MD5 }}-${{ steps.cache_key.outputs.SNUBA_MIGRATIONS_MD5 }}
db-volumes-kafka-v1-${{ steps.cache_key.outputs.SENTRY_MIGRATIONS_MD5 }}-
db-volumes-kafka-v1-
volumes: |
sentry-kafka
- name: Install self-hosted
env:
# Note that cache keys for Sentry and Snuba have their respective Kafka configs built into them
# and the Kafka volume cache is comprises both keys. This way we can omit the Kafka cache hit
# in here to still avoid running Sentry or Snuba migrations if only one of their Kafka config has
# changed. Heats up your head a bit but if you think about it, it makes sense.
SKIP_SENTRY_MIGRATIONS: ${{ steps.restore_cache_sentry.outputs.cache-hit == 'true' && '1' || '' }}
SKIP_SNUBA_MIGRATIONS: ${{ steps.restore_cache_snuba.outputs.cache-hit == 'true' && '1' || '' }}
shell: bash
run: |
cd ${{ github.action_path }}
# Add some customizations to test that path
cat <<EOT >> sentry/enhance-image.sh
#!/bin/bash
touch /created-by-enhance-image
apt-get update
apt-get install -y gcc libsasl2-dev python-dev-is-python3 libldap2-dev libssl-dev
EOT
chmod 755 sentry/enhance-image.sh
echo "python-ldap" > sentry/requirements.txt
./install.sh --no-report-self-hosted-issues --skip-commit-check
- name: Save Sentry Volume Cache
if: steps.restore_cache_sentry.outputs.cache-hit != 'true'
uses: BYK/docker-volume-cache-action/save@be89365902126f508dcae387a32ec3712df6b1cd
with:
key: ${{ steps.restore_cache_sentry.outputs.cache-primary-key }}
volumes: |
sentry-postgres
- name: Save Snuba Volume Cache
if: steps.restore_cache_snuba.outputs.cache-hit != 'true'
uses: BYK/docker-volume-cache-action/save@be89365902126f508dcae387a32ec3712df6b1cd
with:
key: ${{ steps.restore_cache_snuba.outputs.cache-primary-key }}
volumes: |
sentry-clickhouse
- name: Save Kafka Volume Cache
if: steps.restore_cache_kafka.outputs.cache-hit != 'true'
uses: BYK/docker-volume-cache-action/save@be89365902126f508dcae387a32ec3712df6b1cd
with:
key: ${{ steps.restore_cache_kafka.outputs.cache-primary-key }}
volumes: |
sentry-kafka
- name: Integration Test
shell: bash
run: |
sudo chown root /usr/bin/rsync && sudo chmod u+s /usr/bin/rsync
rsync -aW --super --numeric-ids --no-compress --mkpath \
/var/lib/docker/volumes/sentry-postgres \
/var/lib/docker/volumes/sentry-clickhouse \
/var/lib/docker/volumes/sentry-kafka \
"$RUNNER_TEMP/volumes/"
cd ${{ github.action_path }}
pytest -x --cov --junitxml=junit.xml _integration-test/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
if: inputs.CODECOV_TOKEN
with:
directory: ${{ github.action_path }}
token: ${{ inputs.CODECOV_TOKEN }}
slug: getsentry/self-hosted
- name: Upload test results to Codecov
if: inputs.CODECOV_TOKEN && !cancelled()
uses: codecov/test-results-action@v1
with:
directory: ${{ github.action_path }}
token: ${{ inputs.CODECOV_TOKEN }}