Skip to content

Commit 97a543a

Browse files
committed
Add e2e CI workflow
1 parent 14122af commit 97a543a

7 files changed

Lines changed: 216 additions & 50 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -40,37 +40,13 @@ WORKDIR /workspace/sentry
4040
RUN chown -R sentry:sentry /workspace/sentry
4141

4242
ARG VERSION
43-
ARG GEM_HOME="/workspace/gems/${VERSION}"
44-
45-
RUN mkdir /workspace/gems && chown -R sentry:sentry /workspace/gems
43+
ARG GEM_HOME="/workspace/sentry/vendor/gems/${VERSION}"
4644

4745
ENV LANG=C.UTF-8 \
4846
BUNDLE_JOBS=4 \
4947
BUNDLE_RETRY=3 \
50-
GEM_HOME=/workspace/gems/${VERSION} \
48+
GEM_HOME=/workspace/sentry/vendor/gems/${VERSION} \
5149
PATH=$PATH:${GEM_HOME}/bin \
5250
REDIS_HOST=redis
5351

54-
FROM build AS dev
55-
5652
USER sentry
57-
58-
COPY .devcontainer/entrypoint.sh /workspace/entrypoint.sh
59-
60-
ENTRYPOINT ["/workspace/entrypoint.sh"]
61-
62-
FROM build AS test
63-
64-
COPY . .
65-
66-
RUN chown -R sentry:sentry .
67-
68-
USER sentry
69-
70-
RUN gem install foreman && \
71-
bundle install && \
72-
cd spec/apps/rails-mini && \
73-
bundle install
74-
75-
RUN cd spec/apps/svelte-mini && \
76-
npm install

