Skip to content

Commit

Permalink
chore(ci): update CI to use new docker container workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
prisca-c committed Nov 4, 2024
1 parent dab813a commit d573bcd
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 127 deletions.
131 changes: 5 additions & 126 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,130 +14,9 @@ concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}

jobs:
lint:
runs-on: ubuntu-latest
tools:
uses: ./.github/workflows/tools.yml
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 21

- name: Install pnpm
run: |
corepack enable
corepack prepare pnpm@latest --activate
- name: Install dependencies
run: pnpm install

- name: Lint
run: pnpm lint

typecheck:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 21

- name: Install pnpm
run: |
corepack enable
corepack prepare pnpm@latest --activate
- name: Install dependencies
run: |
pnpm install
pnpm -r build
- name: Typecheck
run: pnpm typecheck

build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 21

- name: Install pnpm
run: |
corepack enable
corepack prepare pnpm@latest --activate
- name: Install dependencies
run: pnpm install

- name: Build
run: pnpm build

tests:
runs-on: ubuntu-latest
timeout-minutes: 10

services:
redis:
image: redis:6.2-alpine
ports:
- 6379:6379
postgres:
image: postgres:15-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 21

- name: Install pnpm
run: |
corepack enable
corepack prepare pnpm@latest --activate
- name: Install dependencies
run: |
pnpm install
pnpm exec playwright install
- name: Run tests
env:
APP_KEY: 1234567890123456
NODE_ENV: test
PORT: 3030
HOST: localhost
LOG_LEVEL: info
SESSION_DRIVER: memory
BYPASS_LOGIN: true
REDIS_HOST: localhost
REDIS_PORT: 6379
REDIS_DB: 1
DB_CONNECTION: postgres
DB_HOST: localhost
DB_PORT: 5432
DB_USER: postgres
DB_PASSWORD: postgres
DB_DATABASE: postgres
TWITCH_CLIENT_ID: client_id
TWITCH_CLIENT_SECRET: client_secret
TWITCH_CALLBACK_URL: http://localhost:3333/auth/twitch/callback
GAME_LENGTH: 90
run: FORCE_COLOR=1 pnpm test -r
112 changes: 112 additions & 0 deletions .github/workflows/tools.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Tools CI

on:
workflow_call:
secrets:
DOCKERHUB_USERNAME:
required: true
DOCKERHUB_PASSWORD:
required: true

env:
COMPOSE_FILE: ./docker-compose.tools.yaml

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Run lint
run: |
docker compose -f ${{ env.COMPOSE_FILE }} run --rm install-node-deps
docker compose -f ${{ env.COMPOSE_FILE }} run --rm biome-check
typecheck:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Run typecheck
run: |
docker compose -f ${{ env.COMPOSE_FILE }} run --rm install-node-deps
docker compose -f ${{ env.COMPOSE_FILE }} run --rm tsc
build:
runs-on: ubuntu-latest

steps:
- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Run build
run: |
docker compose -f ${{ env.COMPOSE_FILE }} run --rm install-node-deps
docker compose -f ${{ env.COMPOSE_FILE }} run --rm build
tests:
runs-on: ubuntu-latest
timeout-minutes: 10

services:
redis:
image: redis:6.2-alpine
ports:
- 6379:6379
postgres:
image: postgres:15-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432

steps:
- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Run tests
env:
APP_KEY: 1234567890123456
NODE_ENV: test
PORT: 3333
HOST: localhost
LOG_LEVEL: info
SESSION_DRIVER: memory
BYPASS_LOGIN: true
REDIS_HOST: localhost
REDIS_PORT: 6379
REDIS_DB: 1
DB_CONNECTION: postgres
DB_HOST: localhost
DB_PORT: 5432
DB_USER: postgres
DB_PASSWORD: postgres
DB_DATABASE: postgres
TWITCH_CLIENT_ID: client_id
TWITCH_CLIENT_SECRET: client_secret
TWITCH_CALLBACK_URL: http://localhost:3333/auth/twitch/callback
GAME_LENGTH: 90
run: |
docker compose -f ${{ env.COMPOSE_FILE }} run --rm install-node-deps
docker compose -f ${{ env.COMPOSE_FILE }} up -d postgres-test
docker compose -f ${{ env.COMPOSE_FILE }} run --rm test
3 changes: 2 additions & 1 deletion docker-compose.tools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ services:
- node_modules:/app/node_modules
- build:/app/build
working_dir: /app
command: ["node", "ace", "build"]
entrypoint: [ "sh", "-c" ]
command: ["corepack enable && pnpm build"]

test:
image: node:23.0
Expand Down

0 comments on commit d573bcd

Please sign in to comment.