Skip to content

Commit be0f7bd

Browse files
committed
chore(ci): update CI to use new docker container workflow
1 parent 9986d56 commit be0f7bd

File tree

7 files changed

+150
-131
lines changed

7 files changed

+150
-131
lines changed

.env.ci

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
TZ=UTC
2+
PORT=3333
3+
HOST=localhost
4+
LOG_LEVEL=info
5+
APP_KEY=1234567890123456
6+
NODE_ENV=test
7+
8+
BYPASS_LOGIN=true
9+
10+
SESSION_DRIVER=memory
11+
12+
DB_CONNECTION=postgres
13+
DB_HOST=localhost
14+
DB_PORT=5432
15+
DB_USER=postgres
16+
DB_PASSWORD=postgres
17+
DB_DATABASE=postgres
18+
19+
REDIS_PASSWORD=1234
20+
REDIS_HOST=localhost
21+
REDIS_PORT=6379
22+
REDIS_DB=1
23+
24+
TWITCH_CLIENT_ID=client_id
25+
TWITCH_CLIENT_SECRET=client_secret
26+
TWITCH_CALLBACK_URL=http://localhost:3333/auth/twitch/callback
27+
28+
# Game length in seconds
29+
GAME_LENGTH=90

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ TWITCH_CALLBACK_URL=
2727

2828
# Game length in seconds
2929
GAME_LENGTH=90
30+
31+
32+

.github/workflows/app.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: App CI
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
DOCKERHUB_USERNAME:
7+
required: true
8+
DOCKERHUB_PASSWORD:
9+
required: true
10+
11+
env:
12+
COMPOSE_FILE: ./docker-compose.yaml
13+
COMPOSE_FILE_PROD: ./docker-compose.production.yaml
14+
15+
jobs:
16+
17+
app:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Login to DockerHub
24+
uses: docker/[email protected]
25+
with:
26+
username: ${{ secrets.DOCKERHUB_USERNAME }}
27+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
28+
29+
- name: Run build
30+
run: |
31+
docker compose -f ${{ env.COMPOSE_FILE }} -f ${{ env.COMPOSE_FILE_PROD }} up -d

.github/workflows/checks.yml

Lines changed: 11 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -14,130 +14,15 @@ concurrency:
1414
group: ci-${{ github.workflow }}-${{ github.ref }}
1515

1616
jobs:
17-
lint:
18-
runs-on: ubuntu-latest
17+
tools:
18+
uses: ./.github/workflows/tools.yml
19+
secrets:
20+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
21+
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
22+
23+
app:
24+
uses: ./.github/workflows/app.yml
25+
secrets:
26+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
27+
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
1928

20-
steps:
21-
- uses: actions/checkout@v4
22-
23-
- name: Setup Node.js
24-
uses: actions/setup-node@v4
25-
with:
26-
node-version: 21
27-
28-
- name: Install pnpm
29-
run: |
30-
corepack enable
31-
corepack prepare pnpm@latest --activate
32-
33-
- name: Install dependencies
34-
run: pnpm install
35-
36-
- name: Lint
37-
run: pnpm lint
38-
39-
typecheck:
40-
runs-on: ubuntu-latest
41-
42-
steps:
43-
- uses: actions/checkout@v4
44-
45-
- name: Setup Node.js
46-
uses: actions/setup-node@v4
47-
with:
48-
node-version: 21
49-
50-
- name: Install pnpm
51-
run: |
52-
corepack enable
53-
corepack prepare pnpm@latest --activate
54-
55-
- name: Install dependencies
56-
run: |
57-
pnpm install
58-
pnpm -r build
59-
60-
- name: Typecheck
61-
run: pnpm typecheck
62-
63-
build:
64-
runs-on: ubuntu-latest
65-
66-
steps:
67-
- uses: actions/checkout@v4
68-
69-
- name: Setup Node.js
70-
uses: actions/setup-node@v4
71-
with:
72-
node-version: 21
73-
74-
- name: Install pnpm
75-
run: |
76-
corepack enable
77-
corepack prepare pnpm@latest --activate
78-
79-
- name: Install dependencies
80-
run: pnpm install
81-
82-
- name: Build
83-
run: pnpm build
84-
85-
tests:
86-
runs-on: ubuntu-latest
87-
timeout-minutes: 10
88-
89-
services:
90-
redis:
91-
image: redis:6.2-alpine
92-
ports:
93-
- 6379:6379
94-
postgres:
95-
image: postgres:15-alpine
96-
env:
97-
POSTGRES_USER: postgres
98-
POSTGRES_PASSWORD: postgres
99-
POSTGRES_DB: postgres
100-
ports:
101-
- 5432:5432
102-
103-
steps:
104-
- uses: actions/checkout@v4
105-
106-
- name: Setup Node.js
107-
uses: actions/setup-node@v4
108-
with:
109-
node-version: 21
110-
111-
- name: Install pnpm
112-
run: |
113-
corepack enable
114-
corepack prepare pnpm@latest --activate
115-
116-
- name: Install dependencies
117-
run: |
118-
pnpm install
119-
pnpm exec playwright install
120-
121-
- name: Run tests
122-
env:
123-
APP_KEY: 1234567890123456
124-
NODE_ENV: test
125-
PORT: 3030
126-
HOST: localhost
127-
LOG_LEVEL: info
128-
SESSION_DRIVER: memory
129-
BYPASS_LOGIN: true
130-
REDIS_HOST: localhost
131-
REDIS_PORT: 6379
132-
REDIS_DB: 1
133-
DB_CONNECTION: postgres
134-
DB_HOST: localhost
135-
DB_PORT: 5432
136-
DB_USER: postgres
137-
DB_PASSWORD: postgres
138-
DB_DATABASE: postgres
139-
TWITCH_CLIENT_ID: client_id
140-
TWITCH_CLIENT_SECRET: client_secret
141-
TWITCH_CALLBACK_URL: http://localhost:3333/auth/twitch/callback
142-
GAME_LENGTH: 90
143-
run: FORCE_COLOR=1 pnpm test -r

