Skip to content

Fix e2e test setup: use launcher script for testcontainers #14

Fix e2e test setup: use launcher script for testcontainers

Fix e2e test setup: use launcher script for testcontainers #14

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
NODE_VERSION: "20"
PNPM_VERSION: "10.4.1"
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
test:
name: Typecheck & Test
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: crackhouse_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Typecheck
run: pnpm --filter web typecheck
- name: Run database migrations
run: pnpm --filter @crackhouse/api db:push
env:
DATABASE_URL: postgresql://postgres:password@localhost:5432/crackhouse_test
AUTH_SECRET: test-auth-secret-for-ci-only-32chars
JWT_SECRET: test-jwt-secret-for-ci-only-32chars
- name: Test
run: pnpm --filter @crackhouse/api test:run
env:
NODE_ENV: test
DATABASE_URL: postgresql://postgres:password@localhost:5432/crackhouse_test
AUTH_SECRET: test-auth-secret-for-ci-only-32chars
JWT_SECRET: test-jwt-secret-for-ci-only-32chars
build-and-push:
name: Build & Push Docker Images
needs: test
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- app: api
dockerfile: apps/api/Dockerfile
context: .
- app: web
dockerfile: apps/web/Dockerfile
context: .
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.app }}
tags: |
type=sha,prefix=
type=raw,value=latest
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max