.devcontainer/docker-compose.yml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ services:
33
build:
44
context: ..
55
dockerfile: .devcontainer/Dockerfile
6-
target: test
76
args:
87
IMAGE: ${IMAGE}
98
VERSION: ${VERSION}
@@ -13,39 +12,35 @@ services:
1312
SENTRY_E2E_SVELTE_APP_URL: ${SENTRY_E2E_SVELTE_APP_URL}
1413
volumes:
1514
- ..:/workspace/sentry:cached
16-
- sentry_e2e_logs:/workspace/sentry/log
1715
working_dir: /workspace/sentry
1816
environment:
1917
- REDIS_URL=${REDIS_URL:-redis://redis:6379/0}
2018
env_file: [".env"]
2119

2220
sentry-dev:
2321
<<: *sentry-build
24-
command: sleep infinity
22+
entrypoint: ".devcontainer/run --service dev"
23+
command: "sleep infinity"
2524
depends_on:
2625
- redis
2726

2827
sentry-test:
2928
<<: *sentry-build
29+
entrypoint: ".devcontainer/run --service test"
3030
depends_on:
31-
- redis
3231
- sentry-test-services
3332

3433
sentry-test-services:
3534
<<: *sentry-build
35+
entrypoint: ".devcontainer/run --service test-services"
3636
command: "foreman start"
3737
ports:
38-
- ${SENTRY_E2E_RAILS_APP_PORT}
39-
- ${SENTRY_E2E_SVELTE_APP_PORT}
38+
- "${SENTRY_E2E_RAILS_APP_PORT}:4000"
39+
- "${SENTRY_E2E_SVELTE_APP_PORT}:4001"
4040

4141
redis:
4242
image: redis:latest
4343
environment:
4444
- ALLOW_EMPTY_PASSWORD=yes
4545
ports:
4646
- "6379:6379"
47-
48-
volumes:
49-
sentry_e2e_logs:
50-
sentry_ruby_gems:
51-
sentry_node_modules:

.devcontainer/run

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
cd /workspace/sentry
6+
7+
sudo mkdir -p vendor/gems
8+
sudo chown -R sentry:sentry vendor/gems
9+
10+
git config --global --add safe.directory /workspace/sentry/vendor/gems
11+
git config --global --add safe.directory /workspace/sentry
12+
13+
sudo chown -R sentry:sentry .
14+
15+
run_service_setup() {
16+
local service="$1"
17+
18+
echo "🚀 Running setup for service: $service"
19+
20+
case "$service" in
21+
"dev")
22+
if ! .devcontainer/setup --with-foreman --only-bundle; then
23+
echo "❌ Setup failed for service: $service"
24+
exit 1
25+
fi
26+
;;
27+
"test")
28+
if ! .devcontainer/setup --with-foreman --only-bundle --only .; then
29+
echo "❌ Setup failed for service: $service"
30+
exit 1
31+
fi
32+
;;
33+
"test-services")
34+
if ! .devcontainer/setup --with-foreman --only .,spec/apps/rails-mini; then
35+
echo "❌ Setup failed for service: $service"
36+
exit 1
37+
fi
38+
;;
39+
*)
40+
echo "❌ Unknown service: $service"
41+
echo "Available services: dev, test, test-services"
42+
exit 1
43+
;;
44+
esac
45+
46+
echo "✅ Setup completed for service: $service"
47+
}
48+
49+
# Parse arguments
50+
if [ "$1" = "--service" ] && [ -n "$2" ]; then
51+
service="$2"
52+
shift 2
53+
54+
run_service_setup "$service"
55+
56+
if [ $# -gt 0 ]; then
57+
exec "$@"
58+
else
59+
exec bash
60+
fi
61+
else
62+
exec "$@"
63+
fi

.devcontainer/setup

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44

55
require 'optparse'
66
require 'fileutils'
7+
require 'pathname'
78

89
class SetupScript
910
WORKSPACE_FOLDERS = %w[
11+
.
12+
spec/apps/rails-mini
1013
sentry-ruby
1114
sentry-rails
1215
sentry-sidekiq
@@ -28,8 +31,6 @@ class SetupScript
2831
def run(args)
2932
parse_options(args)
3033

31-
puts "🚀 Running post-create setup script..."
32-
3334
Dir.chdir(@workspace_root)
3435

3536
if should_run_bundle?
@@ -119,8 +120,10 @@ class SetupScript
119120

120121
if Dir.exist?(folder_path) && File.exist?(gemfile_path)
121122
Dir.chdir(folder_path) do
122-
run_with_spinner(" #{folder}") do
123-
system('bundle install > /dev/null 2>&1')
123+
puts " Installing dependencies for #{folder_path}..."
124+
unless system('bundle install')
125+
puts "❌ Bundle install failed for #{folder}"
126+
exit 1
124127
end
125128
end
126129

@@ -132,8 +135,9 @@ class SetupScript
132135
end
133136

134137
def install_foreman_gem
135-
run_with_spinner("💎 Installing foreman gem") do
136-
system('gem install foreman > /dev/null 2>&1')
138+
unless system('gem install foreman')
139+
puts "❌ Foreman gem installation failed"
140+
exit 1
137141
end
138142
end
139143

@@ -142,8 +146,9 @@ class SetupScript
142146

143147
if Dir.exist?(svelte_mini_path)
144148
Dir.chdir(svelte_mini_path) do
145-
run_with_spinner("📦 Installing npm dependencies for e2e tests") do
146-
system('npm install > /dev/null 2>&1')
149+
unless system('npm install')
150+
puts "❌ npm install failed for svelte-mini"
151+
exit 1
147152
end
148153
end
149154
else

.github/workflows/e2e_tests.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: e2e tests
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
pull_request:
9+
10+
concurrency:
11+
group: e2e-tests-${{ github.head_ref || github.run_id }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
e2e-tests:
16+
name: e2e tests
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 5
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
ruby_version: ["3.4.5"]
24+
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
29+
- name: Set up `.env` file
30+
run: |
31+
cd .devcontainer
32+
cp .env.example .env
33+
34+
- name: Restore rubygems cache
35+
uses: actions/cache@v3
36+
with:
37+
path: |
38+
vendor/gems/${{ matrix.ruby_version }}
39+
key: ${{ runner.os }}-${{ matrix.ruby_version }}-gems-${{ hashFiles('Gemfile.lock', '*/Gemfile.lock', 'spec/apps/**/Gemfile.lock') }}
40+
restore-keys: |
41+
${{ runner.os }}-${{ matrix.ruby_version }}-gems-
42+
43+
- name: Restore node_modules cache
44+
uses: actions/cache@v3
45+
with:
46+
path: spec/apps/svelte-mini/node_modules
47+
key: ${{ runner.os }}-node-modules-${{ hashFiles('spec/apps/svelte-mini/package-lock.json') }}
48+
restore-keys: |
49+
${{ runner.os }}-node-modules-
50+
51+
- name: Build sentry-test-services
52+
run: |
53+
docker compose \
54+
--file .devcontainer/docker-compose.yml \
55+
--env-file .devcontainer/.env \
56+
build sentry-test-services
57+
58+
- name: Set up test services
59+
run: |
60+
docker compose \
61+
--file .devcontainer/docker-compose.yml \
62+
--env-file .devcontainer/.env \
63+
run --rm sentry-test-services \
64+
echo "Done"
65+
66+
- name: Start test services
67+
run: |
68+
docker compose \
69+
--file .devcontainer/docker-compose.yml \
70+
--env-file .devcontainer/.env \
71+
up -d sentry-test-services
72+
73+
- name: "Wait for rails-mini app to be ready"
74+
uses: nev7n/wait_for_response@v1
75+
with:
76+
url: 'http://localhost:4000/health'
77+
responseCode: 200
78+
timeout: 90000
79+
interval: 500
80+
81+
- name: "Wait for svelte-mini app to be ready"
82+
uses: nev7n/wait_for_response@v1
83+
with:
84+
url: 'http://localhost:4001/health'
85+
responseCode: 200
86+
timeout: 90000
87+
interval: 500
88+
89+
- name: Build sentry-test
90+
run: |
91+
docker compose \
92+
--file .devcontainer/docker-compose.yml \
93+
--env-file .devcontainer/.env \
94+
build sentry-test
95+
96+
- name: Set up sentry-test container
97+
run: |
98+
docker compose \
99+
--file .devcontainer/docker-compose.yml \
100+
--env-file .devcontainer/.env \
101+
run --rm sentry-test \
102+
echo "Done"
103+
104+
- name: Run e2e tests via sentry-test
105+
run: |
106+
docker compose \
107+
--file .devcontainer/docker-compose.yml \
108+
--env-file .devcontainer/.env \
109+
run --rm sentry-test \
110+
bundle exec rake
111+
112+
- name: Stop e2e services
113+
if: always()
114+
run: |
115+
cd .devcontainer
116+
source .env
117+
docker compose --profile e2e down
118+
119+
- name: Upload test artifacts
120+
if: failure()
121+
uses: actions/upload-artifact@v4
122+
with:
123+
name: e2e-test-logs-ruby-${{ matrix.ruby_version }}
124+
path: |
125+
log/sentry_debug_events.log
126+
retention-days: 7

.github/workflows/tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: Tests & CodeCov
22

33
on:
44
workflow_dispatch:
5-
push:
6-
branches:
7-
- master
8-
- \d+-\d+
9-
pull_request:
5+
# push:
6+
# branches:
7+
# - master
8+
# - \d+-\d+
9+
# pull_request:
1010

1111
concurrency:
1212
group: tests-${{ github.head_ref || github.run_id }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ Gemfile.lock
1515
.rgignore
1616

1717
node_modules
18+
vendor/gems

0 commit comments

Comments
 (0)