Skip to content

Commit

Permalink
Move coverage to the tests workflow and minor improvements and fixes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mauvilsa authored Nov 11, 2024
1 parent e1146d1 commit 3f41ba4
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 148 deletions.
148 changes: 0 additions & 148 deletions .github/workflows/coverage.yaml

This file was deleted.

149 changes: 149 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,52 @@ name: tests
on:
push:
branches: [ "main" ]
tags:
- 'v*'
pull_request:
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]
pip uninstall -y argcomplete
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:
Expand Down Expand Up @@ -49,6 +90,39 @@ jobs:
- 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*

installed-package:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -98,3 +172,78 @@ jobs:
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/sonarcloud-github-action@master
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 }}

publish-pypi:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [linux, windows, macos, omegaconf, pydantic-v1, installed-package, doctest]
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
cd dist
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
pip install -U twine
twine upload ./dist/*.whl ./dist/*.tar.gz

0 comments on commit 3f41ba4

Please sign in to comment.