Files
cv-site/.github/workflows/test.yml
T
juanatsap 0be8972429 fix: Skip PDF integration tests in CI
PDF generation tests require a running HTTP server for chromedp to connect to.
This is not available in CI environment, causing tests to fail with ERR_CONNECTION_REFUSED.

Changes:
- Added skip condition to TestDefaultCVShortcut when running in short mode
- Updated CI workflow to use -short flag for tests and benchmarks
- Removed Chrome installation from CI (not needed for unit tests)
- Integration tests can still run locally without -short flag
2025-11-25 06:10:26 +00:00

93 lines
2.5 KiB
YAML

name: Test CV Site
on:
pull_request:
branches: [main, develop]
push:
branches: [main, develop]
jobs:
test:
name: Test on Go ${{ matrix.go-version }}
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.25.1']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache: true
- name: Install dependencies
run: go mod download
- name: Verify dependencies
run: go mod verify
- name: Run linter
uses: golangci/golangci-lint-action@v7
with:
version: v2.6.0
- name: Run unit tests with coverage
run: |
# Use -short to skip integration tests that require running server
# PDF generation tests need a live HTTP server and Chrome
go test -short -v -race -coverprofile=coverage.txt -covermode=atomic ./...
- name: Generate coverage report
run: |
go tool cover -func=coverage.txt | tee coverage-report.txt
- name: Check coverage threshold
run: |
coverage=$(go tool cover -func=coverage.txt | grep total | awk '{print $3}' | sed 's/%//')
echo "Total coverage: ${coverage}%"
echo "COVERAGE=${coverage}" >> $GITHUB_ENV
if (( $(echo "$coverage < 70" | bc -l) )); then
echo "⚠️ Coverage ${coverage}% is below target of 70%"
echo "This is a warning, not a failure (building towards 70% coverage)"
else
echo "✅ Coverage ${coverage}% meets or exceeds target"
fi
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./coverage.txt
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
- name: Run benchmarks
run: |
go test -short -bench=. -benchmem ./... | tee benchmark.txt
- name: Build binary
run: |
go build -v -o cv-server .
- name: Upload test artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-go-${{ matrix.go-version }}
path: |
coverage.txt
coverage-report.txt
benchmark.txt
retention-days: 30
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: cv-server-binary
path: cv-server
retention-days: 7