Create Postgres step in CI.
[rapid-gossip-sync-server] / .github / workflows / build.yml
index 3626feb844e060ebc85b001289579b29c442ee78..7a614ec4ed82e170c83e987953188413ec5f62aa 100644 (file)
@@ -7,6 +7,10 @@ on:
     branches:
       - "*"
 
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
+
 jobs:
   build:
     strategy:
@@ -14,12 +18,8 @@ jobs:
       matrix:
         toolchain:
           - stable
-          - 1.48.0
+          - 1.56.0
           - beta
-        pinning: [true, false]
-        exclude:
-          - toolchain: 1.48.0
-            pinning: false
     runs-on: ubuntu-latest
     steps:
       - name: Checkout source code
@@ -30,12 +30,38 @@ jobs:
           toolchain: ${{ matrix.toolchain }}
           override: true
           profile: minimal
-      - name: Pin dependencies
-        if: ${{ matrix.pinning }}
-        run: |
-          cargo update -p tokio-postgres --precise "0.7.5" --verbose
-          cargo update -p postgres-types --precise "0.2.3" --verbose
-          cargo update -p tokio --precise "1.14.1" --verbose
       - name: Build on Rust ${{ matrix.toolchain }}
         run: |
           cargo build --verbose --color always
+  test:
+    runs-on: ubuntu-latest
+    services:
+      postgres:
+        image: postgres
+        env:
+          POSTGRES_PASSWORD: postgres
+        options: >-
+          --health-cmd pg_isready
+          --health-interval 10s
+          --health-timeout 5s
+          --health-retries 5
+        ports:
+          - 5432:5432
+    steps:
+      - name: Checkout source code
+        uses: actions/checkout@v3
+      - name: Install Rust ${{ matrix.toolchain }} toolchain
+        uses: actions-rs/toolchain@v1
+        with:
+          toolchain: stable
+          override: true
+          profile: minimal
+      - name: Run tests
+        run: |
+          cargo test --verbose --color always -- --show-output
+        env:
+          RAPID_GOSSIP_TEST_DB_HOST: localhost
+          RAPID_GOSSIP_TEST_DB_NAME: postgres
+          RAPID_GOSSIP_TEST_DB_USER: postgres
+          RAPID_GOSSIP_TEST_DB_PASSWORD: postgres
+          RAPID_GOSSIP_SYNC_SERVER_LOG_LEVEL: gossip