Skip to content

Commit 7ded724

Browse files
authored
Merge pull request #373 from tobac-project/linting-test-repo
Add Pylint to Workflow
2 parents 509a17c + fe1bad8 commit 7ded724

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

.github/workflows/pylint.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Linting
2+
on:
3+
pull_request:
4+
branches:
5+
- '*'
6+
permissions:
7+
pull-requests: write
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
defaults:
13+
run:
14+
shell: bash -l {0}
15+
steps:
16+
- name: Check out Git repository
17+
uses: actions/checkout@v3
18+
19+
- name: Set up conda
20+
uses: conda-incubator/setup-miniconda@v2
21+
with:
22+
miniforge-version: latest
23+
miniforge-variant: mambaforge
24+
channel-priority: strict
25+
channels: conda-forge
26+
show-channel-urls: true
27+
use-only-tar-bz2: true
28+
29+
- name: Install tobac and pylint
30+
run: |
31+
mamba install --yes pylint
32+
pip install .
33+
34+
- name: Store the PR branch
35+
run: |
36+
echo "SHA=$(git rev-parse "$GITHUB_SHA")" >> $GITHUB_OUTPUT
37+
id: git
38+
39+
- name: Checkout RC branch
40+
uses: actions/checkout@v3
41+
with:
42+
ref: ${{ github.base_ref }}
43+
44+
- name: Get pylint score of RC branch
45+
run: |
46+
pylint tobac --disable=C --exit-zero
47+
id: main_score
48+
49+
- name: Checkout PR branch
50+
uses: actions/checkout@v3
51+
with:
52+
ref: "${{ steps.git.outputs.SHA }}"
53+
54+
- name: Get pylint score of PR branch
55+
run: |
56+
# use shell script to save only tail of output
57+
OUTPUT_PART=$(pylint tobac --disable=C --exit-zero | tail -n 2)
58+
# but post entire output in the action details
59+
pylint tobac --disable=C --exit-zero
60+
# define random delimiter for multiline string
61+
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
62+
echo "MESSAGE<<$EOF" >> "$GITHUB_OUTPUT"
63+
echo "$OUTPUT_PART" >> "$GITHUB_OUTPUT"
64+
echo "$EOF" >> "$GITHUB_OUTPUT"
65+
id: pr_score
66+
67+
- name: Find Comment
68+
uses: peter-evans/find-comment@v2
69+
id: comment
70+
with:
71+
issue-number: ${{ github.event.pull_request.number }}
72+
comment-author: 'github-actions[bot]'
73+
body-includes: Linting results by Pylint
74+
75+
- name: Post result to PR
76+
uses: peter-evans/create-or-update-comment@v3
77+
with:
78+
issue-number: ${{ github.event.pull_request.number }}
79+
comment-id: ${{ steps.comment.outputs.comment-id }}
80+
edit-mode: replace
81+
body: |
82+
Linting results by Pylint:
83+
--------------------------
84+
${{ steps.pr_score.outputs.MESSAGE }}
85+
<sub>The linting score is an indicator that reflects how well your code version follows Pylint’s coding standards and quality metrics with respect to the ${{ github.base_ref }} branch.
86+
A decrease usually indicates your new code does not fully meet style guidelines or has potential errors.<sup>

0 commit comments

Comments
 (0)