Repository navigation
Add --debug option #72
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, develop] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| inputs: | |
| bump: | |
| description: "Version for main's head: auto follows the merged PR's release:* label and releases only when something that ships changed" | |
| type: choice | |
| options: [auto, patch, minor, major] | |
| default: auto | |
| dry_run: | |
| description: Only report what would be released | |
| type: boolean | |
| default: true | |
| permissions: {} | |
| # Runs on main test, tag and release one at a time, in order; each waits its | |
| # turn rather than replacing a waiting one. Other runs never wait. | |
| concurrency: | |
| group: ${{ github.ref == 'refs/heads/main' && 'release-main' || github.run_id }} | |
| cancel-in-progress: false | |
| queue: max | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| # 1.25 is the minimum in go.mod for go install users; stable builds the releases. | |
| go: ["1.25", stable] | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 | |
| with: | |
| go-version: ${{ matrix.go }} | |
| check-latest: true | |
| - name: gofmt | |
| run: | | |
| unformatted=$(gofmt -l .) | |
| [ -z "$unformatted" ] || { echo "Run gofmt -w on: $unformatted"; exit 1; } | |
| - run: go vet ./... | |
| - run: go build ./cmd/serpapi | |
| - run: go test -race ./pkg/... | |
| e2e: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 | |
| with: | |
| go-version: stable | |
| check-latest: true | |
| # Fork PRs get no secrets, so only the offline contract tests run there. | |
| # Anywhere else a skipped live test fails the job, since main's runs | |
| # release when they pass. | |
| - name: Run E2E tests | |
| shell: bash | |
| env: | |
| SERPAPI_KEY: ${{ secrets.SERPAPI_KEY }} | |
| REQUIRE_LIVE: ${{ github.event_name != 'pull_request' }} | |
| run: | | |
| go test -v ./tests/... | tee e2e.log | |
| if [ "$REQUIRE_LIVE" = true ] && grep -q -- '--- SKIP' e2e.log; then | |
| echo "::error::Live e2e tests were skipped: is the SERPAPI_KEY secret set?" | |
| exit 1 | |
| fi | |
| # After the tests pass on main, release-tag.sh tags the commit with the next | |
| # version, and release.yml releases it. A tag pushed with GITHUB_TOKEN | |
| # doesn't start release.yml's tag trigger, so this run calls it. | |
| release-script: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| persist-credentials: false | |
| - run: python3 .github/scripts/release-tag-test.py | |
| tag: | |
| needs: [test, e2e, release-script] | |
| if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: read | |
| outputs: | |
| tag: ${{ steps.tag.outputs.tag }} | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - id: tag | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| SHA: ${{ github.sha }} | |
| BUMP: ${{ inputs.bump || 'auto' }} | |
| DRY_RUN: ${{ inputs.dry_run || false }} | |
| run: bash .github/scripts/release-tag.sh | |
| release: | |
| needs: tag | |
| if: needs.tag.outputs.tag != '' | |
| permissions: | |
| contents: write | |
| uses: ./.github/workflows/release.yml | |
| with: | |
| tag: ${{ needs.tag.outputs.tag }} | |
| sha: ${{ github.sha }} | |
| secrets: inherit |