PR checker / misspell - use golangci misspell #38
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: PR-checker | |
on: | |
push: | |
workflow_dispatch: | |
inputs: | |
python-version: | |
description: 'Python version to use' | |
default: '3.9' | |
# This allows a subsequently queued workflow run to interrupt previous runs | |
concurrency: | |
group: e2e-edge-'${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | |
cancel-in-progress: true | |
jobs: | |
static-checks: | |
runs-on: ubuntu-latest | |
env: | |
SUMMARY_FILE: summary.log | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Install Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Clone scripts-internal | |
uses: actions/checkout@v4 | |
with: | |
repository: PelionIoT/scripts-internal | |
path: scripts-internal | |
token: ${{ secrets.ACCESS_TOKEN }} | |
# Need to run this 1st, so that the other log files do not cause unnecessary findings | |
- name: Install Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20' | |
- name: Install & run misspell | |
if: always() | |
run: | | |
go install github.com/golangci/misspell/cmd/misspell@latest | |
misspell -i mosquitto . >misspell.log | |
echo "## Summary" >>$SUMMARY_FILE | |
echo "### misspell" >>$SUMMARY_FILE | |
cat misspell.log >>$SUMMARY_FILE | |
misspell -error -i mosquitto . | |
lines=$(wc -l < "misspell.log") | |
if [[ $lines -gt 0 ]]; then | |
echo "Misspell has findings, fail." | |
echo "TEST_FAIL=true" >> $GITHUB_ENV | |
exit 1 | |
else | |
echo "No findings." >>$SUMMARY_FILE | |
fi | |
- name: Run pylint (findings may not increase) | |
run: | | |
sudo apt-get install pylint | |
echo "### pylint" >>$SUMMARY_FILE | |
pylint --version >>$SUMMARY_FILE | |
pylint --exit-zero --rcfile pylintrc --persistent=n tests/ izuma_systest_lib/ >pylint.log | |
pylintstats=$(scripts-internal/ci/more-lines-checker.sh ${{ github.event.repository.default_branch }} ${{ github.ref_name }} "pylint --exit-zero --rcfile pylintrc --persistent=n tests/ izuma_systest_lib/" pylint | tail -n3) | |
echo "$pylintstats" >>$SUMMARY_FILE | |
pylintscore=$(tail -2 pylint.log |head -1) | |
echo "$pylintscore" >>$SUMMARY_FILE | |
if [[ $pylintstats == *"Oh no"* ]]; then | |
# More findings than earlier | |
echo "TEST_FAIL=true" >> $GITHUB_ENV | |
exit 1 | |
fi | |
- name: Run flake8 | |
if: always() | |
run: | | |
sudo apt-get install flake8 | |
flake8 --version | |
echo "Starting flake8..." | |
flake8 --exit-zero --exclude=izuma_systest_lib/.eggs,scripts-internal --max-line-length=130 >flake8.log | |
echo "### flake8" >>$SUMMARY_FILE | |
lines=$(wc -l < "flake8.log") | |
if [[ $lines -gt 0 ]]; then | |
echo "Flake8 has findings, fail." | |
echo "TEST_FAIL=true" >> $GITHUB_ENV | |
exit 1 | |
else | |
echo "No findings." >>$SUMMARY_FILE | |
fi | |
- name: Archive production artifacts | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Findings logs | |
path: | | |
*.log | |
- name: Summary | |
if: always() | |
run: cat $SUMMARY_FILE >>$GITHUB_STEP_SUMMARY | |
- name: Set whole job status based on found fails | |
if: always() | |
run: | | |
if [ "$TEST_FAIL" = "true" ]; then | |
echo "Some test has failed, fail the job." | |
exit 1 # You can choose to exit with success (0) to mark this step as successful but skipped. | |
fi |