fix(scrape): cancel queued work and fail closed on budget #227
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: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| concurrency: | |
| group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| ruff: | |
| name: Ruff | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v7 | |
| - name: Run Ruff | |
| # ruff-action has v4.1.0 / v4.0.0 tags, not a floating v4 major. | |
| uses: astral-sh/ruff-action@v4.1.0 | |
| with: | |
| version: "0.16.3" | |
| args: check --output-format=github | |
| - name: Check Ruff format | |
| uses: astral-sh/ruff-action@v4.1.0 | |
| with: | |
| version: "0.16.3" | |
| args: format --check | |
| hadolint: | |
| name: Hadolint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v7 | |
| - name: Lint Dockerfile | |
| run: docker run --rm -i hadolint/hadolint < Dockerfile | |
| spectral: | |
| name: Spectral | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v7 | |
| - name: Lint OpenAPI | |
| run: make spectral | |
| lint: | |
| name: Lint | |
| if: ${{ !cancelled() }} | |
| needs: [ruff, hadolint, spectral] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Require Ruff, Hadolint, and Spectral | |
| run: | | |
| test "${{ needs.ruff.result }}" = "success" | |
| test "${{ needs.hadolint.result }}" = "success" | |
| test "${{ needs.spectral.result }}" = "success" | |
| unit-tests: | |
| name: Run unit tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v7 | |
| - name: Get Python version from Dockerfile | |
| id: get-version | |
| run: | | |
| # Extract version like "3.14" from "FROM python:3.14-slim..." | |
| VERSION=$(grep -m 1 "^FROM python:" Dockerfile | sed -E 's/^FROM python:([0-9]+\.[0-9]+).*/\1/') | |
| if [ -z "$VERSION" ]; then | |
| echo "Error: Could not extract Python version from Dockerfile" | |
| exit 1 | |
| fi | |
| echo "Extracted version: $VERSION" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Set up Python | |
| uses: actions/setup-python@v7 | |
| with: | |
| python-version: ${{ steps.get-version.outputs.version }} | |
| cache: "pip" | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install -r requirements-dev.txt | |
| - name: Execute unit test suite | |
| run: python -m unittest discover -s tests -p "test_*.py" -v | |
| - name: Typecheck | |
| run: make typecheck | |
| - name: Verify OpenAPI snapshot | |
| run: make openapi-verify | |
| docker-smoke-image: | |
| name: Docker smoke image (linux/amd64, cache) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| actions: write | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v7 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Build and cache smoke image | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| push: false | |
| load: true | |
| platforms: linux/amd64 | |
| tags: botasaurus-api-smoke:ci | |
| cache-from: type=gha,scope=smoke-linux-amd64 | |
| cache-to: type=gha,mode=max,scope=smoke-linux-amd64 | |
| smoke-test: | |
| name: ${{ matrix.title }} | |
| needs: docker-smoke-image | |
| runs-on: ubuntu-latest | |
| timeout-minutes: ${{ matrix.timeout_minutes }} | |
| permissions: | |
| contents: read | |
| actions: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - title: "Smoke (prewarm=false, cold)" | |
| profile: contract-prewarm-off | |
| timeout_minutes: 30 | |
| - title: "Smoke (prewarm=true, warm-handoff)" | |
| profile: prewarm-on-warm-handoff | |
| timeout_minutes: 20 | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v7 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Load smoke image from cache | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| push: false | |
| load: true | |
| platforms: linux/amd64 | |
| tags: botasaurus-api-smoke:ci | |
| cache-from: type=gha,scope=smoke-linux-amd64 | |
| - name: Execute smoke profile | |
| env: | |
| SMOKE_SKIP_BUILD: "1" | |
| SMOKE_IMAGE_NAME: botasaurus-api-smoke:ci | |
| SMOKE_PROFILE: ${{ matrix.profile }} | |
| run: make smoke |