Test actions #1
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: Test actions | |
| on: | |
| workflow_call: | |
| workflow_dispatch: | |
| jobs: | |
| test_setup_python: | |
| name: Test setup-python | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [windows-latest, ubuntu-latest, macos-latest] | |
| python-version: [3.9, '3.10', 3.11, 3.12, 3.13, 3.13t, pypy3.10, pypy3.11] | |
| steps: | |
| - name: Check out repo | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Set up Python | |
| uses: ./setup-python | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Check Python version | |
| run: | | |
| import sys, sysconfig | |
| version = sys.version_info[:2] | |
| expected_version = tuple(map(int, "${{ matrix.python-version }}".removeprefix("pypy").removesuffix("t").split("."))) | |
| if version != expected_version: | |
| print(f"::error title=Test Failure::The Python version does not match. Got {version}, expected {expected_version}.") | |
| sys.exit(1) | |
| implementation = sys.implementation.name | |
| expected_implementation = "pypy" if "${{ matrix.python-version }}".startswith("pypy") else "cpython" | |
| if implementation != expected_implementation: | |
| print(f"::error title=Test Failure::The Python implementation does not match. Got {implementation}, expected {expected_implementation}.") | |
| sys.exit(1) | |
| threading = "free-threading" if sysconfig.get_config_var("Py_GIL_DISABLED") else "GIL" | |
| expected_threading = "free-threading" if "${{ matrix.python-version }}".endswith("t") else "GIL" | |
| if threading != expected_threading: | |
| print(f"::error title=Test Failure::The Python threading does not match. Got {threading}, expected {expected_threading}.") | |
| sys.exit(1) | |
| shell: python | |
| test_setup_poetry: | |
| name: Test setup-poetry | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [windows-latest, ubuntu-latest, macos-latest] | |
| python-version: [3.9, '3.10', 3.11, 3.12, 3.13, pypy3.10, pypy3.11] | |
| steps: | |
| - name: Check out repo | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Set up Python | |
| uses: ./setup-python | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Set up Poetry | |
| uses: ./setup-poetry | |
| - name: Create project | |
| run: poetry new test-project | |
| - name: Check that the project was created | |
| run: | | |
| if [ ! -f test-project/pyproject.toml ]; then | |
| echo "::error title=Test Failure::The project file does not exist." | |
| exit 1 | |
| fi | |
| shell: bash | |
| test_setup_poetry_cache_hit: | |
| name: Test setup-poetry (cache hit) | |
| runs-on: ${{ matrix.os }} | |
| needs: test_setup_poetry | |
| strategy: | |
| matrix: | |
| os: [windows-latest, ubuntu-latest, macos-latest] | |
| python-version: [3.9, '3.10', 3.11, 3.12, 3.13, pypy3.10, pypy3.11] | |
| steps: | |
| - name: Check out repo | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Set up Python | |
| uses: ./setup-python | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Set up Poetry | |
| id: setup-poetry | |
| uses: ./setup-poetry | |
| - name: Error if cache miss | |
| if: steps.setup-poetry.outputs.cache-hit != 'true' | |
| run: echo "::error title=Test Failure::Expected cache hit."; exit 1 | |
| shell: bash | |
| - name: Create project | |
| run: poetry new test-project | |
| - name: Check that the project was created | |
| run: | | |
| if [ ! -f test-project/pyproject.toml ]; then | |
| echo "::error title=Test Failure::The project file does not exist." | |
| exit 1 | |
| fi | |
| shell: bash | |
| test_setup_poetry_no_cache: | |
| name: Test setup-poetry (no cache) | |
| runs-on: ${{ matrix.os }} | |
| needs: test_setup_poetry | |
| strategy: | |
| matrix: | |
| os: [windows-latest, ubuntu-latest, macos-latest] | |
| python-version: [3.9, '3.10', 3.11, 3.12, 3.13, pypy3.10, pypy3.11] | |
| steps: | |
| - name: Check out repo | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Set up Python | |
| uses: ./setup-python | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Set up Poetry | |
| id: setup-poetry | |
| uses: ./setup-poetry | |
| with: | |
| use-cache: false | |
| - name: Error if cache hit | |
| if: steps.setup-poetry.outputs.cache-hit == 'true' | |
| run: echo "::error title=Test Failure::Expected cache miss."; exit 1 | |
| shell: bash | |
| - name: Create project | |
| run: poetry new test-project | |
| - name: Check that the project was created | |
| run: | | |
| if [ ! -f test-project/pyproject.toml ]; then | |
| echo "::error title=Test Failure::The project file does not exist." | |
| exit 1 | |
| fi | |
| shell: bash | |
| test_check_project_version: | |
| name: Test check-project-version | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repo | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Set up Python | |
| uses: ./setup-python | |
| - name: Set up Poetry | |
| uses: ./setup-poetry | |
| - name: Create project with version 1.0.0 | |
| run: | | |
| poetry new test-project | |
| poetry version 1.0.0 -C test-project | |
| - name: Check version == 1.0.0 | |
| uses: ./check-project-version | |
| with: | |
| project-directory: test-project | |
| expected-version: 1.0.0 | |
| - name: Create a notice about the expected failure | |
| run: echo "::notice title=Notice::The next step is expected to fail." | |
| - name: Check version == 1.0.1 (expected to fail) | |
| id: expected-failure | |
| continue-on-error: true | |
| uses: ./check-project-version | |
| with: | |
| project-directory: test-project | |
| expected-version: 1.0.1 | |
| - name: Error if the previous step didn't fail | |
| if: steps.expected-failure.outcome != 'failure' | |
| run: | | |
| echo "::error title=Test Failure::The previous step did not fail as expected." | |
| exit 1 | |
| test_update_project_version: | |
| name: Test update-project-version | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repo | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Set up Python | |
| uses: ./setup-python | |
| - name: Set up Poetry | |
| uses: ./setup-poetry | |
| - name: Create project with version 1.0.0 | |
| run: | | |
| poetry new test-project | |
| poetry version 1.0.0 -C test-project | |
| - name: Update version to 1.0.1 | |
| uses: ./update-project-version | |
| with: | |
| project-directory: test-project | |
| create-pull-request: false | |
| version-rule: patch | |
| use-dev-suffix: false | |
| - name: Check version == 1.0.1 | |
| uses: ./check-project-version | |
| with: | |
| project-directory: test-project | |
| expected-version: 1.0.1 | |
| - name: Update version to 1.0.2.dev0 | |
| uses: ./update-project-version | |
| with: | |
| project-directory: test-project | |
| create-pull-request: false | |
| - name: Check version == 1.0.2.dev0 | |
| uses: ./check-project-version | |
| with: | |
| project-directory: test-project | |
| expected-version: 1.0.2.dev0 | |
| - name: Update version to 1.0.2.dev1 | |
| uses: ./update-project-version | |
| with: | |
| project-directory: test-project | |
| create-pull-request: false | |
| - name: Check version == 1.0.2.dev1 | |
| uses: ./check-project-version | |
| with: | |
| project-directory: test-project | |
| expected-version: 1.0.2.dev1 | |
| test_analyze_project: | |
| name: Test analyze-project | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [windows-latest, ubuntu-latest, macos-latest] | |
| python-version: [3.9, '3.10', 3.11, 3.12, 3.13, pypy3.10, pypy3.11] | |
| steps: | |
| - name: Check out repo | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Set up Python | |
| uses: ./setup-python | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Set up Poetry | |
| uses: ./setup-poetry | |
| - name: Analyze Python project | |
| uses: ./analyze-project | |
| with: | |
| project-directory: ${{ github.workspace }}/.github/test_projects/minimal | |
| test_analyze_project_in_root: | |
| name: Test analyze-project in root of repo | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [windows-latest, ubuntu-latest, macos-latest] | |
| python-version: [3.9, '3.10', 3.11, 3.12, 3.13, pypy3.10, pypy3.11] | |
| steps: | |
| - name: Check out repo | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Set up Python | |
| uses: ./setup-python | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Set up Poetry | |
| uses: ./setup-poetry | |
| - name: Copy Python project to root | |
| run: cp -av "${{ github.workspace }}/.github/test_projects/minimal/*" "${{ github.workspace }}" | |
| shell: bash | |
| - name: Analyze Python project | |
| uses: ./analyze-project | |
| # This job is intended to combine the test results so we don't have to list | |
| # each matrix combination in the required status check settings. There are a | |
| # lot of corner cases that make this harder than it should be; see See | |
| # https://github.com/orgs/community/discussions/26822 for more info. | |
| test_results: | |
| name: Test Results | |
| runs-on: ubuntu-latest | |
| needs: [ | |
| test_setup_python, | |
| test_setup_poetry, | |
| test_setup_poetry_cache_hit, | |
| test_setup_poetry_no_cache, | |
| test_check_project_version, | |
| test_update_project_version, | |
| test_analyze_project, | |
| test_analyze_project_in_root, | |
| ] | |
| if: ${{ !cancelled() }} | |
| steps: | |
| - run: exit 0 |