@@ -16,6 +16,13 @@ concurrency:
1616permissions :
1717 contents : read
1818
19+ env :
20+ # Only resolve distributions published at least one week ago, reducing the
21+ # chance of installing packages affected by undetected supply chain attacks
22+ UV_EXCLUDE_NEWER : 7 days
23+ # Make uv pip install into the python provided by setup-python
24+ UV_SYSTEM_PYTHON : 1
25+
1926jobs :
2027
2128 linux :
@@ -30,17 +37,21 @@ jobs:
3037 - uses : actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
3138 with :
3239 python-version : ${{ matrix.python }}
33- cache : pip
40+ - uses : astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
41+ with :
42+ enable-cache : true
43+ cache-suffix : py${{ matrix.python }}
44+ cache-dependency-glob : pyproject.toml
3445 - name : Test without optional dependencies and without pyyaml
3546 run : |
36- pip install .[coverage]
37- pip uninstall -y pyyaml types-PyYAML
47+ uv pip install .[coverage]
48+ uv pip uninstall pyyaml types-PyYAML
3849 pytest --cov --cov-report=term --cov-report=xml --junit-xml=junit.xml
3950 mv coverage.xml coverage_py${{ matrix.python }}_bare.xml
4051 mv junit.xml junit_py${{ matrix.python }}_bare.xml
4152 - name : Test with all optional dependencies
4253 run : |
43- pip install .[test,all]
54+ uv pip install .[test,all]
4455 pytest --cov --cov-report=term --cov-report=xml --junit-xml=junit.xml
4556 mv coverage.xml coverage_py${{ matrix.python }}_all.xml
4657 mv junit.xml junit_py${{ matrix.python }}_all.xml
@@ -131,19 +142,22 @@ jobs:
131142 - uses : actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
132143 with :
133144 python-version : " 3.12"
134- cache : pip
145+ - uses : astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
146+ with :
147+ enable-cache : true
148+ cache-dependency-glob : pyproject.toml
135149 - name : With pydantic<2
136150 run : |
137- pip install .[coverage]
138- pip install "pydantic<2"
151+ uv pip install .[coverage]
152+ uv pip install "pydantic<2"
139153 pytest --cov --cov-report=term --cov-report=xml --junit-xml=junit.xml jsonargparse_tests/test_pydantic.py
140154 mv coverage.xml coverage_pydantic1.xml
141155 mv junit.xml junit_pydantic1.xml
142156 - name : with pydantic>=2
143157 run : |
144158 sed -i "s|import pydantic|import pydantic.v1 as pydantic|" jsonargparse_tests/test_pydantic.py
145159 sed -i "s|^annotated = .*|annotated = False|" jsonargparse_tests/test_pydantic.py
146- pip install "pydantic>=2"
160+ uv pip install "pydantic>=2"
147161 pytest --cov --cov-report=term --cov-report=xml --junit-xml=junit.xml jsonargparse_tests/test_pydantic.py
148162 mv coverage.xml coverage_pydantic2.xml
149163 mv junit.xml junit_pydantic2.xml
@@ -157,6 +171,10 @@ jobs:
157171 path : ./junit_py*
158172
159173 build-package :
174+ # This job builds the artifacts that pypi-publish publishes. To protect
175+ # against cache poisoning attacks, it must not use any cache (actions/cache,
176+ # setup-python's cache or setup-uv's enable-cache) and dependencies must be
177+ # installed with --require-hashes from a lock file.
160178 runs-on : ubuntu-latest
161179 steps :
162180 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -187,21 +205,24 @@ jobs:
187205 - uses : actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
188206 with :
189207 python-version : " 3.12"
190- cache : pip
208+ - uses : astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
209+ with :
210+ enable-cache : true
211+ cache-dependency-glob : pyproject.toml
191212 - uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
192213 with :
193214 name : package
194215 path : dist
195216 - name : Test without optional dependencies and without pyyaml
196217 run : |
197218 cd dist
198- pip install $(ls jsonargparse-*.whl)[test-no-urls] $(ls jsonargparse_tests-*.whl)
199- pip uninstall -y pyyaml
219+ uv pip install $(ls jsonargparse-*.whl)[test-no-urls] $(ls jsonargparse_tests-*.whl)
220+ uv pip uninstall pyyaml
200221 python -m jsonargparse_tests
201222 - name : Test with all optional dependencies
202223 run : |
203224 cd dist
204- pip install $(ls jsonargparse-*.whl)[test,all]
225+ uv pip install $(ls jsonargparse-*.whl)[test,all]
205226 python -m jsonargparse_tests
206227
207228 doctest :
@@ -213,8 +234,11 @@ jobs:
213234 - uses : actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
214235 with :
215236 python-version : " 3.12"
216- cache : pip
217- - run : pip install -e .[all,shtab,doc]
237+ - uses : astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
238+ with :
239+ enable-cache : true
240+ cache-dependency-glob : pyproject.toml
241+ - run : uv pip install -e .[all,shtab,doc]
218242 - name : Run doc tests
219243 run : sphinx-build -M doctest sphinx sphinx/_build sphinx/index.rst
220244
@@ -299,6 +323,8 @@ jobs:
299323 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
300324
301325 pypi-publish :
326+ # This job publishes to PyPI the package created by build-package. Same as
327+ # there, it must not use any cache to protect against cache poisoning.
302328 if : startsWith(github.ref, 'refs/tags/v')
303329 runs-on : ubuntu-latest
304330 needs : [linux, windows, macos, argparse-compatibility, omegaconf, pydantic-v1, installed-package, doctest, mypy]
0 commit comments