2023-02-28 16:07:11 +00:00
|
|
|
name: Python CI
|
|
|
|
on:
|
|
|
|
workflow_call:
|
2023-02-28 16:47:39 +00:00
|
|
|
secrets:
|
|
|
|
SONAR_TOKEN:
|
2023-02-28 16:38:12 +00:00
|
|
|
required: true
|
2023-12-30 13:28:41 +00:00
|
|
|
SNYK_TOKEN:
|
|
|
|
required: true
|
2023-02-28 16:42:47 +00:00
|
|
|
|
2023-02-28 16:07:11 +00:00
|
|
|
jobs:
|
|
|
|
ci:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Check out repository code
|
2024-06-13 05:41:43 +00:00
|
|
|
uses: actions/checkout@v4.1.7
|
2023-02-28 16:07:11 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
- name: Setup Python
|
2023-12-06 13:27:25 +00:00
|
|
|
uses: actions/setup-python@v5
|
2023-02-28 16:07:11 +00:00
|
|
|
with:
|
|
|
|
python-version: "3.11"
|
2023-04-30 11:48:00 +01:00
|
|
|
- name: Update Pip
|
|
|
|
run: |
|
|
|
|
pip install -U pip
|
2023-02-28 16:07:11 +00:00
|
|
|
- name: Install dependencies
|
2023-02-28 16:13:14 +00:00
|
|
|
run: |
|
|
|
|
pip install -r requirements.txt
|
|
|
|
pip install -r requirements-dev.txt
|
|
|
|
pip install pylint-exit
|
2023-02-28 16:07:11 +00:00
|
|
|
- name: Lint
|
|
|
|
run: pylint --recursive=yes --output-format=parseable --output=lintreport.txt . || pylint-exit $?
|
|
|
|
- name: Unit Test
|
|
|
|
run: |
|
2023-02-28 16:19:09 +00:00
|
|
|
coverage run -m pytest -v --junitxml=testresults.xml
|
2023-02-28 16:07:11 +00:00
|
|
|
coverage xml
|
2023-02-28 16:13:14 +00:00
|
|
|
sed -i 's@${{ github.workspace }}@/github/workspace@g' coverage.xml
|
2023-02-28 16:07:11 +00:00
|
|
|
- name: SonarCloud Scan
|
|
|
|
uses: SonarSource/sonarcloud-github-action@master
|
|
|
|
env:
|
2023-02-28 16:29:16 +00:00
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2023-02-28 16:47:39 +00:00
|
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
2023-12-29 19:58:04 +00: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:
|
|
|
|
args: --sarif-file-output=snyk.sarif
|
|
|
|
- name: Upload result to GitHub Code Scanning
|
2023-12-30 13:29:02 +00:00
|
|
|
uses: github/codeql-action/upload-sarif@v3
|
2023-12-29 19:58:04 +00:00
|
|
|
with:
|
|
|
|
sarif_file: snyk.sarif
|