-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Pylint to Workflow #373
Changes from 2 commits
1083ada
383e9f7
26768f5
b0f7f60
fe1bad8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Linting | ||
on: | ||
pull_request: | ||
branches: | ||
- '*' | ||
permissions: | ||
pull-requests: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out Git repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.9' | ||
|
||
- name: Store the PR branch | ||
run: | | ||
echo "SHA=$(git rev-parse "$GITHUB_SHA")" >> $GITHUB_OUTPUT | ||
id: git | ||
|
||
- name: Get RC branch name | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would probably be better to grab the merging PR branch name. Let me look into that and see if that's possible |
||
run: | | ||
git fetch --all | ||
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | ||
echo "RC_BRANCH<<$EOF" >> $GITHUB_OUTPUT | ||
echo "$(git branch -r --list 'origin/RC*' --sort=-committerdate | head -n 1 | sed 's/origin\///' | xargs)" >> $GITHUB_OUTPUT | ||
echo "$EOF" >> $GITHUB_OUTPUT | ||
id: branch_name | ||
|
||
- name: Checkout RC branch | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ steps.branch_name.outputs.RC_BRANCH }} | ||
|
||
- name: Install tobac and pylint | ||
run: | | ||
pip install . | ||
pip install --upgrade pylint | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be better to use conda/mamba to create the environment, consistent with other actions, rather than pip? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had some trouble getting pylint to work with the conda environment but I'll take another look. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah fair, if it causes more work then it's probably not worth changing it. Seems to work fine for me via conda locally as long as it isn't using python 3.12 Also good to check that we can install tobac with pip! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, it's working now. I just forgot to specify the shell in which pylint is supposed to run. |
||
|
||
- name: Get pylint score of RC branch | ||
run: | | ||
pylint tobac --disable=C --exit-zero | ||
id: main_score | ||
|
||
- name: Checkout PR branch | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: "${{ steps.git.outputs.SHA}}" | ||
|
||
- name: Get pylint score of PR branch | ||
run: | | ||
# use shell script to save only tail of output | ||
OUTPUT_PART=$(pylint tobac --disable=C | tail -n 2) | ||
# but post entire output in the action details | ||
pylint tobac --disable=C --exit-zero | ||
# define random delimiter for multiline string | ||
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | ||
echo "MESSAGE<<$EOF" >> "$GITHUB_OUTPUT" | ||
echo "$OUTPUT_PART" >> "$GITHUB_OUTPUT" | ||
echo "$EOF" >> "$GITHUB_OUTPUT" | ||
id: pr_score | ||
|
||
- name: Post result to PR | ||
uses: mshick/add-pr-comment@v1 | ||
with: | ||
message: | | ||
Linting results by Pylint: | ||
-------------------------- | ||
${{ steps.pr_score.outputs.MESSAGE}} | ||
<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 ${{ steps.branch_name.outputs.RC_BRANCH}} branch. | ||
A decrease usually indicates your new code does not fully meet style guidelines or has potential errors.<sup> | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
repo-token-user-login: 'github-actions[bot]' # The user.login for temporary GitHub token | ||
allow-repeats: false # This is the default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a need to use python 3.9? pylint doesn't seem to yet work with 3.12, but 3.11 works fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can change it to 3.11