55 workflow_dispatch :
66
77jobs :
8+ test_setup_python :
9+ name : Test setup-python
10+ runs-on : ${{ matrix.os }}
11+ strategy :
12+ matrix :
13+ os : [windows-latest, ubuntu-latest]
14+ python-version : [3.9, '3.10', 3.11, 3.12, 3.13]
15+ steps :
16+ - name : Check out repo
17+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
18+ - name : Set up Python
19+ uses : ./setup-python
20+ with :
21+ python-version : ${{ matrix.python-version }}
22+ - name : Check Python version
23+ run : |
24+ import sys
25+ version = sys.version_info[:2]
26+ expected_version = tuple(map(int, "${{ matrix.python-version }}".split(".")))
27+ if version != expected_version:
28+ print(f"::error title=Test Failure::The Python version does not match. Got {version}, expected {expected_version}.")
29+ sys.exit(1)
30+ shell : python
31+
32+ test_setup_poetry :
33+ name : Test setup-poetry
34+ runs-on : ${{ matrix.os }}
35+ strategy :
36+ matrix :
37+ os : [windows-latest, ubuntu-latest]
38+ python-version : [3.9, '3.10', 3.11, 3.12, 3.13]
39+ steps :
40+ - name : Check out repo
41+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
42+ - name : Set up Python
43+ uses : ./setup-python
44+ with :
45+ python-version : ${{ matrix.python-version }}
46+ - name : Set up Poetry
47+ uses : ./setup-poetry
48+ - name : Create project
49+ run : poetry new test-project
50+ - name : Check that the project was created
51+ run : |
52+ if [ ! -f test-project/pyproject.toml ]; then
53+ echo "::error title=Test Failure::The project file does not exist."
54+ exit 1
55+ fi
56+ shell : bash
57+
58+ test_setup_poetry_cache_hit :
59+ name : Test setup-poetry (cache hit)
60+ runs-on : ${{ matrix.os }}
61+ needs : test_setup_poetry
62+ strategy :
63+ matrix :
64+ os : [windows-latest, ubuntu-latest]
65+ python-version : [3.9, '3.10', 3.11, 3.12, 3.13]
66+ steps :
67+ - name : Check out repo
68+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
69+ - name : Set up Python
70+ uses : ./setup-python
71+ with :
72+ python-version : ${{ matrix.python-version }}
73+ - name : Set up Poetry
74+ id : setup-poetry
75+ uses : ./setup-poetry
76+ - name : Error if cache miss
77+ if : steps.setup-poetry.outputs.cache-hit != 'true'
78+ run : echo "::error title=Test Failure::Expected cache hit."; exit 1
79+ shell : bash
80+ - name : Create project
81+ run : poetry new test-project
82+ - name : Check that the project was created
83+ run : |
84+ if [ ! -f test-project/pyproject.toml ]; then
85+ echo "::error title=Test Failure::The project file does not exist."
86+ exit 1
87+ fi
88+ shell : bash
89+
90+ test_setup_poetry_no_cache :
91+ name : Test setup-poetry (no cache)
92+ runs-on : ${{ matrix.os }}
93+ needs : test_setup_poetry
94+ strategy :
95+ matrix :
96+ os : [windows-latest, ubuntu-latest]
97+ python-version : [3.9, '3.10', 3.11, 3.12, 3.13]
98+ steps :
99+ - name : Check out repo
100+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
101+ - name : Set up Python
102+ uses : ./setup-python
103+ with :
104+ python-version : ${{ matrix.python-version }}
105+ - name : Set up Poetry
106+ id : setup-poetry
107+ uses : ./setup-poetry
108+ with :
109+ use-cache : false
110+ - name : Error if cache hit
111+ if : steps.setup-poetry.outputs.cache-hit == 'true'
112+ run : echo "::error title=Test Failure::Expected cache miss."; exit 1
113+ shell : bash
114+ - name : Create project
115+ run : poetry new test-project
116+ - name : Check that the project was created
117+ run : |
118+ if [ ! -f test-project/pyproject.toml ]; then
119+ echo "::error title=Test Failure::The project file does not exist."
120+ exit 1
121+ fi
122+ shell : bash
123+
8124 test_check_project_version :
9125 name : Test check-project-version
10126 runs-on : ubuntu-latest
38154 run : |
39155 echo "::error title=Test Failure::The previous step did not fail as expected."
40156 exit 1
157+
41158 test_update_project_version :
42159 name : Test update-project-version
43160 runs-on : ubuntu-latest
@@ -84,3 +201,22 @@ jobs:
84201 with :
85202 project-directory : test-project
86203 expected-version : 1.0.2.dev1
204+
205+ # This job is intended to combine the test results so we don't have to list
206+ # each matrix combination in the required status check settings. There are a
207+ # lot of corner cases that make this harder than it should be; see See
208+ # https://github.com/orgs/community/discussions/26822 for more info.
209+ test_results :
210+ name : Test Results
211+ runs-on : ubuntu-latest
212+ needs : [
213+ test_setup_python,
214+ test_setup_poetry,
215+ test_setup_poetry_cache_hit,
216+ test_setup_poetry_no_cache,
217+ test_check_project_version,
218+ test_update_project_version
219+ ]
220+ if : ${{ !cancelled() }}
221+ steps :
222+ - run : exit 0
0 commit comments