improve_error_msg (#41) #96
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: linter | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
formater: | |
name: Python Formatter | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Cut sha for PR branch name | |
shell: bash | |
run: | | |
echo "GITHUB_SHA_SHORT=$(echo ${{ github.sha }} | cut -c 1-6)" >> $GITHUB_ENV | |
echo ${{ env.GITHUB_SHA_SHORT }} | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' | |
- run: pip install yapf | |
shell: bash | |
- name: run yapf | |
id: yapf | |
shell: bash | |
run: | | |
is_formatted=0 | |
yapf . --verbose --recursive --diff --parallel > /dev/null || is_formatted=1 | |
yapf . --verbose --recursive --in-place --parallel > /dev/null | |
echo "IS_FORMATTED=$is_formatted" >> $GITHUB_ENV | |
echo "is_formatted: ${{ env.IS_FORMATTED }}" | |
- name: Create Pull Request | |
if: ${{ env.IS_FORMATTED != 0 }} | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
title: "Bot action yapf on branch - ${{ github.head_ref }}" | |
commit-message: ":art: Format Python code with yapf" | |
body: | | |
There appear to be some python formatting errors in ${{ github.sha }}. This pull request | |
uses the yapf formatter to fix these issues. | |
base: ${{ github.head_ref }} # Creates pull request onto pull request or commit branch | |
branch: ${{ github.head_ref }}_${{ env.GITHUB_SHA_SHORT }}_yapf | |
- name: yapf exit failure | |
if: ${{ env.IS_FORMATTED != 0 }} | |
run: exit 1 | |
shell: bash |