Skip to content

Commit ff956fe

Browse files
committed
Replace docker-compose with Github Actions service
1 parent 9524dab commit ff956fe

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ env:
99
CARGO_TERM_COLOR: always
1010
RUST_BACKTRACE: 1
1111
RUST_TEST_THREADS: 1
12-
SQL_URL: postgres://db_user:db_pass@localhost:15432/test_db
12+
SQL_URL: postgres://db_user:db_pass@localhost:5432/test_db
1313

1414
jobs:
1515
backend_test:
@@ -18,13 +18,24 @@ jobs:
1818
defaults:
1919
run:
2020
working-directory: ./atcoder-problems-backend
21+
22+
services:
23+
postgres:
24+
image: postgres
25+
env:
26+
POSTGRES_USER: db_user
27+
POSTGRES_PASSWORD: db_pass
28+
POSTGRES_DB: test_db
29+
POSTGRES_INITDB_ARGS: "--encoding=UTF8"
30+
options: >-
31+
--health-cmd pg_isready
32+
--health-interval 10s
33+
--health-timeout 5s
34+
--health-retries 5
2135
2236
steps:
2337
- uses: actions/checkout@v2
2438

25-
- name: Start PostgreSQL server
26-
run: docker-compose up -d postgresql
27-
2839
- name: Cache cargo registry
2940
uses: actions/cache@v2
3041
with:
@@ -35,14 +46,8 @@ jobs:
3546
./atcoder-problems-backend/target
3647
key: ${{ runner.os }}-cargo-${{ hashFiles('atcoder-problems-backend/Cargo.lock') }}
3748

38-
- name: Wait for PostgreSQL
39-
run: |
40-
for i in `seq 20`
41-
do
42-
docker-compose exec -T pg_isready && break
43-
echo "Waiting for PostgreSQL for 3 seconds ..."
44-
sleep 3
45-
done
49+
- name: Setup Postgresql
50+
run: psql ${SQL_URL} < ../config/database-definition.sql
4651

4752
- name: Setup
4853
run: rustup component add rustfmt
@@ -53,9 +58,6 @@ jobs:
5358
- name: Build
5459
run: cargo build --verbose
5560

56-
- name: env debug
57-
run: echo ${SQL_URL}
58-
5961
- name: Run tests
6062
run: cargo test --verbose --workspace -- --test-threads=1
6163

0 commit comments

Comments
 (0)