|
9 | 9 | CARGO_TERM_COLOR: always
|
10 | 10 | RUST_BACKTRACE: 1
|
11 | 11 | RUST_TEST_THREADS: 1
|
| 12 | + SQL_URL: postgres://db_user:db_pass@localhost:5432/test_db |
12 | 13 |
|
13 | 14 | jobs:
|
14 | 15 | backend_test:
|
15 | 16 | name: Run backend tests
|
16 | 17 | runs-on: ubuntu-latest
|
17 |
| - |
| 18 | + defaults: |
| 19 | + run: |
| 20 | + working-directory: ./atcoder-problems-backend |
| 21 | + |
18 | 22 | services:
|
19 |
| - postgres: |
| 23 | + postgres: |
20 | 24 | image: postgres
|
21 | 25 | env:
|
22 |
| - POSTGRES_PASSWORD: pass |
23 |
| - POSTGRES_USER: kenkoooo |
24 |
| - POSTGRES_DB: test |
25 |
| - # Set health checks to wait until postgres has started |
| 26 | + POSTGRES_USER: db_user |
| 27 | + POSTGRES_PASSWORD: db_pass |
| 28 | + POSTGRES_DB: test_db |
| 29 | + POSTGRES_INITDB_ARGS: "--encoding=UTF8" |
26 | 30 | options: >-
|
27 | 31 | --health-cmd pg_isready
|
28 | 32 | --health-interval 10s
|
29 | 33 | --health-timeout 5s
|
30 | 34 | --health-retries 5
|
31 | 35 | ports:
|
32 |
| - # Maps tcp port 5432 on service container to the host |
33 | 36 | - 5432:5432
|
34 |
| - |
| 37 | + |
35 | 38 | steps:
|
36 | 39 | - uses: actions/checkout@v2
|
| 40 | + |
| 41 | + - name: Cache cargo registry |
| 42 | + uses: actions/cache@v2 |
| 43 | + with: |
| 44 | + path: | |
| 45 | + ~/.cargo/git |
| 46 | + ~/.cargo/registry/cache |
| 47 | + ~/.cargo/registry/index |
| 48 | + ./atcoder-problems-backend/target |
| 49 | + key: ${{ runner.os }}-cargo-${{ hashFiles('atcoder-problems-backend/Cargo.lock') }} |
| 50 | + |
| 51 | + - name: Setup Postgresql |
| 52 | + run: psql ${SQL_URL} < ../config/database-definition.sql |
| 53 | + |
37 | 54 | - name: Setup
|
38 | 55 | run: rustup component add rustfmt
|
| 56 | + |
39 | 57 | - name: Check format
|
40 |
| - working-directory: ./atcoder-problems-backend |
41 | 58 | run: cargo fmt --all -- --check
|
| 59 | + |
42 | 60 | - name: Build
|
43 |
| - working-directory: ./atcoder-problems-backend |
44 | 61 | run: cargo build --verbose
|
| 62 | + |
45 | 63 | - name: Run tests
|
46 |
| - working-directory: ./atcoder-problems-backend |
47 |
| - env: |
48 |
| - SQL_URL: postgresql://kenkoooo:pass@localhost:5432/test |
49 | 64 | run: cargo test --verbose --workspace -- --test-threads=1
|
50 | 65 |
|
51 | 66 | frontend_test:
|
52 | 67 | name: Run frontend tests
|
53 | 68 | runs-on: ubuntu-latest
|
| 69 | + defaults: |
| 70 | + run: |
| 71 | + working-directory: ./atcoder-problems-frontend |
| 72 | + |
54 | 73 | steps:
|
55 |
| - - name: Setup |
56 |
| - run: sudo apt install libgconf-2-4 |
57 | 74 | - uses: actions/checkout@v2
|
58 | 75 | - name: Use Node.js
|
59 | 76 | uses: actions/setup-node@v1
|
| 77 | + |
| 78 | + - name: Cache node_modules |
| 79 | + uses: actions/cache@v2 |
| 80 | + with: |
| 81 | + path: | |
| 82 | + ~/.cache/Cypress |
| 83 | + ./atcoder-problems-frontend/node_modules |
| 84 | + key: ${{ runner.os }}-cargo-${{ hashFiles('atcoder-problems-frontend/yarn.lock') }} |
| 85 | + |
60 | 86 | - name: Install dependencies
|
61 |
| - working-directory: ./atcoder-problems-frontend |
62 | 87 | run: yarn
|
63 | 88 | - name: build
|
64 |
| - working-directory: ./atcoder-problems-frontend |
65 | 89 | run: yarn build
|
66 | 90 | - name: test
|
67 |
| - working-directory: ./atcoder-problems-frontend |
68 | 91 | run: yarn test
|
69 | 92 | - name: lint
|
70 |
| - working-directory: ./atcoder-problems-frontend |
71 | 93 | run: yarn lint
|
72 | 94 | - name: Integration test
|
73 |
| - working-directory: ./atcoder-problems-frontend |
74 | 95 | run: |
|
75 | 96 | yarn prepare-ci
|
76 | 97 | yarn start:ci &
|
|
0 commit comments