I built a pylint git action, for pull request, which actually works really well:
name: Python Linting
on:
pull_request:
branches: [ main, dev ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Setup action
uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Changed Files Exporter
id: files
uses: umani/changed-files@v3.3.0
with:
repo-token: ${{ github.token }}
pattern: '^src.*\.(py)$'
result-encoding: 'string'
- name: Lint with pylint
working-directory: ./
run: |
echo '${{ steps.files.outputs.files_updated }} ${{ steps.files.outputs.files_created }}'
pip install pylint
OUTPUT=$(pylint ${{ steps.files.outputs.files_updated }} ${{ steps.files.outputs.files_created }} --exit-zero)
echo 'MESSAGE<<EOF' >> $GITHUB_ENV
echo "$OUTPUT" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Post result to PR
uses: mshick/add-pr-comment@v1
with:
message: |
** Pylint Result**
```
${{ env.MESSAGE }}
```
Please aim to have a quality of score of at least 5.0 or higher
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login: 'github-actions[bot]' # The user.login for temporary GitHub tokens
allow-repeats: false # This is the default
The main problem with this is that it create a new message every time the PR is updated, is it possible to just update the existing comment that is already created? Here is what the comment look like:
Is it possible to edit for an existing comment? How can I tell which comment is the one to update?
