tests.yml 1.6 KB

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