node20対応 #151
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: CI | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
env: | |
CARGO_TERM_COLOR: always | |
RUST_BACKTRACE: 1 | |
RUST_TEST_THREADS: 1 | |
CARGO_PROFILE_TEST_DEBUG: 0 | |
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: 16 # react-scripts 4.x系が対応していないため、Node 16を使う | |
cache: yarn | |
cache-dependency-path: ./atcoder-problems-frontend/yarn.lock | |
- name: Cache Cypress Binary | |
uses: actions/cache@v4.0.1 | |
with: | |
path: | | |
~/.cache/Cypress | |
key: ${{ runner.os }}-Cypress-${{ hashFiles('atcoder-problems-frontend/yarn.lock') }} | |
- name: Install dependencies | |
run: yarn | |
- name: Setup mdBook | |
uses: peaceiris/actions-mdbook@v1.2.0 # https://github.com/peaceiris/actions-mdbook/pull/500 のマージを待つ | |
with: | |
mdbook-version: "latest" | |
- name: build | |
run: 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 |