|
7 | 7 | branches: [ main ] |
8 | 8 |
|
9 | 9 | jobs: |
10 | | - test: |
| 10 | + unit-test: |
| 11 | + name: Unit Tests |
11 | 12 | runs-on: ubuntu-latest |
12 | 13 |
|
13 | 14 | steps: |
|
29 | 30 | - name: Download dependencies |
30 | 31 | run: go mod download |
31 | 32 |
|
32 | | - - name: Run tests |
| 33 | + - name: Run unit tests |
33 | 34 | run: go test -v ./... |
34 | 35 |
|
35 | | - - name: Run tests with race detection |
| 36 | + - name: Run unit tests with race detection |
36 | 37 | run: go test -race -v ./... |
| 38 | + |
| 39 | + integration-test: |
| 40 | + name: Integration Tests |
| 41 | + runs-on: ubuntu-latest |
| 42 | + |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v4 |
| 45 | + |
| 46 | + - name: Set up Go |
| 47 | + uses: actions/setup-go@v4 |
| 48 | + with: |
| 49 | + go-version: '1.22.3' |
| 50 | + |
| 51 | + - name: Cache Go modules |
| 52 | + uses: actions/cache@v3 |
| 53 | + with: |
| 54 | + path: ~/go/pkg/mod |
| 55 | + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 56 | + restore-keys: | |
| 57 | + ${{ runner.os }}-go- |
| 58 | + |
| 59 | + - name: Download dependencies |
| 60 | + run: go mod download |
| 61 | + |
| 62 | + - name: Start PostgreSQL with logical replication |
| 63 | + run: | |
| 64 | + docker run -d \ |
| 65 | + --name postgres-test \ |
| 66 | + -e POSTGRES_USER=postgres \ |
| 67 | + -e POSTGRES_PASSWORD=postgres \ |
| 68 | + -e POSTGRES_DB=postgres \ |
| 69 | + -p 5432:5432 \ |
| 70 | + postgres:17 \ |
| 71 | + -c wal_level=logical \ |
| 72 | + -c max_wal_senders=10 \ |
| 73 | + -c max_replication_slots=10 |
| 74 | +
|
| 75 | + - name: Wait for PostgreSQL to be ready |
| 76 | + run: | |
| 77 | + for i in {1..30}; do |
| 78 | + docker exec postgres-test pg_isready -U postgres && break |
| 79 | + echo "Waiting for PostgreSQL..." |
| 80 | + sleep 2 |
| 81 | + done |
| 82 | +
|
| 83 | + - name: Verify PostgreSQL configuration |
| 84 | + run: | |
| 85 | + docker exec postgres-test psql -U postgres -c "SHOW wal_level;" |
| 86 | + docker exec postgres-test psql -U postgres -c "SHOW max_replication_slots;" |
| 87 | + docker exec postgres-test psql -U postgres -c "SHOW max_wal_senders;" |
| 88 | + |
| 89 | + - name: Run integration tests |
| 90 | + env: |
| 91 | + POSTGRES_HOST: localhost |
| 92 | + POSTGRES_PORT: 5432 |
| 93 | + POSTGRES_USER: postgres |
| 94 | + POSTGRES_PASSWORD: postgres |
| 95 | + POSTGRES_DB: postgres |
| 96 | + run: go test -v -tags=integration -timeout=300s ./listener/... |
0 commit comments