From 213315cf930a7bae7b383cfc9e3fca32eaa828ef Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Sat, 27 Apr 2024 19:06:32 +0100 Subject: [PATCH] fix linting issues --- .github/workflows/ci.yml | 58 +++++++++++++++++++++++++++++----------- tools/lint.sh | 3 +++ 2 files changed, 46 insertions(+), 15 deletions(-) create mode 100755 tools/lint.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a71796c..a123a7a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,20 +1,48 @@ name: CI on: - push: - branches: [ main ] - pull_request: - types: [opened, synchronize, reopened] - paths-ignore: - - 'README.md' - - 'LICENSE.md' - - '.gitignore' - - 'CODEOWNERS' - - 'renovate.json' - - '.github/' + workflow_call: + secrets: + SONAR_TOKEN: + required: true + SNYK_TOKEN: + required: true jobs: ci: - uses: luketainton/gha-workflows/.github/workflows/ci-python-poetry.yml@main - secrets: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4.1.4 + with: + fetch-depth: 0 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + - name: Setup Poetry + uses: abatilo/actions-poetry@v2 + - name: Install dependencies + run: poetry install + - name: Lint + run: poetry run ./tools/lint.sh + - name: Unit Test + run: | + poetry run coverage run -m pytest -v --junitxml=testresults.xml + poetry run coverage xml + sed -i 's@${{ github.workspace }}@/github/workspace@g' coverage.xml + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - name: Snyk Vulnerability Scan + uses: snyk/actions/python-3.10@master + continue-on-error: true # To make sure that SARIF upload gets called + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + with: + args: --sarif-file-output=snyk.sarif + - name: Upload result to GitHub Code Scanning + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: snyk.sarif diff --git a/tools/lint.sh b/tools/lint.sh new file mode 100755 index 0000000..c18f2ec --- /dev/null +++ b/tools/lint.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +pylint --recursive=yes --output-format=parseable --output=lintreport.txt . || pylint-exit $?