test-postgres.yml raw

   1  name: Backend testing with Postgres
   2  
   3  on:
   4    push:
   5      branches:
   6        - master
   7    pull_request:
   8      types: [opened, synchronize]
   9  
  10  jobs:
  11    test-postgres:
  12      runs-on: ubuntu-22.04
  13  
  14      services:
  15        postgres:
  16          image: postgres:17.2
  17          ports:
  18            - 5432:5432
  19          env:
  20            POSTGRES_DB: albyhub
  21            POSTGRES_USER: alby
  22            POSTGRES_PASSWORD: albytest123
  23          options: >-
  24            --health-cmd pg_isready
  25            --health-interval 10s
  26            --health-timeout 5s
  27            --health-retries 5
  28  
  29      steps:
  30        - uses: actions/checkout@v4
  31          name: Check out code
  32  
  33        - name: Setup GoLang
  34          uses: actions/setup-go@v5
  35          with:
  36            go-version-file: "./go.mod"
  37  
  38        - name: Get dependencies
  39          run: go get -v -t -d ./...
  40  
  41        - name: Run tests
  42          env:
  43            TEST_DATABASE_URI: "postgresql://alby:albytest123@localhost:5432/albyhub"
  44            TEST_DB_MIGRATE_POSTGRES_URI: "postgresql://alby:albytest123@localhost:5432/albyhub"
  45          run: mkdir frontend/dist && touch frontend/dist/tmp && go test ./...
  46