Skip to content

Commit 63334cb

Browse files
authored
ci: Move e2e test action into the repo (#3519)
This is an initial transitionary patch before landing #3516. Once we land this, we will update users of the old action to use this one and remove that repo. Then land #3516 safely. Great thing is, with this patch and the subsequent update to getsentry/action-self-hosted-e2e-tests to use this one, all the repos would be using the Docker Volume caching we introduced in #3488.
1 parent cb9e0ce commit 63334cb

File tree

2 files changed

+153
-113
lines changed

2 files changed

+153
-113
lines changed

Diff for: .github/workflows/test.yml

+4-113
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,6 @@ defaults:
1919
run:
2020
shell: bash
2121
jobs:
22-
e2e-test:
23-
if: github.repository_owner == 'getsentry'
24-
runs-on: ubuntu-22.04
25-
name: "Sentry self-hosted end-to-end tests"
26-
steps:
27-
- name: Checkout
28-
uses: actions/checkout@v4
29-
with:
30-
path: self-hosted
31-
32-
- name: End to end tests
33-
uses: getsentry/action-self-hosted-e2e-tests@main
34-
with:
35-
project_name: self-hosted
36-
3722
unit-test:
3823
if: github.repository_owner == 'getsentry'
3924
runs-on: ubuntu-22.04
@@ -107,6 +92,7 @@ jobs:
10792
- name: Prepare Docker Volume Caching
10893
run: |
10994
# Set permissions for docker volumes so we can cache and restore
95+
# We need these for the backup/restore test snapshotting too
11096
sudo chmod o+x /var/lib/docker
11197
sudo chmod -R o+rx /var/lib/docker/volumes
11298
# Set tar ownership for it to be able to read
@@ -149,108 +135,13 @@ jobs:
149135
- name: Checkout
150136
uses: actions/checkout@v4
151137

152-
- name: Setup dev environment
153-
run: |
154-
pip install -r requirements-dev.txt
155-
echo "PY_COLORS=1" >> "$GITHUB_ENV"
156-
### pytest-sentry configuration ###
157-
if [ "$GITHUB_REPOSITORY" = "getsentry/self-hosted" ]; then
158-
echo "PYTEST_SENTRY_DSN=$SELF_HOSTED_TESTING_DSN" >> $GITHUB_ENV
159-
echo "PYTEST_SENTRY_TRACES_SAMPLE_RATE=0" >> $GITHUB_ENV
160-
161-
# This records failures on master to sentry in order to detect flakey tests, as it's
162-
# expected that people have failing tests on their PRs
163-
if [ "$GITHUB_REF" = "refs/heads/master" ]; then
164-
echo "PYTEST_SENTRY_ALWAYS_REPORT=1" >> $GITHUB_ENV
165-
fi
166-
fi
167-
168-
- name: Get Compose
169-
env:
170-
COMPOSE_PATH: /usr/local/lib/docker/cli-plugins
171-
COMPOSE_VERSION: 'v2.26.0'
172-
run: |
173-
# Always remove `docker compose` support as that's the newer version
174-
# and comes installed by default nowadays.
175-
sudo rm -f "/usr/local/lib/docker/cli-plugins/docker-compose"
176-
# Docker Compose v1 is installed here, remove it
177-
sudo rm -f "/usr/local/bin/docker-compose"
178-
sudo rm -f "${{ env.COMPOSE_PATH }}/docker-compose"
179-
sudo mkdir -p "${{ env.COMPOSE_PATH }}"
180-
sudo curl -L https://github.com/docker/compose/releases/download/${{ env.COMPOSE_VERSION }}/docker-compose-`uname -s`-`uname -m` -o "${{ env.COMPOSE_PATH }}/docker-compose"
181-
sudo chmod +x "${{ env.COMPOSE_PATH }}/docker-compose"
182-
183-
- name: Prepare Docker Volume Caching
184-
id: cache_key
185-
run: |
186-
# Set permissions for docker volumes so we can cache and restore
187-
sudo chmod o+x /var/lib/docker
188-
sudo chmod -R o+rwx /var/lib/docker/volumes
189-
source .env
190-
SENTRY_IMAGE_SHA=$(docker buildx imagetools inspect $SENTRY_IMAGE --format "{{println .Manifest.Digest}}")
191-
echo "SENTRY_IMAGE_SHA=$SENTRY_IMAGE_SHA" >> $GITHUB_OUTPUT
192-
SNUBA_IMAGE_SHA=$(docker buildx imagetools inspect $SNUBA_IMAGE --format "{{println .Manifest.Digest}}")
193-
echo "SNUBA_IMAGE_SHA=$SNUBA_IMAGE_SHA" >> $GITHUB_OUTPUT
194-
195-
- name: Restore DB Volumes Cache
196-
id: restore_cache
197-
uses: actions/cache/restore@v4
198-
with:
199-
key: db-volumes-v4-${{ steps.cache_key.outputs.SENTRY_IMAGE_SHA }}-${{ steps.cache_key.outputs.SNUBA_IMAGE_SHA }}
200-
restore-keys: |
201-
db-volumes-v4-${{ steps.cache_key.outputs.SENTRY_IMAGE_SHA }}
202-
db-volumes-v4-
203-
path: |
204-
/var/lib/docker/volumes/sentry-postgres/_data
205-
/var/lib/docker/volumes/sentry-clickhouse/_data
206-
/var/lib/docker/volumes/sentry-kafka/_data
207-
208-
- name: Install self-hosted
209-
env:
210-
SKIP_DB_MIGRATIONS: ${{ steps.restore_cache.outputs.cache-hit == 'true' && '1' || '' }}
211-
run: |
212-
# This is for the cache restore on Kafka to work in older releases
213-
docker run --rm -v "sentry-kafka:/data" busybox chown -R 1000:1000 /data
214-
./install.sh
215-
216-
- name: Prepare Docker Volume Caching
217-
run: |
218-
# Set permissions for docker volumes so we can cache and restore
219-
sudo chmod o+x /var/lib/docker
220-
sudo chmod -R o+rx /var/lib/docker/volumes
221-
# Set tar ownership for it to be able to read
222-
# From: https://github.com/actions/toolkit/issues/946#issuecomment-1726311681
223-
sudo chown root /usr/bin/tar && sudo chmod u+s /usr/bin/tar
224-
225-
- name: Save DB Volumes Cache
226-
if: steps.restore_cache.outputs.cache-hit != 'true'
227-
uses: actions/cache/save@v4
138+
- name: Use action from local checkout
139+
uses: './'
228140
with:
229-
key: ${{ steps.restore_cache.outputs.cache-primary-key }}
230-
path: |
231-
/var/lib/docker/volumes/sentry-postgres/_data
232-
/var/lib/docker/volumes/sentry-clickhouse/_data
233-
/var/lib/docker/volumes/sentry-kafka/_data
234-
235-
- name: Integration Test
236-
run: |
237-
docker compose up --wait
238-
pytest --cov --junitxml=junit.xml _integration-test/ --customizations=enabled
141+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
239142

240143
- name: Inspect failure
241144
if: failure()
242145
run: |
243146
docker compose ps
244147
docker compose logs
245-
246-
- name: Upload coverage to Codecov
247-
uses: codecov/codecov-action@v5
248-
with:
249-
token: ${{ secrets.CODECOV_TOKEN }}
250-
slug: getsentry/self-hosted
251-
252-
- name: Upload test results to Codecov
253-
if: ${{ !cancelled() }}
254-
uses: codecov/test-results-action@v1
255-
with:
256-
token: ${{ secrets.CODECOV_TOKEN }}

Diff for: action.yaml

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: "Sentry self-hosted end-to-end tests"
2+
inputs:
3+
project_name:
4+
required: false
5+
description: "e.g. snuba, sentry, relay, self-hosted"
6+
image_url:
7+
required: false
8+
description: "The URL to the built relay, snuba, sentry image to test against."
9+
CODECOV_TOKEN:
10+
required: false
11+
description: "The Codecov token to upload coverage."
12+
13+
runs:
14+
using: "composite"
15+
steps:
16+
- name: Go into self-hosted directory
17+
shell: bash
18+
run: cd ${{ github.action_path }}
19+
20+
- name: Configure to use the test image
21+
if: inputs.project_name && inputs.image_url
22+
shell: bash
23+
run: |
24+
image_var=$(echo ${{ inputs.project_name }}_IMAGE | tr '[:lower:]' '[:upper:]')
25+
echo "${image_var}=${{ inputs.image_url }}" >> $GITHUB_ENV
26+
27+
- name: Setup dev environment
28+
shell: bash
29+
run: |
30+
pip install -r requirements-dev.txt
31+
echo "PY_COLORS=1" >> "$GITHUB_ENV"
32+
### pytest-sentry configuration ###
33+
if [ "$GITHUB_REPOSITORY" = "getsentry/self-hosted" ]; then
34+
echo "PYTEST_SENTRY_DSN=$SELF_HOSTED_TESTING_DSN" >> $GITHUB_ENV
35+
echo "PYTEST_SENTRY_TRACES_SAMPLE_RATE=0" >> $GITHUB_ENV
36+
37+
# This records failures on master to sentry in order to detect flakey tests, as it's
38+
# expected that people have failing tests on their PRs
39+
if [ "$GITHUB_REF" = "refs/heads/master" ]; then
40+
echo "PYTEST_SENTRY_ALWAYS_REPORT=1" >> $GITHUB_ENV
41+
fi
42+
fi
43+
44+
- name: Get Compose
45+
env:
46+
COMPOSE_PATH: /usr/local/lib/docker/cli-plugins
47+
COMPOSE_VERSION: "v2.26.0"
48+
shell: bash
49+
run: |
50+
# Always remove `docker compose` support as that's the newer version
51+
# and comes installed by default nowadays.
52+
sudo rm -f "/usr/local/lib/docker/cli-plugins/docker-compose"
53+
# Docker Compose v1 is installed here, remove it
54+
sudo rm -f "/usr/local/bin/docker-compose"
55+
sudo rm -f "${{ env.COMPOSE_PATH }}/docker-compose"
56+
sudo mkdir -p "${{ env.COMPOSE_PATH }}"
57+
sudo curl -L https://github.com/docker/compose/releases/download/${{ env.COMPOSE_VERSION }}/docker-compose-`uname -s`-`uname -m` -o "${{ env.COMPOSE_PATH }}/docker-compose"
58+
sudo chmod +x "${{ env.COMPOSE_PATH }}/docker-compose"
59+
60+
- name: Prepare Docker Volume Caching
61+
id: cache_key
62+
shell: bash
63+
run: |
64+
# Set permissions for docker volumes so we can cache and restore
65+
sudo chmod o+x /var/lib/docker
66+
sudo chmod -R o+rwx /var/lib/docker/volumes
67+
source .env
68+
SENTRY_IMAGE_SHA=$(docker buildx imagetools inspect $SENTRY_IMAGE --format "{{println .Manifest.Digest}}")
69+
echo "SENTRY_IMAGE_SHA=$SENTRY_IMAGE_SHA" >> $GITHUB_OUTPUT
70+
SNUBA_IMAGE_SHA=$(docker buildx imagetools inspect $SNUBA_IMAGE --format "{{println .Manifest.Digest}}")
71+
echo "SNUBA_IMAGE_SHA=$SNUBA_IMAGE_SHA" >> $GITHUB_OUTPUT
72+
73+
- name: Restore DB Volumes Cache
74+
id: restore_cache
75+
uses: actions/cache/restore@v4
76+
with:
77+
key: db-volumes-v4-${{ steps.cache_key.outputs.SENTRY_IMAGE_SHA }}-${{ steps.cache_key.outputs.SNUBA_IMAGE_SHA }}
78+
restore-keys: |
79+
db-volumes-v4-${{ steps.cache_key.outputs.SENTRY_IMAGE_SHA }}
80+
db-volumes-v4-
81+
path: |
82+
/var/lib/docker/volumes/sentry-postgres/_data
83+
/var/lib/docker/volumes/sentry-clickhouse/_data
84+
/var/lib/docker/volumes/sentry-kafka/_data
85+
86+
- name: Install self-hosted
87+
env:
88+
SKIP_DB_MIGRATIONS: ${{ steps.restore_cache.outputs.cache-hit == 'true' && '1' || '' }}
89+
shell: bash
90+
run: |
91+
# This is for the cache restore on Kafka to work in older releases
92+
docker run --rm -v "sentry-kafka:/data" busybox chown -R 1000:1000 /data
93+
# Add some customizations to test that path
94+
cat <<EOT >> sentry/enhance-image.sh
95+
#!/bin/bash
96+
touch /created-by-enhance-image
97+
apt-get update
98+
apt-get install -y gcc libsasl2-dev python-dev-is-python3 libldap2-dev libssl-dev
99+
EOT
100+
chmod 755 sentry/enhance-image.sh
101+
echo "python-ldap" > sentry/requirements.txt
102+
103+
./install.sh --no-report-self-hosted-issues --skip-commit-check
104+
105+
- name: Prepare Docker Volume Caching
106+
shell: bash
107+
run: |
108+
# Set permissions for docker volumes so we can cache and restore
109+
# We need these for the backup/restore test snapshotting too
110+
sudo chmod o+x /var/lib/docker
111+
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
115+
sudo chown root /usr/bin/rsync && sudo chmod u+s /usr/bin/rsync
116+
117+
- name: Save DB Volumes Cache
118+
if: steps.restore_cache.outputs.cache-hit != 'true'
119+
uses: actions/cache/save@v4
120+
with:
121+
key: ${{ steps.restore_cache.outputs.cache-primary-key }}
122+
path: |
123+
/var/lib/docker/volumes/sentry-postgres/_data
124+
/var/lib/docker/volumes/sentry-clickhouse/_data
125+
/var/lib/docker/volumes/sentry-kafka/_data
126+
127+
- name: Integration Test
128+
shell: bash
129+
run: |
130+
rsync -aW --no-compress --mkpath \
131+
/var/lib/docker/volumes/sentry-postgres \
132+
/var/lib/docker/volumes/sentry-clickhouse \
133+
/var/lib/docker/volumes/sentry-kafka \
134+
"$RUNNER_TEMP/volumes/"
135+
docker compose up --wait
136+
TEST_CUSTOMIZATIONS=enabled pytest -x --cov --junitxml=junit.xml _integration-test/
137+
138+
- name: Upload coverage to Codecov
139+
uses: codecov/codecov-action@v5
140+
if: inputs.CODECOV_TOKEN
141+
with:
142+
token: ${{ inputs.CODECOV_TOKEN }}
143+
slug: getsentry/self-hosted
144+
145+
- name: Upload test results to Codecov
146+
if: inputs.CODECOV_TOKEN && !cancelled()
147+
uses: codecov/test-results-action@v1
148+
with:
149+
token: ${{ inputs.CODECOV_TOKEN }}

0 commit comments

Comments
 (0)