-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (121 loc) · 5.15 KB
/
Copy pathjest-server-test.yml
File metadata and controls
154 lines (121 loc) · 5.15 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
name: Server Integration Tests
on:
push:
branches: [ edge, stable ]
pull_request:
branches: [ edge, stable ]
jobs:
server-integration-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install mkcert
run: |
# Install mkcert for certificate generation
curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64"
chmod +x mkcert-v*-linux-amd64
sudo cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert
# Install CA in system trust store
mkcert -install
- name: Generate certificates
run: |
# Create certificate directory in workspace (not home directory)
mkdir -p ./.simulacrum/certs
cd ./.simulacrum/certs
# Generate certificates for all required hostnames
mkcert -cert-file localhost.pem -key-file localhost-key.pem \
localhost 127.0.0.1 ::1 oidc-simulator host.docker.internal
# Copy mkcert root CA to the certs directory for Docker containers
cp "$(mkcert -CAROOT)/rootCA.pem" ./rootCA.pem
# List generated files for debugging
echo "Generated certificates:"
ls -la
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Create test.env with CI-specific paths
run: |
# Update AUTH_CERTS_PATH to use workspace-relative path
sed -i 's|AUTH_CERTS_PATH=.*|AUTH_CERTS_PATH=./.simulacrum/certs|' test.env
# Update JWKS_URI to use localhost for OIDC simulator
sed -i 's|JWKS_URI=.*|JWKS_URI=https://localhost:3000/.well-known/jwks.json|' test.env
# Copy test.env to .env for docker-compose variable interpolation
cp test.env .env
# Also copy test.env to server directory for the test environment
cp test.env server/.env
# Show relevant env vars for debugging
echo "Environment variables:"
grep -E "AUTH_|CERT|DATABASE_URL|POSTGRES_|JWT_|JWKS_URI" test.env || true
- name: Build Docker images
run: |
# Build all services except server (tests run on host)
docker compose -f docker-compose.test.yml --env-file test.env build \
math postgres file-server maildev oidc-simulator dynamodb
- name: Start services
run: |
# Start only required services in detached mode (exclude server)
docker compose -f docker-compose.test.yml --env-file test.env up -d \
math postgres file-server maildev oidc-simulator dynamodb
# Wait for services to be ready
echo "Waiting for services to start..."
sleep 30
# Show running containers
docker compose -f docker-compose.test.yml ps
- name: Check service health
run: |
# Check if key services are responding
echo "Checking postgres..."
docker compose -f docker-compose.test.yml exec -T postgres pg_isready -U postgres || true
echo "Checking oidc-simulator..."
curl -k -f https://localhost:3000/.well-known/jwks.json || true
echo "Checking DynamoDB..."
curl -f http://localhost:8000 || true
# Alternative check using AWS CLI if available
aws dynamodb list-tables --endpoint-url http://localhost:8000 --region us-east-1 2>/dev/null || true
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: server/package-lock.json
- name: Install server dependencies
run: |
cd server
npm ci
- name: Run server integration tests
run: |
cd server
# Set environment variables for tests
export NODE_EXTRA_CA_CERTS=$(pwd)/../.simulacrum/certs/rootCA.pem
export CI=true
export NODE_ENV=test
# Override service URLs to use localhost instead of Docker service names
export DATABASE_URL=postgres://postgres:PdwPNS2mDN73Vfbc@localhost:5432/polis-test
export MAILDEV_HOST=localhost
export STATIC_FILES_HOST=localhost
export DYNAMODB_ENDPOINT=http://localhost:8000
# Run the tests on the host machine
npm test -- --ci --coverage --maxWorkers=2
- name: Upload test coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: server/coverage
if-no-files-found: ignore
- name: Show service logs
if: failure()
run: |
# Show logs from critical services for debugging
echo "=== OIDC Simulator logs ==="
docker compose -f docker-compose.test.yml logs oidc-simulator | tail -100
echo "=== Postgres logs ==="
docker compose -f docker-compose.test.yml logs postgres | tail -100
echo "=== Math logs ==="
docker compose -f docker-compose.test.yml logs math | tail -50
echo "=== DynamoDB logs ==="
docker compose -f docker-compose.test.yml logs dynamodb | tail -100
- name: Clean up
if: always()
run: |
docker compose -f docker-compose.test.yml down -v