-
-
Notifications
You must be signed in to change notification settings - Fork 541
161 lines (139 loc) · 5.6 KB
/
Copy pathe2e_tests.yml
File metadata and controls
161 lines (139 loc) · 5.6 KB
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
name: e2e tests
on:
workflow_dispatch:
push:
branches:
- master
pull_request:
permissions:
contents: read
packages: read
concurrency:
group: e2e-tests-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
e2e-tests:
name: e2e tests (ruby ${{ matrix.ruby.flavor }}, ${{ matrix.adapter }})
runs-on: ubuntu-latest
timeout-minutes: 8
strategy:
fail-fast: false
matrix:
ruby:
- version: "3.4.9"
flavor: "3.4"
- version: "4.0.3"
flavor: "4.0"
adapter:
- async
- inline
- sidekiq
- resque
- delayed_job
- solid_queue
steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Read devcontainer version
id: devcontainer-version
run: echo "version=$(cat .devcontainer/VERSION)" >> $GITHUB_OUTPUT
- name: Set up `.env` file
run: |
cd .devcontainer
cp .env.example .env
echo "SENTRY_E2E_ACTIVE_JOB_ADAPTER=${{ matrix.adapter }}" >> .env
- name: Log in to GHCR
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull test container image
run: docker pull ghcr.io/getsentry/sentry-ruby-devcontainer-${{ matrix.ruby.flavor }}:${{ steps.devcontainer-version.outputs.version }}
- name: Prepare docker resources
run: |
bundle_volume="sentry-ruby-e2e-bundle-${{ github.run_id }}-${{ matrix.ruby.flavor }}-${{ matrix.adapter }}"
test_container="sentry-ruby-e2e-test-${{ github.run_id }}-${{ matrix.ruby.flavor }}-${{ matrix.adapter }}"
echo "E2E_BUNDLE_VOLUME=${bundle_volume}" >> "$GITHUB_ENV"
echo "E2E_TEST_CONTAINER=${test_container}" >> "$GITHUB_ENV"
docker volume create "${bundle_volume}"
- name: Restore node_modules cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: spec/apps/svelte-mini/node_modules
key: ${{ runner.os }}-${{ runner.arch }}-node-modules-${{ hashFiles('spec/apps/svelte-mini/package-lock.json') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-node-modules-
- name: Set up test container
run: |
docker run --rm \
--env-file .devcontainer/.env \
--env BUNDLE_PATH=/home/sentry/bundle \
--env MISE_RUBY_VERSION=${{ matrix.ruby.version }} \
--volume "${PWD}:/workspaces/sentry-ruby" \
--volume "${E2E_BUNDLE_VOLUME}:/home/sentry/bundle" \
"ghcr.io/getsentry/sentry-ruby-devcontainer-${{ matrix.ruby.flavor }}:${{ steps.devcontainer-version.outputs.version }}" \
.devcontainer/ci-run .devcontainer/setup --only .,spec/apps/rails-mini
- name: Start test services
run: |
docker run -d \
--name "${E2E_TEST_CONTAINER}" \
--publish 4000:4000 \
--publish 4001:4001 \
--env-file .devcontainer/.env \
--env BUNDLE_PATH=/home/sentry/bundle \
--env MISE_RUBY_VERSION=${{ matrix.ruby.version }} \
--volume "${PWD}:/workspaces/sentry-ruby" \
--volume "${E2E_BUNDLE_VOLUME}:/home/sentry/bundle" \
"ghcr.io/getsentry/sentry-ruby-devcontainer-${{ matrix.ruby.flavor }}:${{ steps.devcontainer-version.outputs.version }}" \
.devcontainer/ci-run mise run e2e:serve
# Poll from the runner host, not a container action: the apps' ports are
# published to the host (`--publish`), so `localhost` here reaches them,
# whereas a Docker container action's `localhost` is its own container.
- name: "Wait for rails-mini app to be ready"
run: |
for _ in $(seq 1 180); do
if curl -sf http://localhost:4000/health >/dev/null; then
echo "rails-mini is ready"
exit 0
fi
sleep 1
done
echo "❌ rails-mini did not become ready in time" >&2
docker logs "${E2E_TEST_CONTAINER}" 2>&1 | tail -n 200 || true
exit 1
- name: "Wait for svelte-mini app to be ready"
run: |
for _ in $(seq 1 180); do
if curl -sf http://localhost:4001/health >/dev/null; then
echo "svelte-mini is ready"
exit 0
fi
sleep 1
done
echo "❌ svelte-mini did not become ready in time" >&2
docker logs "${E2E_TEST_CONTAINER}" 2>&1 | tail -n 200 || true
exit 1
- name: Run e2e tests via sentry-test
run: |
docker exec "${E2E_TEST_CONTAINER}" bundle exec rake
- name: Dump service logs
if: failure()
run: |
echo "===== docker ps -a ====="
docker ps -a
echo "===== test container logs ====="
docker logs "${E2E_TEST_CONTAINER}" 2>&1 || true
- name: Stop e2e services
if: always()
run: |
docker rm -f "${E2E_TEST_CONTAINER}" 2>/dev/null || true
docker volume rm "${E2E_BUNDLE_VOLUME}" 2>/dev/null || true
- name: Upload test artifacts
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: e2e-test-logs-ruby-${{ matrix.ruby.version }}-${{ matrix.adapter }}
path: |
log/sentry_debug_events.log
retention-days: 7