Refactor to eventually remove pyyaml as a required dependency #111
Workflow file for this run
This file contains 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: tests | |
on: | |
push: | |
branches: [main] | |
tags: | |
- 'v*' | |
pull_request_target: | |
branches: [main] | |
jobs: | |
linux: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python: [3.8, 3.9, "3.10", 3.11, 3.12, 3.13] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
cache: pip | |
- name: without optional dependencies | |
run: | | |
pip install .[coverage] | |
pytest --cov --cov-report=term --cov-report=xml --junit-xml=junit.xml | |
mv coverage.xml coverage_py${{ matrix.python }}_bare.xml | |
mv junit.xml junit_py${{ matrix.python }}_bare.xml | |
- name: with all optional dependencies | |
run: | | |
pip install .[test,all] | |
pytest --cov --cov-report=term --cov-report=xml --junit-xml=junit.xml | |
mv coverage.xml coverage_py${{ matrix.python }}_all.xml | |
mv junit.xml junit_py${{ matrix.python }}_all.xml | |
- name: without future annotations | |
run: | | |
sed -i '/^from __future__ import annotations$/d' jsonargparse_tests/test_*.py | |
pytest --cov --cov-report=term --cov-report=xml --junit-xml=junit.xml | |
mv coverage.xml coverage_py${{ matrix.python }}_types.xml | |
mv junit.xml junit_py${{ matrix.python }}_types.xml | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: coverage_py${{ matrix.python }} | |
path: ./coverage_py* | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: junit_py${{ matrix.python }} | |
path: ./junit_py* | |
windows: | |
runs-on: windows-2019 | |
strategy: | |
fail-fast: false | |
matrix: | |
python: [3.8, 3.9, "3.10", 3.11, 3.12, 3.13] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
cache: pip | |
- run: pip install tox | |
- run: tox -e py-all-extras | |
macos: | |
runs-on: macOS-15 | |
strategy: | |
fail-fast: false | |
matrix: | |
python: [3.8, "3.10", 3.12] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
cache: pip | |
- run: pip install tox | |
- run: tox -e py-all-extras | |
omegaconf: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
cache: pip | |
- run: pip install tox | |
- run: tox -e omegaconf | |
pydantic-v1: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
cache: pip | |
- name: With pydantic<2 | |
run: | | |
pip install .[coverage] | |
pip install "pydantic<2" | |
pytest --cov --cov-report=term --cov-report=xml --junit-xml=junit.xml jsonargparse_tests/test_dataclass_like.py | |
mv coverage.xml coverage_pydantic1.xml | |
mv junit.xml junit_pydantic1.xml | |
- name: with pydantic>=2 | |
run: | | |
sed -i "s|import pydantic|import pydantic.v1 as pydantic|" jsonargparse_tests/test_dataclass_like.py | |
sed -i "s|^annotated = .*|annotated = False|" jsonargparse_tests/test_dataclass_like.py | |
sed -i "s|test_pydantic_types|_test_pydantic_types|" jsonargparse_tests/test_dataclass_like.py | |
pip install "pydantic>=2" | |
pytest --cov --cov-report=term --cov-report=xml --junit-xml=junit.xml jsonargparse_tests/test_dataclass_like.py | |
mv coverage.xml coverage_pydantic2.xml | |
mv junit.xml junit_pydantic2.xml | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: coverage_pydantic | |
path: ./coverage_py* | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: junit_pydantic | |
path: ./junit_py* | |
without-pyyaml: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
cache: pip | |
- run: | | |
pip install .[test,all] | |
pip uninstall -y argcomplete omegaconf pyyaml reconplogger responses ruyaml types-PyYAML | |
pytest | |
build-package: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Build package | |
run: | | |
pip install -U build | |
python -m build | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: package | |
path: ./dist/* | |
installed-package: | |
runs-on: ubuntu-latest | |
needs: [build-package] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
cache: pip | |
- uses: actions/download-artifact@v4 | |
with: | |
name: package | |
path: dist | |
- name: Test without optional dependencies | |
run: | | |
cd dist | |
pip install $(ls *.whl)[test-no-urls] | |
python -m jsonargparse_tests | |
- name: Test with all optional dependencies | |
run: | | |
cd dist | |
pip install $(ls *.whl)[test,all] | |
python -m jsonargparse_tests | |
doctest: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
cache: pip | |
- run: pip install -e .[all,doc] | |
- name: Run doc tests | |
run: sphinx-build -M doctest sphinx sphinx/_build sphinx/index.rst | |
mypy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
cache: pip | |
- uses: actions/cache@v4 | |
with: | |
key: pre-commit-cache | |
path: ~/.cache/pre-commit | |
- run: pip install pre-commit | |
- run: pre-commit run -a --hook-stage pre-push mypy | |
codecov: | |
runs-on: ubuntu-latest | |
needs: [linux, pydantic-v1] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
- uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: true | |
files: ./coverage_*.xml | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- uses: codecov/test-results-action@v1 | |
with: | |
fail_ci_if_error: true | |
files: ./junit_*.xml | |
token: ${{ secrets.CODECOV_TOKEN }} | |
sonarcloud: | |
runs-on: ubuntu-latest | |
needs: [linux, pydantic-v1] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Shallow clone disabled for a better relevancy of analysis | |
- uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
- name: Get version | |
run: | | |
TAG=$(git describe --tags --exact-match 2>/dev/null | sed 's/^v//') | |
if [ -n "$TAG" ]; then | |
VERSION="$TAG" | |
else | |
VERSION="$(git describe --tags --abbrev=0 | sed 's/^v//')+$(git rev-parse --short HEAD)" | |
fi | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- uses: SonarSource/sonarqube-scan-action@v4 | |
with: | |
args: > | |
-Dsonar.organization=omni-us | |
-Dsonar.projectKey=omni-us_jsonargparse | |
-Dsonar.projectVersion=${{ env.VERSION }} | |
-Dsonar.sources=jsonargparse | |
-Dsonar.exclusions=sphinx/** | |
-Dsonar.tests=jsonargparse_tests | |
-Dsonar.python.coverage.reportPaths=coverage_*.xml | |
-Dsonar.python.version=3.8,3.9,3.10,3.11,3.12,3.13 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
pypi-publish: | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
needs: [linux, windows, macos, omegaconf, pydantic-v1, without-pyyaml, installed-package, doctest, mypy] | |
environment: | |
name: pypi | |
url: https://pypi.org/p/jsonargparse | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: package | |
path: dist | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |