Initial Ruff migration #20
Workflow file for this run
This file contains hidden or 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
on: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
paths-ignore: | |
- "**.md" | |
env: | |
REPO_NAME: ${{ github.event.repository.name }} | |
name: CI | |
jobs: | |
pre-commit-and-test: | |
if: always() | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
steps: | |
- name: Get branch name | |
id: branch-name | |
uses: tj-actions/branch-names@v7.0.7 | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Setup Python | |
uses: actions/setup-python@v6 | |
with: | |
python-version-file: ".python-version" | |
- name: Install uv | |
uses: astral-sh/setup-uv@v6 | |
with: | |
enable-cache: true | |
- name: Install Dependencies | |
run: uv sync --locked --all-extras --dev | |
- name: Run ruff linter | |
shell: bash | |
run: pre-commit run ruff-check --all-files | |
- name: Run ruff formatter | |
shell: bash | |
run: pre-commit run ruff-format --all-files | |
- name: Run mypy | |
shell: bash | |
run: pre-commit run mypy --all-files | |
- name: Run pytest with code coverage | |
run: | | |
pytest --junitxml pytest.xml --cov=. --cov-report=term-missing --cov-report=xml:coverage.xml --cov-branch | tee pytest-coverage.txt | |
- name: Upload Coverage Results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-results | |
path: coverage.xml | |
if: ${{ always() }} | |
- name: Upload Unit Test Results | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: unit-test-py312 | |
path: pytest.xml | |
- name: Upload Unit Test Results | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: unit-test-py312 | |
path: pytest-coverage.txt | |
publish-test-results: | |
name: Publish Unit Tests Results | |
needs: pre-commit-and-test | |
runs-on: ubuntu-latest | |
if: always() | |
timeout-minutes: 20 | |
steps: | |
- name: Download Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: unit-test-py312 | |
path: unit-test-py312 | |
- name: Download coverage report | |
uses: actions/download-artifact@v3 | |
with: | |
name: coverage-results | |
- name: Pytest coverage comment in pull-request | |
uses: MishaKav/pytest-coverage-comment@main | |
with: | |
default-branch: main | |
pytest-coverage-path: unit-test-py312/pytest-coverage.txt | |
junitxml-path: unit-test-py312/pytest.xml | |
hide-badge: true | |
hide-report: false | |
create-new-comment: false | |
hide-comment: false | |
report-only-changed-files: true | |
- name: Get the Coverage | |
shell: bash | |
run: | | |
regex='<coverage.+line-rate="([0-9).[0-9]+)".+>' | |
line=$(grep -oP $regex coverage.xml) | |
[[ $line =~ $regex ]] | |
coverage=$( bc <<< ${BASH_REMATCH[1]}*100 ) | |
if (( $(echo "$coverage > 90" |bc -l) )); then | |
COLOR=green | |
else | |
COLOR=red | |
fi | |
echo "COVERAGE=${coverage%.*}%" >> $GITHUB_ENV | |
echo "COLOR=$COLOR" >> $GITHUB_ENV | |
- name: Create Coverage Badge | |
uses: schneegans/dynamic-badges-action@v1.7.0 | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: ${{ secrets.GIST_ID }} | |
filename: coverage.${{ env.REPO_NAME }}.${{ github.event.number }}.json | |
label: coverage | |
message: ${{ env.COVERAGE }} | |
color: ${{ env.COLOR }} | |
- name: Find Comment | |
uses: peter-evans/find-comment@v2 | |
id: fc | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: "github-actions[bot]" | |
body-includes: Current Branch | Main Branch | |
- name: Create coverage comment | |
uses: peter-evans/create-or-update-comment@v2 | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
reactions: eyes | |
body: | | |
Current Branch | Main Branch | | |
| ------ | ------ | | |
 |  | | |
edit-mode: replace |