Testing ruff pr creation with 40 char lim #6
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: Python Lint and Format | |
on: | |
push: | |
branches: | |
- master | |
- 'feature/**' | |
pull_request: | |
branches: | |
- master | |
- 'feature/**' | |
jobs: | |
lint-and-format: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install Ruff | |
run: pip install ruff | |
- name: Run Ruff and prepare changes | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
echo '[tool.ruff]' > pyproject.toml | |
echo 'line-length = 40' >> pyproject.toml | |
ruff check --fix . | |
git add -A | |
git diff-index --quiet HEAD || echo "CHANGES_EXIST=true" >> $GITHUB_ENV | |
- name: Create Pull Request | |
if: env.CHANGES_EXIST == 'true' | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: 'Auto-format Python code with Ruff (line length 40)' | |
title: 'Auto-format Python code (line length 40)' | |
body: 'This PR was automatically created to format Python code using Ruff with a line length of 40 characters.' | |
branch: auto-format-${{ github.sha }} | |
base: ${{ github.ref }} | |
delete-branch: true | |
- name: Check outputs | |
if: env.CHANGES_EXIST == 'true' | |
run: | | |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" | |
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" |