|
| 1 | +name: Checks |
| 2 | + |
| 3 | +on: |
| 4 | + # Runs when manually triggered from the GitHub UI. |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + run_tests: |
| 8 | + description: Whether to run the test suites (unit, integration). |
| 9 | + required: false |
| 10 | + type: boolean |
| 11 | + default: true |
| 12 | + |
| 13 | + # Runs when invoked by another workflow. |
| 14 | + workflow_call: |
| 15 | + inputs: |
| 16 | + run_tests: |
| 17 | + description: Whether to run the test suites (unit, integration). |
| 18 | + required: false |
| 19 | + type: boolean |
| 20 | + default: true |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: read |
| 24 | + |
| 25 | +env: |
| 26 | + PYTHON_VERSION: 3.14 |
| 27 | + |
| 28 | +jobs: |
| 29 | + actions_lint_check: |
| 30 | + name: Actions lint check |
| 31 | + runs-on: ubuntu-latest |
| 32 | + steps: |
| 33 | + - name: Checkout repository |
| 34 | + uses: actions/checkout@v6 |
| 35 | + - name: Run actionlint |
| 36 | + uses: rhysd/actionlint@v1.7.11 |
| 37 | + |
| 38 | + spell_check: |
| 39 | + name: Spell check |
| 40 | + runs-on: ubuntu-latest |
| 41 | + steps: |
| 42 | + - name: Checkout repository |
| 43 | + uses: actions/checkout@v6 |
| 44 | + - name: Check spelling with typos |
| 45 | + uses: crate-ci/typos@v1 |
| 46 | + |
| 47 | + lint_check: |
| 48 | + name: Lint check |
| 49 | + uses: apify/workflows/.github/workflows/python_lint_check.yaml@main |
| 50 | + with: |
| 51 | + python_versions: '["3.11", "3.12", "3.13", "3.14"]' |
| 52 | + |
| 53 | + type_check: |
| 54 | + name: Type check |
| 55 | + uses: apify/workflows/.github/workflows/python_type_check.yaml@main |
| 56 | + with: |
| 57 | + python_versions: '["3.11", "3.12", "3.13", "3.14"]' |
| 58 | + |
| 59 | + docstrings_check: |
| 60 | + name: Docstrings check |
| 61 | + runs-on: ubuntu-latest |
| 62 | + steps: |
| 63 | + - name: Checkout repository |
| 64 | + uses: actions/checkout@v6 |
| 65 | + |
| 66 | + - name: Set up Python |
| 67 | + uses: actions/setup-python@v6 |
| 68 | + with: |
| 69 | + python-version: ${{ env.PYTHON_VERSION }} |
| 70 | + |
| 71 | + - name: Set up uv package manager |
| 72 | + uses: astral-sh/setup-uv@v7 |
| 73 | + with: |
| 74 | + python-version: ${{ env.PYTHON_VERSION }} |
| 75 | + |
| 76 | + - name: Install dependencies |
| 77 | + run: uv run poe install-dev |
| 78 | + |
| 79 | + - name: Async docstrings check |
| 80 | + run: uv run poe check-docstrings |
| 81 | + |
| 82 | + unit_tests: |
| 83 | + name: Unit tests |
| 84 | + if: inputs.run_tests |
| 85 | + uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main |
| 86 | + secrets: inherit |
| 87 | + with: |
| 88 | + python_versions: '["3.11", "3.12", "3.13", "3.14"]' |
| 89 | + operating_systems: '["ubuntu-latest", "windows-latest"]' |
| 90 | + python_version_for_codecov: "3.14" |
| 91 | + operating_system_for_codecov: ubuntu-latest |
| 92 | + tests_concurrency: "16" |
| 93 | + |
| 94 | + # Integration tests are inlined (not calling the reusable workflow) to avoid GitHub's compile-time secret |
| 95 | + # validation for nested reusable workflows, which fails on fork PRs where repo secrets are not available. |
| 96 | + integration_tests: |
| 97 | + name: Integration tests (${{ matrix.python-version }}, ${{ matrix.os }}) |
| 98 | + if: >- |
| 99 | + ${{ |
| 100 | + inputs.run_tests && ( |
| 101 | + (github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login == 'apify') || |
| 102 | + (github.event_name == 'push' && github.ref == 'refs/heads/master') || |
| 103 | + github.event_name == 'workflow_dispatch' |
| 104 | + ) |
| 105 | + }} |
| 106 | +
|
| 107 | + strategy: |
| 108 | + matrix: |
| 109 | + os: ["ubuntu-latest"] |
| 110 | + python-version: ["3.11", "3.14"] |
| 111 | + |
| 112 | + runs-on: ${{ matrix.os }} |
| 113 | + |
| 114 | + env: |
| 115 | + TESTS_CONCURRENCY: "16" |
| 116 | + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
| 117 | + |
| 118 | + steps: |
| 119 | + - name: Checkout repository |
| 120 | + uses: actions/checkout@v6 |
| 121 | + |
| 122 | + - name: Set up Python ${{ matrix.python-version }} |
| 123 | + uses: actions/setup-python@v6 |
| 124 | + with: |
| 125 | + python-version: ${{ matrix.python-version }} |
| 126 | + |
| 127 | + - name: Set up uv package manager |
| 128 | + uses: astral-sh/setup-uv@v7 |
| 129 | + with: |
| 130 | + python-version: ${{ matrix.python-version }} |
| 131 | + |
| 132 | + - name: Install Python dependencies |
| 133 | + run: uv run poe install-dev |
| 134 | + |
| 135 | + - name: Run integration tests |
| 136 | + run: uv run poe integration-tests-cov |
| 137 | + env: |
| 138 | + APIFY_TEST_USER_API_TOKEN: ${{ secrets.APIFY_TEST_USER_PYTHON_SDK_API_TOKEN }} |
| 139 | + APIFY_TEST_USER_2_API_TOKEN: ${{ secrets.APIFY_TEST_USER_2_API_TOKEN }} |
| 140 | + |
| 141 | + - name: Upload integration test coverage |
| 142 | + if: >- |
| 143 | + ${{ |
| 144 | + matrix.os == 'ubuntu-latest' && |
| 145 | + matrix.python-version == '3.14' && |
| 146 | + env.CODECOV_TOKEN != '' |
| 147 | + }} |
| 148 | + uses: codecov/codecov-action@v6 |
| 149 | + with: |
| 150 | + token: ${{ env.CODECOV_TOKEN }} |
| 151 | + files: coverage-integration.xml |
| 152 | + flags: integration |
| 153 | + |
| 154 | + package_check: |
| 155 | + name: Package check |
| 156 | + runs-on: ubuntu-latest |
| 157 | + steps: |
| 158 | + - name: Checkout repository |
| 159 | + uses: actions/checkout@v6 |
| 160 | + |
| 161 | + - name: Set up uv package manager |
| 162 | + uses: astral-sh/setup-uv@v8.1.0 |
| 163 | + with: |
| 164 | + python-version: "3.14" |
| 165 | + |
| 166 | + - name: Build sdist and wheel |
| 167 | + run: uv run poe build |
| 168 | + |
| 169 | + - name: Verify built package |
| 170 | + uses: apify/actions/python-package-check@v1.1.0 |
| 171 | + with: |
| 172 | + package_name: apify_client |
| 173 | + dist_dir: dist |
| 174 | + python_version: "3.14" |
| 175 | + smoke_code: | |
| 176 | + from apify_client import ApifyClient, ApifyClientAsync |
| 177 | + ApifyClient(token='x') |
| 178 | + ApifyClientAsync(token='x') |
| 179 | +
|
| 180 | + doc_check: |
| 181 | + name: Doc check |
| 182 | + uses: apify/workflows/.github/workflows/python_docs_check.yaml@main |
0 commit comments