diff --git a/.github/workflows/_check_code.yaml b/.github/workflows/_check_code.yaml deleted file mode 100644 index 012c966..0000000 --- a/.github/workflows/_check_code.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: Code checks - -on: - # Runs when manually triggered from the GitHub UI. - workflow_dispatch: - - # Runs when invoked by another workflow. - workflow_call: - -jobs: - actions_lint_check: - name: Actions lint check - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v6 - - name: Run actionlint - uses: rhysd/actionlint@v1.7.9 - - spell_check: - name: Spell check - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v6 - - name: Check spelling with typos - uses: crate-ci/typos@v1 - - lint_check: - name: Lint check - uses: apify/workflows/.github/workflows/python_lint_check.yaml@main - with: - python_versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]' - - type_check: - name: Type check - uses: apify/workflows/.github/workflows/python_type_check.yaml@main - with: - python_versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]' diff --git a/.github/workflows/_check_package.yaml b/.github/workflows/_check_package.yaml deleted file mode 100644 index dc32052..0000000 --- a/.github/workflows/_check_package.yaml +++ /dev/null @@ -1,36 +0,0 @@ -name: Package check - -on: - # Runs when manually triggered from the GitHub UI. - workflow_dispatch: - - # Runs when invoked by another workflow. - workflow_call: - -permissions: - contents: read - -jobs: - package_check: - name: Package check - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v6 - - - name: Set up uv package manager - uses: astral-sh/setup-uv@v8.1.0 - with: - python-version: "3.14" - - - name: Build sdist and wheel - run: uv run poe build - - - name: Verify built package - uses: apify/actions/python-package-check@v1.1.0 - with: - package_name: apify_shared - dist_dir: dist - python_version: "3.14" - smoke_code: | - from apify_shared.consts import WebhookEventType diff --git a/.github/workflows/_checks.yaml b/.github/workflows/_checks.yaml new file mode 100644 index 0000000..3dc8d35 --- /dev/null +++ b/.github/workflows/_checks.yaml @@ -0,0 +1,88 @@ +name: Checks + +on: + # Runs when manually triggered from the GitHub UI. + workflow_dispatch: + inputs: + run_tests: + description: Whether to run the unit test suite. + required: false + type: boolean + default: true + + # Runs when invoked by another workflow. + workflow_call: + inputs: + run_tests: + description: Whether to run the unit test suite. + required: false + type: boolean + default: true + +permissions: + contents: read + +jobs: + actions_lint_check: + name: Actions lint check + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v6 + - name: Run actionlint + uses: rhysd/actionlint@v1.7.9 + + spell_check: + name: Spell check + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v6 + - name: Check spelling with typos + uses: crate-ci/typos@v1 + + lint_check: + name: Lint check + uses: apify/workflows/.github/workflows/python_lint_check.yaml@main + with: + python_versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]' + + type_check: + name: Type check + uses: apify/workflows/.github/workflows/python_type_check.yaml@main + with: + python_versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]' + + unit_tests: + name: Unit tests + if: inputs.run_tests + uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main + with: + python_versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]' + operating_systems: '["ubuntu-latest", "windows-latest"]' + tests_concurrency: "1" + # Codecov inputs omitted - apify-shared-python doesn't use codecov. + + package_check: + name: Package check + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Set up uv package manager + uses: astral-sh/setup-uv@v8.1.0 + with: + python-version: "3.14" + + - name: Build sdist and wheel + run: uv run poe build + + - name: Verify built package + uses: apify/actions/python-package-check@v1.1.0 + with: + package_name: apify_shared + dist_dir: dist + python_version: "3.14" + smoke_code: | + from apify_shared.consts import WebhookEventType diff --git a/.github/workflows/_tests.yaml b/.github/workflows/_tests.yaml deleted file mode 100644 index 9dd851e..0000000 --- a/.github/workflows/_tests.yaml +++ /dev/null @@ -1,18 +0,0 @@ -name: Tests - -on: - # Runs when manually triggered from the GitHub UI. - workflow_dispatch: - - # Runs when invoked by another workflow. - workflow_call: - -jobs: - unit_tests: - name: Unit tests - uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main - with: - python_versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]' - operating_systems: '["ubuntu-latest", "windows-latest"]' - tests_concurrency: "1" - # Codecov inputs omitted - apify-shared-python doesn't use codecov. diff --git a/.github/workflows/manual_release_beta.yaml b/.github/workflows/manual_release_beta.yaml index f1a8f35..1f79d75 100644 --- a/.github/workflows/manual_release_beta.yaml +++ b/.github/workflows/manual_release_beta.yaml @@ -16,8 +16,22 @@ permissions: contents: read jobs: + wait_for_checks: + # Gate the release on the `Checks` workflow already succeeding on this commit (run by `on_master.yaml`). + name: Wait for required checks + runs-on: ubuntu-latest + permissions: + checks: read + steps: + - name: Wait for checks + uses: apify/actions/wait-for-checks@v1.2.0 + with: + ref: ${{ github.sha }} + check-regexp: '^Checks' + release_prepare: name: Release prepare + needs: [wait_for_checks] runs-on: ubuntu-latest outputs: version_number: ${{ steps.release_prepare.outputs.version_number }} diff --git a/.github/workflows/manual_release_stable.yaml b/.github/workflows/manual_release_stable.yaml index 903a932..3931383 100644 --- a/.github/workflows/manual_release_stable.yaml +++ b/.github/workflows/manual_release_stable.yaml @@ -26,17 +26,22 @@ concurrency: cancel-in-progress: false jobs: - code_checks: - name: Code checks - uses: ./.github/workflows/_check_code.yaml - - tests: - name: Tests - uses: ./.github/workflows/_tests.yaml + wait_for_checks: + # Gate the release on the `Checks` workflow already succeeding on this commit (run by `on_master.yaml`). + name: Wait for required checks + runs-on: ubuntu-latest + permissions: + checks: read + steps: + - name: Wait for checks + uses: apify/actions/wait-for-checks@v1.2.0 + with: + ref: ${{ github.sha }} + check-regexp: '^Checks' release_prepare: name: Release prepare - needs: [code_checks, tests] + needs: [wait_for_checks] runs-on: ubuntu-latest outputs: version_number: ${{ steps.release_prepare.outputs.version_number }} diff --git a/.github/workflows/on_master.yaml b/.github/workflows/on_master.yaml index c4dd211..dfe6043 100644 --- a/.github/workflows/on_master.yaml +++ b/.github/workflows/on_master.yaml @@ -8,15 +8,16 @@ on: - "**" # Ignore all tags to avoid duplicate executions triggered by tag pushes. jobs: - code_checks: - name: Code checks - uses: ./.github/workflows/_check_code.yaml - - tests: - # Skip this for "ci" and "docs" commits. - if: "!startsWith(github.event.head_commit.message, 'ci') && !startsWith(github.event.head_commit.message, 'docs')" - name: Tests - uses: ./.github/workflows/_tests.yaml + checks: + name: Checks + uses: ./.github/workflows/_checks.yaml + with: + # Skip the test suite for "ci" and "docs" commits — they don't change runtime behavior. + run_tests: >- + ${{ + !startsWith(github.event.head_commit.message, 'ci') && + !startsWith(github.event.head_commit.message, 'docs') + }} # The beta release is dispatched as a separate workflow run (instead of calling `manual_release_beta.yaml` via `uses:`) # because PyPI's Trusted Publishing does not currently support reusable workflows. @@ -25,7 +26,7 @@ jobs: # Skip this for "ci", "docs" and "test" commits and for forks. if: "!startsWith(github.event.head_commit.message, 'ci') && !startsWith(github.event.head_commit.message, 'docs') && !startsWith(github.event.head_commit.message, 'test') && startsWith(github.repository, 'apify/')" name: Beta release - needs: [code_checks, tests] + needs: [checks] runs-on: ubuntu-latest permissions: actions: write # Required by execute-workflow. diff --git a/.github/workflows/on_pull_request.yaml b/.github/workflows/on_pull_request.yaml index 4660922..2307f9f 100644 --- a/.github/workflows/on_pull_request.yaml +++ b/.github/workflows/on_pull_request.yaml @@ -13,14 +13,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - code_checks: - name: Code checks - uses: ./.github/workflows/_check_code.yaml - - package_check: - name: Package check - uses: ./.github/workflows/_check_package.yaml - - tests: - name: Tests - uses: ./.github/workflows/_tests.yaml + checks: + name: Checks + uses: ./.github/workflows/_checks.yaml