Skip to content

Update node to 20

Update node to 20 #327

Workflow file for this run

name: Unit tests
on:
push:
branches: [ master ]
paths-ignore:
- 'scripts/**'
- '.github/workflows/dokku.yml'
- 'Procfile'
- 'Dockerfile'
pull_request:
jobs:
js-tests:
defaults:
run:
working-directory: web
name: Web app tests
runs-on: ubuntu-latest
container: node:20-bullseye
# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:12.4
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
# Force https use since ssh does not work
- run: 'git config --global url."https://github.com/".insteadOf ssh://git@github.com/'
- run: 'git config --global url."https://".insteadOf ssh://'
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml
- name: Install deps
run: |
pnpm install --frozen-lockfile
cd .. && pnpm install --frozen-lockfile
- name: Initialize database
run: cd .. && pnpm migrate:up && pnpm migrate:test
- name: Run vitest and generate coverage
run: pnpm test:ci
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3.1.4
with:
flags: frontend
name: Frontend coverage
env:
DB_HOST: postgres
DB_PORT: 5432
DB_NAME: postgres
DB_NAME_TEST: postgres
DB_USER: postgres
PGPASSWORD: postgres
ELASTIC_NODE: http://localhost:9200
REDIS_URL: redis:6379
DEBUG: debug,session-*,auth-info
TZ: UTC
LEVEL: silent
SKIP_POSTINSTALL: true
IS_CI: true
python-tests:
name: Scraper tests
runs-on: ubuntu-latest
container: python:3.10-buster
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:12.4
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.1
env:
discovery.type: single-node
options: >-
--health-cmd "curl http://localhost:9200/_cluster/health"
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
- 9200:9200
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Setup poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.5.1
- name: Install dependencies
run: poetry install --with dev
- name: Lint with flake8
run: |
python -m pip install --upgrade pip
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 src --count --select=E9,F63,F7,F82 --show-source --statistics --exclude **/mangaplus_pb2.py*
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 src --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude **/mangaplus_pb2.py*
- name: Type checks with mypy
run: poetry run mypy --config-file mypy.ini ./src
- name: Install db migration dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Test with pytest
run: poetry run pytest --cov=./src --cov-report=xml src
- name: Uninstall coveragepy
run: poetry run pip uninstall -y coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3.1.4
with:
flags: scraper
name: Scraper coverage
files: './coverage/coverage.xml'
env:
DB_HOST: postgres
DB_PORT: 5432
DB_NAME: postgres
DB_NAME_TEST: postgres
DB_USER: postgres
PGPASSWORD: postgres
DB_PASSWORD: postgres
NO_TEMP_DB: TRUE
ELASTIC_TEST_HOST: elasticsearch
ELASTIC_TEST_PORT: 9200
e2e-tests:
defaults:
run:
working-directory: web
name: Cypress E2E tests
runs-on: ubuntu-latest
container:
image: cypress/browsers:node16.13.0-chrome95-ff94
options: --user 1001
# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:12.4
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
# Force https use since ssh does not work
- run: 'git config --global url."https://github.com/".insteadOf ssh://git@github.com/'
- run: 'git config --global url."https://".insteadOf ssh://'
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml
- name: Install deps
run: cd .. && pnpm install --frozen-lockfile
- name: Initialize database
run: cd .. && pnpm migrate:up && pnpm migrate:test
- name: Persist Next.js build cache
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/web/.next/cache
# Generate a new cache whenever packages or source files change.
key: nextjs-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
nextjs-${{ hashFiles('pnpm-lock.yaml') }}-
- uses: cypress-io/github-action@v5.8.1
with:
browser: chrome
working-directory: ./web
build: pnpm cross-env NODE_ENV=production pnpm build-nyc
start: pnpm cross-env NODE_ENV=production pnpm start-coverage
wait-on: 'http://localhost:3000'
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3.1.4
with:
flags: E2E
name: E2E coverage
env:
DB_HOST: postgres
DB_PORT: 5432
DB_NAME: postgres
DB_NAME_TEST: postgres
DB_USER: postgres
PGPASSWORD: postgres
ELASTIC_NODE: http://localhost:9200
NEXTAUTH_URL: 'http://localhost:3000'
NEXTAUTH_SECRET: secret
REDIS_URL: redis:6379
DEBUG: debug,session-*,auth-info
TZ: UTC
LEVEL: silent
SKIP_POSTINSTALL: true
IS_CI: true
LOGIN_RETRY_COUNT: 3
CYPRESS: true
# need at least one oauth provider or next-auth crashes
DISCORD_CLIENT_ID: test
DISCORD_CLIENT_SECRET: test