tests.yml 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. name: Tests
  2. permissions:
  3. contents: read
  4. on:
  5. pull_request:
  6. branches:
  7. - main
  8. workflow_dispatch:
  9. jobs:
  10. unit-tests:
  11. name: Unit Tests
  12. runs-on: ${{ matrix.os }}
  13. strategy:
  14. max-parallel: 4
  15. matrix:
  16. os: [ubuntu-latest, windows-latest, macOS-latest]
  17. steps:
  18. - name: Checkout
  19. uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
  20. with:
  21. persist-credentials: false
  22. - name: Set up Go
  23. uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
  24. with:
  25. go-version: stable
  26. - name: Run unit tests with coverage and race conditions checking
  27. if: matrix.os == 'ubuntu-latest'
  28. run: make test
  29. - name: Run unit tests without coverage and race conditions checking
  30. if: matrix.os != 'ubuntu-latest'
  31. run: go test ./...
  32. integration-tests:
  33. name: Integration Tests
  34. runs-on: ubuntu-latest
  35. services:
  36. postgres:
  37. image: postgres:11
  38. env:
  39. POSTGRES_USER: postgres
  40. POSTGRES_PASSWORD: postgres
  41. POSTGRES_DB: postgres
  42. ports:
  43. - 5432:5432
  44. options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
  45. steps:
  46. - name: Checkout
  47. uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
  48. with:
  49. persist-credentials: false
  50. - name: Set up Go
  51. uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
  52. with:
  53. go-version: stable
  54. - name: Install Postgres client
  55. run: sudo apt update && sudo apt install -y postgresql-client
  56. - name: Run integration tests
  57. run: make integration-test
  58. env:
  59. PGHOST: 127.0.0.1
  60. PGPASSWORD: postgres