Skip to content

Commit 48fcfbd

Browse files
committed
Minimal production test on github
This commit splits up the existing ci.yml into multiple files, and adds a new test that tries to bring up the production webserver from scratch to make sure that it works.
1 parent c41507f commit 48fcfbd

File tree

3 files changed

+69
-15
lines changed

3 files changed

+69
-15
lines changed

.github/workflows/docker-build.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Docker Build
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
docker-build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Set up Docker Buildx
15+
uses: docker/setup-buildx-action@v3
16+
- name: Build app image
17+
uses: docker/build-push-action@v5
18+
with:
19+
context: .
20+
file: Dockerfile
21+
push: false
22+
tags: hackorum:test

.github/workflows/prod-boot.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Prod Boot
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
prod-boot:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 25
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Prepare deploy env file
17+
run: |
18+
cp deploy/.env.example deploy/.env
19+
# Override secrets/SSL for CI boot
20+
ruby -e "require 'securerandom'; puts \"SECRET_KEY_BASE=#{SecureRandom.hex(64)}\"" >> deploy/.env
21+
echo "FORCE_SSL=false" >> deploy/.env
22+
echo "APP_HOST=localhost" >> deploy/.env
23+
24+
- name: Start database
25+
run: docker compose -f deploy/docker-compose.yml up -d db
26+
27+
- name: Prepare database (migrations)
28+
run: docker compose -f deploy/docker-compose.yml run --rm web bin/rails db:prepare
29+
30+
- name: Start web
31+
run: docker compose -f deploy/docker-compose.yml up -d web
32+
33+
- name: Verify web healthcheck
34+
run: |
35+
for i in {1..30}; do
36+
if docker compose -f deploy/docker-compose.yml exec web sh -lc "curl -fs http://localhost:3000/up"; then
37+
exit 0
38+
fi
39+
sleep 5
40+
done
41+
docker compose -f deploy/docker-compose.yml logs --tail=200 web db
42+
exit 1
43+
44+
- name: Teardown
45+
if: always()
46+
run: docker compose -f deploy/docker-compose.yml down -v
Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: Tests
22

33
on:
44
push:
@@ -46,17 +46,3 @@ jobs:
4646

4747
- name: Run specs
4848
run: bundle exec rspec
49-
50-
docker-build:
51-
runs-on: ubuntu-latest
52-
steps:
53-
- uses: actions/checkout@v4
54-
- name: Set up Docker Buildx
55-
uses: docker/setup-buildx-action@v3
56-
- name: Build app image
57-
uses: docker/build-push-action@v5
58-
with:
59-
context: .
60-
file: Dockerfile
61-
push: false
62-
tags: hackorum:test

0 commit comments

Comments
 (0)