Create Postgres step in CI.
[rapid-gossip-sync-server] / .github / workflows / build.yml
1 name: Cross-platform build verification
2 on:
3   push:
4     branches:
5       - main
6   pull_request:
7     branches:
8       - "*"
9
10 concurrency:
11   group: ${{ github.workflow }}-${{ github.ref }}
12   cancel-in-progress: true
13
14 jobs:
15   build:
16     strategy:
17       fail-fast: false
18       matrix:
19         toolchain:
20           - stable
21           - 1.56.0
22           - beta
23     runs-on: ubuntu-latest
24     steps:
25       - name: Checkout source code
26         uses: actions/checkout@v3
27       - name: Install Rust ${{ matrix.toolchain }} toolchain
28         uses: actions-rs/toolchain@v1
29         with:
30           toolchain: ${{ matrix.toolchain }}
31           override: true
32           profile: minimal
33       - name: Build on Rust ${{ matrix.toolchain }}
34         run: |
35           cargo build --verbose --color always
36   test:
37     runs-on: ubuntu-latest
38     services:
39       postgres:
40         image: postgres
41         env:
42           POSTGRES_PASSWORD: postgres
43         options: >-
44           --health-cmd pg_isready
45           --health-interval 10s
46           --health-timeout 5s
47           --health-retries 5
48         ports:
49           - 5432:5432
50     steps:
51       - name: Checkout source code
52         uses: actions/checkout@v3
53       - name: Install Rust ${{ matrix.toolchain }} toolchain
54         uses: actions-rs/toolchain@v1
55         with:
56           toolchain: stable
57           override: true
58           profile: minimal
59       - name: Run tests
60         run: |
61           cargo test --verbose --color always -- --show-output
62         env:
63           RAPID_GOSSIP_TEST_DB_HOST: localhost
64           RAPID_GOSSIP_TEST_DB_NAME: postgres
65           RAPID_GOSSIP_TEST_DB_USER: postgres
66           RAPID_GOSSIP_TEST_DB_PASSWORD: postgres
67           RAPID_GOSSIP_SYNC_SERVER_LOG_LEVEL: gossip