name: Unit Tests on: push: branches: [main] paths: - "backend/**" pull_request: branches: [main, breaking/**] paths: - "backend/**" permissions: contents: read jobs: test-backend: name: Backend (${{ matrix.name }}) strategy: fail-fast: false matrix: include: - name: Linux runner: depot-ubuntu-latest - name: Windows runner: windows-latest runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: go-version-file: "backend/go.mod" cache-dependency-path: "backend/go.sum" - name: Install dependencies working-directory: backend run: | go get ./... - name: Start Postgres # The SQLite/Postgres schema parity test needs Postgres and fails instead of skipping when POCKET_ID_TEST_POSTGRES_REQUIRED is set if: runner.os == 'Linux' run: | docker run -d --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 --health-cmd "pg_isready -U postgres" --health-interval 1s --health-retries 60 postgres:17 timeout 60 sh -c 'until [ "$(docker inspect -f "{{.State.Health.Status}}" postgres)" = healthy ]; do sleep 1; done' echo "POCKET_ID_TEST_POSTGRES_URL=postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" >> "$GITHUB_ENV" echo "POCKET_ID_TEST_POSTGRES_REQUIRED=true" >> "$GITHUB_ENV" - name: Run backend unit tests working-directory: backend run: go test "-tags=exclude_frontend,unit" -v ./... test-backend-race: name: Backend (race detector) runs-on: depot-ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: go-version-file: "backend/go.mod" cache-dependency-path: "backend/go.sum" - name: Install dependencies working-directory: backend run: | go get ./... - name: Run backend unit tests with the race detector working-directory: backend run: go test -race "-tags=exclude_frontend,unit" ./...