build(deps-dev): bump ruff from 0.5.0 to 0.6.1 (#1006) #30
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 & Release | |
on: | |
push: | |
branches: | |
- master | |
- main | |
- "pre/*" | |
jobs: | |
test: | |
name: Python ${{ matrix.python-version }} on ${{ matrix.os }} tests | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
os: [ubuntu-latest, windows-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
python -m pip install .[test] | |
python -m pip install pytest-github-actions-annotate-failures | |
- name: pytest on Linux | |
id: tests-linux | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: | | |
python -m pytest \ | |
-vv \ | |
-nauto \ | |
--cov=semantic_release \ | |
--cov-context=test \ | |
--cov-report=term-missing \ | |
--cov-fail-under=80 \ | |
--junit-xml=tests/reports/pytest-results.xml | |
- name: pytest on windows | |
id: tests-win | |
if: ${{ matrix.os == 'windows-latest' }} | |
# env: | |
# Required for GitPython to work on Windows because of getpass.getuser() | |
# USERNAME: "runneradmin" | |
# Because GHA is currently broken on Windows to pass these varables, we do it manually | |
run: | | |
$env:USERNAME = "runneradmin" | |
python -m pytest ` | |
-vv ` | |
-nauto ` | |
`--cov=semantic_release ` | |
`--cov-context=test ` | |
`--cov-report=term-missing ` | |
`--cov-fail-under=80 ` | |
`--junit-xml=tests/reports/pytest-results.xml | |
- name: Report | Upload Linux Test Results | |
uses: mikepenz/action-junit-report@v4.3.1 | |
if: ${{ always() && steps.tests-linux.outcome != 'skipped' }} | |
with: | |
report_paths: ./tests/reports/*.xml | |
- name: Report | Upload Windows Test Results | |
uses: mikepenz/action-junit-report@v4.3.1 | |
if: ${{ always() && steps.tests-win.outcome != 'skipped' }} | |
with: | |
report_paths: ./tests/reports/*.xml | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.8 | |
- name: Install mypy & dev packages | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
python -m pip install ".[dev, mypy]" | |
- name: ruff | |
run: | | |
python -m ruff check . \ | |
--config pyproject.toml \ | |
--output-format=full \ | |
--exit-non-zero-on-fix | |
- name: mypy | |
run: | | |
python -m mypy --ignore-missing-imports semantic_release | |
beautify: | |
name: Beautify | |
runs-on: ubuntu-latest | |
concurrency: push | |
needs: [test, lint] | |
outputs: | |
new_sha: ${{ steps.sha.outputs.SHA }} | |
permissions: | |
id-token: write | |
contents: write | |
steps: | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.9 | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install Ruff | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
python -m pip install ".[dev]" | |
- name: Format | |
run: | | |
python -m ruff format . | |
- name: Commit and push changes | |
uses: github-actions-x/commit@v2.9 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: "style: beautify ${{ github.sha }}" | |
name: github-actions | |
email: action@github.com | |
- name: Get new SHA | |
id: sha | |
run: | | |
new_sha=$(git rev-parse HEAD) | |
echo "SHA=$new_sha" >> $GITHUB_OUTPUT | |
release: | |
name: Semantic Release | |
runs-on: ubuntu-latest | |
concurrency: push | |
needs: [test, lint, beautify] | |
if: github.repository == 'python-semantic-release/python-semantic-release' | |
environment: | |
name: pypi | |
url: https://pypi.org/project/python-semantic-release/ | |
permissions: | |
# https://docs.github.com/en/rest/overview/permissions-required-for-github-apps?apiVersion=2022-11-28#metadata | |
id-token: write | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.ref_name }} | |
- name: Python Semantic Release | |
id: release | |
uses: ./ | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
root_options: "-vv" | |
# see https://docs.pypi.org/trusted-publishers/ | |
- name: Publish package distributions to PyPI | |
id: pypi-publish | |
# NOTE: DO NOT wrap the conditional in ${{ }} as it will always evaluate to true. | |
# See https://github.com/actions/runner/issues/1173 | |
if: steps.release.outputs.released == 'true' | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
verbose: true | |
- name: Publish package distributions to GitHub Releases | |
id: github-release | |
# NOTE: DO NOT wrap the conditional in ${{ }} as it will always evaluate to true. | |
# See https://github.com/actions/runner/issues/1173 | |
if: steps.release.outputs.released == 'true' | |
uses: python-semantic-release/upload-to-gh-release@main | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ steps.release.outputs.tag }} |