Skip to content

Commit 44ba71c

Browse files
committed
try local action
1 parent b7925cd commit 44ba71c

File tree

2 files changed

+146
-131
lines changed

2 files changed

+146
-131
lines changed

.github/workflows/test.yml

+2-131
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
@@ -150,125 +135,11 @@ jobs:
150135
- name: Checkout
151136
uses: actions/checkout@v4
152137

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

258141
- name: Inspect failure
259142
if: failure()
260143
run: |
261144
docker compose ps
262145
docker compose logs
263-
264-
- name: Upload coverage to Codecov
265-
uses: codecov/codecov-action@v5
266-
with:
267-
token: ${{ secrets.CODECOV_TOKEN }}
268-
slug: getsentry/self-hosted
269-
270-
- name: Upload test results to Codecov
271-
if: ${{ !cancelled() }}
272-
uses: codecov/test-results-action@v1
273-
with:
274-
token: ${{ secrets.CODECOV_TOKEN }}

action.yaml

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

0 commit comments

Comments
 (0)