refactor: split sync_test.go into focused test files #1100
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 | |
| with: | |
| go-version: '1.24' | |
| - name: Build | |
| run: go build ./... | |
| - name: Test with race detection (Linux/macOS) | |
| if: matrix.os != 'windows-latest' | |
| run: go test -race -tags integration ./... | |
| - name: Test (Windows) | |
| if: matrix.os == 'windows-latest' | |
| shell: pwsh | |
| run: | | |
| # go test on Windows can exit 1 due to temp .exe cleanup | |
| # ("go: remove ...\.exe: Access is denied") even when all | |
| # tests pass. Only suppress that specific pattern. | |
| go test -tags integration ./... 2>&1 | Tee-Object -Variable testOut | |
| $exitCode = $LASTEXITCODE | |
| if ($exitCode -ne 0) { | |
| $failed = $testOut | Select-String "^FAIL\s" | |
| if ($failed) { | |
| Write-Host "Tests failed:" | |
| Write-Host ($failed -join "`n") | |
| exit 1 | |
| } | |
| $cleanup = $testOut | Select-String "go: remove .+\.exe: Access is denied" | |
| if (-not $cleanup) { | |
| Write-Host "go test failed with unknown error" | |
| exit $exitCode | |
| } | |
| Write-Host "All tests passed (ignoring temp .exe cleanup error)" | |
| exit 0 | |
| } | |
| - name: Build with CGO disabled | |
| run: go build ./... | |
| env: | |
| CGO_ENABLED: 0 | |
| coverage: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 | |
| with: | |
| go-version: '1.24' | |
| - name: Test with coverage | |
| # -p 1 serializes package execution to avoid ROBOREV_DATA_DIR race conditions | |
| # between tests in different packages that modify this environment variable | |
| run: go test -race -tags integration -p 1 -coverprofile=coverage.out ./... | |
| - name: Upload coverage | |
| uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 | |
| with: | |
| file: coverage.out | |
| continue-on-error: true | |
| integration: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:16-alpine | |
| env: | |
| POSTGRES_USER: roborev_test | |
| POSTGRES_PASSWORD: roborev_test_password | |
| POSTGRES_DB: roborev_test | |
| ports: | |
| - 5433:5432 | |
| options: >- | |
| --health-cmd "pg_isready -U roborev_test -d roborev_test" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 | |
| with: | |
| go-version: '1.24' | |
| - name: Run integration tests | |
| run: go test -tags=postgres -v ./internal/storage/... -run Integration | |
| env: | |
| TEST_POSTGRES_URL: postgres://roborev_test:roborev_test_password@localhost:5433/roborev_test | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 | |
| with: | |
| go-version: '1.24' | |
| - name: golangci-lint | |
| uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0 | |
| with: | |
| version: v2.10.1 | |
| nix: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: cachix/install-nix-action@2126ae7fc54c9df00dd18f7f18754393182c73cd # v31.9.1 | |
| with: | |
| nix_path: nixpkgs=channel:nixos-unstable | |
| - name: Check flake | |
| run: nix flake check | |
| - name: Build package | |
| run: nix build | |
| - name: Verify binaries | |
| run: ./result/bin/roborev version | |
| - name: Verify nix apps | |
| run: nix run .#roborev -- version |