Skip to content

Commit cbde3f3

Browse files
committed
Test with CI workflow
1 parent 0e60379 commit cbde3f3

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Start mock upstream
17+
run: |
18+
docker run -d --name upstream -p 3000:80 nginx:alpine
19+
sleep 2
20+
21+
- name: Create .env
22+
run: |
23+
echo "DOMAIN=localhost" > .env
24+
echo "UPSTREAM_URL=http://host.docker.internal:3000" >> .env
25+
26+
- name: Build images
27+
run: docker-compose build
28+
29+
- name: Generate certificates
30+
run: docker-compose --profile setup run --rm mkcert
31+
32+
- name: Verify certificates exist
33+
run: |
34+
test -f certs/localhost.pem
35+
test -f certs/localhost.key.pem
36+
test -f certs/localhost.rootCA.pem
37+
38+
- name: Start proxy
39+
run: docker-compose up -d
40+
41+
- name: Wait for Caddy to start
42+
run: sleep 3
43+
44+
- name: Check Caddy is running
45+
run: docker-compose ps caddy | grep -q "running"
46+
47+
- name: Test HTTP redirect
48+
run: |
49+
curl -s -o /dev/null -w "%{http_code}" http://localhost:8080 | grep -q "301\|308"
50+
51+
- name: Test HTTPS proxies to upstream
52+
run: |
53+
curl -s --cacert certs/localhost.rootCA.pem https://localhost:8443 | grep -q "nginx"
54+
55+
- name: Show logs on failure
56+
if: failure()
57+
run: docker-compose logs
58+
59+
- name: Stop proxy
60+
if: always()
61+
run: |
62+
docker-compose down
63+
docker rm -f upstream || true

0 commit comments

Comments
 (0)