name: test on: push: branches: [main] pull_request: workflow_dispatch: permissions: contents: read jobs: test: runs-on: ubuntu-latest timeout-minutes: 15 services: postgres: image: postgres:18 env: POSTGRES_USER: chess_test POSTGRES_PASSWORD: chess_test POSTGRES_DB: chess_test ports: - 5432:5432 options: >- --health-cmd "pg_isready -U chess_test -d chess_test" --health-interval 2s --health-timeout 5s --health-retries 30 env: CHESS_TEST_DSN: postgres://chess_test:chess_test@localhost:5432/chess_test?sslmode=disable steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 with: go-version: '1.27.x' - name: Install Stockfish for the rules-core cross-check run: sudo apt-get update -qq && sudo apt-get install -y -qq stockfish - name: gofmt run: test -z "$(gofmt -l .)" || { gofmt -l .; exit 1; } - run: go vet ./... - run: go test -race -count=1 ./... - name: Cross-compile static FreeBSD server and WASM client env: CGO_ENABLED: '0' run: | GOOS=freebsd GOARCH=amd64 go build -trimpath -o /dev/null ./cmd/chess-server GOOS=js GOARCH=wasm go build -trimpath -o /dev/null ./cmd/chess-client-cli e2e: runs-on: ubuntu-latest timeout-minutes: 20 services: postgres: image: postgres:18 env: POSTGRES_USER: chess_test POSTGRES_PASSWORD: chess_test POSTGRES_DB: chess_test ports: - 5432:5432 options: >- --health-cmd "pg_isready -U chess_test -d chess_test" --health-interval 2s --health-timeout 5s --health-retries 30 env: CHESS_TEST_DSN: postgres://chess_test:chess_test@localhost:5432/chess_test?sslmode=disable steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 with: go-version: '1.27.x' - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: node-version: '22' - name: Install Stockfish run: sudo apt-get update -qq && sudo apt-get install -y -qq stockfish - name: Build the server run: make server - name: Install Playwright and Chromium working-directory: test/e2e run: npm install && npx playwright install --with-deps chromium - name: Start the test server with the web client run: | WEB_PORT=9090 MAIL_DIR="$RUNNER_TEMP/chess-mail" LOG_LEVEL=info test/run-test-server.sh bin/chess-server > server.log 2>&1 & for i in $(seq 1 60); do curl -sf http://localhost:8080/health && break; sleep 1; done curl -sf http://localhost:8080/health - name: Run the web client tests working-directory: test/e2e env: CHESS_E2E_MAIL_DIR: ${{ runner.temp }}/chess-mail run: npm test - name: Server log if: failure() run: tail -n 200 server.log - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 if: failure() with: name: playwright-traces path: test/e2e/test-results/ if-no-files-found: ignore