big package dependency updates for node 22 #490
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Test | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
debug_enabled: | |
type: boolean | |
description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)" | |
required: false | |
default: false | |
env: | |
MATERIAL_REPO: "UNIVERSE-HPC/course-material" | |
MANAGER: "yarn" | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
env: | |
MATERIAL_DIR: ".material" | |
NEXT_PUBLIC_BASEPATH: "" | |
NEXTAUTH_URL: http://localhost:3002/gutenberg/api/auth | |
NEXTAUTH_SECRET: "secret here" | |
GITHUB_SECRET: "github_secret" | |
GITHUB_ID: "github_id" | |
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/gutenberg | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Enable corepack | |
shell: bash | |
run: corepack enable | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
cache: ${{ env.MANAGER }} | |
- name: Restore cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
.next/cache | |
# Generate a new cache whenever packages or source files change. | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} | |
# If source files changed but packages didn't, rebuild from a prior cache. | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}- | |
- name: Install dependencies | |
run: ${{ env.MANAGER }} install | |
- name: Migrate database | |
run: ${{ env.MANAGER }} prisma migrate deploy | |
- name: Seed database with test data | |
run: ${{ env.MANAGER }} prisma db seed | |
- name: Checkout course material | |
shell: bash | |
run: yarn pullmat | |
- name: Check course material | |
shell: bash | |
run: ls ${{ env.MATERIAL_DIR }} | |
- name: Build with Next.js | |
run: ${{ env.MANAGER }} build | |
# Enable tmate debugging of manually-triggered workflows if the input option was provided | |
- name: Setup tmate session | |
uses: mxschmitt/action-tmate@v3 | |
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} | |
- name: Run e2e tests | |
run: ${{ env.MANAGER }} ci:e2e | |
- name: Run component tests | |
run: ${{ env.MANAGER }} component | |
docker-build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: docker compose build | |
run: docker compose -f docker-compose.yml build | |
- name: docker compose up | |
run: docker compose -f docker-compose.yml up -d | |
- name: docker compose ps | |
run: docker compose -f docker-compose.yml ps | |
- name: docker compose down | |
run: docker compose -f docker-compose.yml down | |
deploy: | |
name: Deploy to staging | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
needs: build-and-test | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
- name: Enable corepack | |
shell: bash | |
run: corepack enable | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Checkout course material | |
shell: bash | |
run: | | |
pip install --upgrade pip setuptools wheel | |
pip install -r scripts/python_requirements.txt | |
python scripts/pull_material.py | |
- name: Check course material | |
shell: bash | |
run: ls ${{ env.MATERIAL_DIR }} | |
- uses: superfly/flyctl-actions/setup-flyctl@master | |
- run: flyctl deploy -a gutenberg-staging --remote-only | |
--build-arg DATABASE_URL=${{secrets.DATABASE_URL_TEST}} | |
--build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN=${{secrets.NEXT_PUBLIC_PLAUSIBLE_DOMAIN_TEST}} | |
--wait-timeout 240 | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
NEXT_PUBLIC_PLAUSIBLE_DOMAIN: ${{ secrets.NEXT_PUBLIC_PLAUSIBLE_DOMAIN }} |