add group_fail_limits to pypi #72
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: test nornir_conditional_runner | |
on: [push,pull_request] | |
jobs: | |
linters: | |
name: linters | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Cache Poetry virtualenv | |
uses: actions/cache@v4 | |
id: cached-poetry-dependencies | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} | |
- name: Install Dependencies | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction --no-root | |
- name: Run ruff | |
run: poetry run ruff check | |
- name: Run ruff format | |
run: poetry run ruff format --check | |
- name: Run mypy | |
run: poetry run mypy . --pretty --show-error-context | |
pytest: | |
name: Testing on Python ${{ matrix.python-version }} (${{ matrix.platform}}) | |
defaults: | |
run: | |
shell: bash | |
strategy: | |
matrix: | |
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12'] | |
platform: [ubuntu-latest, macOS-latest, windows-latest] | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Cache Poetry virtualenv | |
uses: actions/cache@v4 | |
id: cached-poetry-dependencies | |
with: | |
path: .venv | |
key: venv-${{ matrix.python-version }}-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} | |
if: ${{ matrix.platform != 'windows-latest' }} # windows hangs if using a cached venv | |
- name: Install Dependencies | |
run: poetry install --no-interaction | |
- name: Poetry show | |
run: poetry show | |
- name: Poetry env info | |
run: poetry env info | |
- name: Run tests with coverage | |
run: | | |
poetry run pytest --cov=nornir_conditional_runner --cov-report=xml --cov-report=term-missing | |
- name: Upload coverage report artifact | |
if: matrix.platform == 'macos-latest' && matrix.python-version == '3.11' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-report | |
path: coverage.xml | |
coverage: | |
runs-on: macos-latest | |
needs: [pytest] | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Download coverage report artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: coverage-report | |
- name: Extract Coverage | |
if: runner.os == 'macOS' | |
run: | | |
pip install lxml | |
COVERAGE=$(xmllint --xpath "string(//coverage/@line-rate)" coverage.xml) | |
echo "coverage=$COVERAGE" >> $GITHUB_ENV | |
- name: Generate Badge | |
if: runner.os == 'macOS' | |
run: | | |
pip install lxml | |
COVERAGE=$(xmllint --xpath "string(//coverage/@line-rate)" coverage.xml) | |
COVERAGE=$(awk "BEGIN {print $COVERAGE * 100}") | |
echo "Extracted Coverage: $COVERAGE%" | |
echo "{\"schemaVersion\": 1, \"label\": \"coverage\", \"message\": \"${COVERAGE}%\", \"color\": \"green\"}" > coverage-badge.json | |
mkdir -p public | |
mv coverage-badge.json public/ | |
- name: Deploy Badge to GitHub Pages | |
if: runner.os == 'macOS' | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
personal_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./public | |
release: | |
name: Releasing to PyPI | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
needs: [linters, pytest] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
- name: build release | |
run: poetry build | |
- name: Publish package to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: build | |
path: dist/* |