|
| 1 | +name: Integration tests |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + secrets: |
| 6 | + APIFY_TEST_USER_PYTHON_SDK_API_TOKEN: |
| 7 | + description: API token of the Python testing user on Apify |
| 8 | + required: true |
| 9 | + |
| 10 | +# Concurrency control to ensure only one instance of this workflow runs at a time. |
| 11 | +# This avoids exceeding API usage limits on the test user account. |
| 12 | +concurrency: |
| 13 | + group: integration_tests |
| 14 | + |
| 15 | +jobs: |
| 16 | + # Job to run integration tests from the main repository. |
| 17 | + integration_tests_on_main: |
| 18 | + name: Integration tests (main repository) |
| 19 | + runs-on: ubuntu-latest |
| 20 | + # If PR is from the main repository or it is a push to master. |
| 21 | + if: github.event.pull_request.head.repo.owner.login == 'apify' || github.ref == 'refs/heads/master' |
| 22 | + strategy: |
| 23 | + matrix: |
| 24 | + python-version: ["3.9", "3.12"] # Oldest and newest supported Python versions. |
| 25 | + max-parallel: 1 # No parallel tests to avoid exceeding API limits. |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout repository |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Set up Python ${{ matrix.python-version }} |
| 32 | + uses: actions/setup-python@v5 |
| 33 | + with: |
| 34 | + python-version: ${{ matrix.python-version }} |
| 35 | + |
| 36 | + - name: Install Python dependencies |
| 37 | + run: | |
| 38 | + pipx install --python ${{ matrix.python-version }} poetry |
| 39 | + make install-dev |
| 40 | +
|
| 41 | + - name: Run integration tests |
| 42 | + run: make INTEGRATION_TESTS_CONCURRENCY=8 integration-tests |
| 43 | + env: |
| 44 | + APIFY_TEST_USER_API_TOKEN: ${{ secrets.APIFY_TEST_USER_PYTHON_SDK_API_TOKEN }} |
| 45 | + |
| 46 | + # Job to request approval before running integration tests for PRs from forks. |
| 47 | + integration_tests_on_fork_approval: |
| 48 | + name: Approve integration tests for fork PR |
| 49 | + runs-on: ubuntu-latest |
| 50 | + # If the PR is from a fork. |
| 51 | + if: github.event.pull_request.head.repo.owner.login != 'apify' |
| 52 | + environment: |
| 53 | + name: fork-pr-integration-tests |
| 54 | + url: ${{ github.event.pull_request.html_url }} |
| 55 | + steps: |
| 56 | + - name: Await approval |
| 57 | + run: echo "Waiting for approval to run integration tests for fork PR." |
| 58 | + |
| 59 | + # Job to run integration tests for PRs from forks, only after manual approval. |
| 60 | + integration_tests_on_fork: |
| 61 | + name: Integration tests (fork after approval) |
| 62 | + needs: integration_tests_on_fork_approval |
| 63 | + # If the PR is from a fork. |
| 64 | + if: github.event.pull_request.head.repo.owner.login != 'apify' |
| 65 | + runs-on: ubuntu-latest |
| 66 | + strategy: |
| 67 | + matrix: |
| 68 | + python-version: ["3.9", "3.12"] # Oldest and newest supported Python versions. |
| 69 | + max-parallel: 1 # No parallel tests to avoid overshooting limits. |
| 70 | + |
| 71 | + steps: |
| 72 | + - name: Checkout repository |
| 73 | + uses: actions/checkout@v4 |
| 74 | + |
| 75 | + - name: Set up Python ${{ matrix.python-version }} |
| 76 | + uses: actions/setup-python@v5 |
| 77 | + with: |
| 78 | + python-version: ${{ matrix.python-version }} |
| 79 | + |
| 80 | + - name: Install Python dependencies |
| 81 | + run: | |
| 82 | + pipx install --python ${{ matrix.python-version }} poetry |
| 83 | + make install-dev |
| 84 | +
|
| 85 | + - name: Run integration tests |
| 86 | + run: make INTEGRATION_TESTS_CONCURRENCY=8 integration-tests |
| 87 | + env: |
| 88 | + APIFY_TEST_USER_API_TOKEN: ${{ secrets.APIFY_TEST_USER_PYTHON_SDK_API_TOKEN }} |
0 commit comments