gha-workflows/.github/workflows/ci-python.yml

62 lines
1.9 KiB
YAML
Raw Normal View History

2023-02-28 17:07:11 +01:00
name: Python CI
on:
workflow_call:
2024-11-28 22:29:24 +01:00
inputs:
python-version:
2024-11-28 22:29:24 +01:00
type: string
default: "3.11"
description: "Version of Python to use for testing environment"
2023-02-28 17:47:39 +01:00
secrets:
SONAR_TOKEN:
2023-02-28 17:38:12 +01:00
required: true
2023-12-30 14:28:41 +01:00
SNYK_TOKEN:
required: true
2023-02-28 17:42:47 +01:00
2023-02-28 17:07:11 +01:00
jobs:
ci:
runs-on: ubuntu-latest
steps:
- name: Set python-version
id: python-version
2024-11-28 22:29:24 +01:00
run: |
PYTHON_VERSION=${{ inputs.python-version }}
echo "value=${PYTHON_VERSION:-"3.11"}" >> $GITHUB_OUTPUT
2023-02-28 17:07:11 +01:00
- name: Check out repository code
uses: actions/checkout@v4.2.2
2023-02-28 17:07:11 +01:00
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
2023-02-28 17:07:11 +01:00
with:
python-version: "${{ steps.python-version.outputs.value }}"
2023-04-30 12:48:00 +02:00
- name: Update Pip
run: |
pip install -U pip
2023-02-28 17:07:11 +01:00
- name: Install dependencies
2023-02-28 17:13:14 +01:00
run: |
pip install -r requirements.txt
pip install -r requirements-dev.txt
2023-02-28 17:07:11 +01:00
- name: Lint
2024-11-21 23:01:30 +01:00
run: pylint --fail-under=8 --recursive=yes --output-format=parseable --output=lintreport.txt .
2023-02-28 17:07:11 +01:00
- name: Unit Test
run: |
2023-02-28 17:19:09 +01:00
coverage run -m pytest -v --junitxml=testresults.xml
2023-02-28 17:07:11 +01:00
coverage xml
2023-02-28 17:13:14 +01:00
sed -i 's@${{ github.workspace }}@/github/workspace@g' coverage.xml
2024-12-15 14:17:08 +01:00
- name: SonarQube Cloud Scan
uses: SonarSource/sonarqube-scan-action@v4.2.1
2023-02-28 17:07:11 +01:00
env:
2023-02-28 17:29:16 +01:00
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2023-02-28 17:47:39 +01:00
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2023-12-29 20:58:04 +01:00
- 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:
2024-11-21 23:01:30 +01:00
args: --sarif-file-output=snyk.sarif --all-projects
2023-12-29 20:58:04 +01:00
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v3
2023-12-29 20:58:04 +01:00
with:
sarif_file: snyk.sarif