.github/workflows/tools.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Tools CI
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
DOCKERHUB_USERNAME:
7+
required: true
8+
DOCKERHUB_PASSWORD:
9+
required: true
10+
11+
env:
12+
COMPOSE_FILE_TOOLS: ./docker-compose.tools.yaml
13+
COMPOSE_FILE: ./docker-compose.yaml
14+
15+
jobs:
16+
lint:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Login to DockerHub
23+
uses: docker/[email protected]
24+
with:
25+
username: ${{ secrets.DOCKERHUB_USERNAME }}
26+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
27+
28+
- name: Run lint
29+
run: |
30+
docker compose -f ${{ env.COMPOSE_FILE_TOOLS }} run --rm install-node-deps
31+
docker compose -f ${{ env.COMPOSE_FILE_TOOLS }} run --rm biome-check
32+
33+
typecheck:
34+
runs-on: ubuntu-latest
35+
36+
steps:
37+
- uses: actions/checkout@v4
38+
39+
- name: Login to DockerHub
40+
uses: docker/[email protected]
41+
with:
42+
username: ${{ secrets.DOCKERHUB_USERNAME }}
43+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
44+
45+
- name: Run typecheck
46+
run: |
47+
docker compose -f ${{ env.COMPOSE_FILE_TOOLS }} run --rm install-node-deps
48+
docker compose -f ${{ env.COMPOSE_FILE_TOOLS }} run --rm tsc
49+
50+
tests:
51+
runs-on: ubuntu-latest
52+
timeout-minutes: 10
53+
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- name: Login to DockerHub
58+
uses: docker/[email protected]
59+
with:
60+
username: ${{ secrets.DOCKERHUB_USERNAME }}
61+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
62+
63+
- name: Run tests
64+
run: |
65+
cp .env.ci .env
66+
docker compose -f ${{ env.COMPOSE_FILE }} up -d redis
67+
docker compose -f ${{ env.COMPOSE_FILE_TOOLS }} run --rm install-node-deps
68+
docker compose -f ${{ env.COMPOSE_FILE_TOOLS }} up -d postgres-test
69+
docker compose -f ${{ env.COMPOSE_FILE_TOOLS }} run --rm biome-check
70+
docker compose -f ${{ env.COMPOSE_FILE_TOOLS }} run --rm test

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": false },
44
"files": {
55
"ignoreUnknown": false,
6-
"ignore": ["node_modules", "dist", "build", "public", "resources"]
6+
"ignore": ["node_modules", "dist", "build", "public", "resources", ".pnpm-store"]
77
},
88
"formatter": {
99
"enabled": true,

docker-compose.tools.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ services:
1515
- node_modules:/app/node_modules
1616
working_dir: /app
1717
entrypoint: [ "sh", "-c" ]
18-
command: ["corepack enable && pnpm typecheck"]
18+
command: ["corepack enable && FORCE_COLOR=1 pnpm typecheck"]
1919

2020
biome-check:
2121
image: node:23.0
@@ -24,7 +24,7 @@ services:
2424
- node_modules:/app/node_modules
2525
working_dir: /app
2626
entrypoint: [ "sh", "-c" ]
27-
command: ["corepack enable && pnpm lint"]
27+
command: ["corepack enable && FORCE_COLOR=1 pnpm lint"]
2828

2929
biome-check-fix:
3030
image: node:23.0
@@ -33,7 +33,7 @@ services:
3333
- node_modules:/app/node_modules
3434
working_dir: /app
3535
entrypoint: [ "sh", "-c" ]
36-
command: ["corepack enable && pnpm lint --write"]
36+
command: ["corepack enable && FORCE_COLOR=1 pnpm lint --write"]
3737

3838
build:
3939
image: node:23.0
@@ -42,7 +42,8 @@ services:
4242
- node_modules:/app/node_modules
4343
- build:/app/build
4444
working_dir: /app
45-
command: ["node", "ace", "build"]
45+
entrypoint: [ "sh", "-c" ]
46+
command: ["corepack enable && FORCE_COLOR=1 pnpm build"]
4647

4748
test:
4849
image: node:23.0

0 commit comments

Comments
 (0)