Skip to content

CIのNode 20対応 #1048

CIのNode 20対応

CIのNode 20対応 #1048

Workflow file for this run

name: CI
on:
push:
branches: [master]
pull_request:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
CARGO_PROFILE_TEST_DEBUG: 0
RUST_TEST_THREADS: 1
SQL_URL: postgres://db_user:db_pass@localhost:5432/test_db
jobs:
backend_test:
name: Run backend tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./atcoder-problems-backend
services:
postgres:
image: postgres
env:
POSTGRES_USER: db_user
POSTGRES_PASSWORD: db_pass
POSTGRES_DB: test_db
POSTGRES_INITDB_ARGS: "--encoding=UTF8"
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4.1.1
- name: Cache dependencies
uses: Swatinem/rust-cache@v2.7.3
with:
workspaces: atcoder-problems-backend -> target
- name: Setup Postgresql
run: psql ${SQL_URL} < ../config/database-definition.sql
- name: Setup
run: rustup component add rustfmt
- name: Check format
run: cargo fmt --all -- --check
- name: Download dependencies
run: cargo fetch --locked
- name: Build
run: cargo test --no-run --workspace --locked --verbose
- name: Run tests
run: cargo test --workspace --locked --verbose -- --test-threads=1
frontend_test:
name: Run frontend tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./atcoder-problems-frontend
steps:
- uses: actions/checkout@v4.1.1
- name: Use Node.js
uses: actions/setup-node@v4.0.2
with:
node-version: 20
- name: Cache dependencies
uses: actions/cache@v4.0.1
with:
path: |
~/.cache/Cypress
atcoder-problems-frontend/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('atcoder-problems-frontend/yarn.lock') }}
- name: Install dependencies
run: yarn
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v2.0.0
with:
mdbook-version: "latest"
# Node 17でOpenSSLがデフォルトでMD4ハッシュを提供しなくなり、
# これに依存していたwebpackに依存するreact-scripts 4.x系でのビルドができなくなってしまった。
# --openssl-legacy-providerをオプションとして渡すことで、Node 17以降でもビルドができる。
# react-scripts 4.x系から移行したら、このオプションは不要になる。
- name: build
run: export NODE_OPTIONS=--openssl-legacy-provider && yarn build
- name: test
run: yarn test
- name: lint
run: yarn lint
- name: Integration test
run: |
yarn prepare-ci
yarn start:ci &
yarn cy:run