-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (111 loc) · 3.58 KB
/
test-sonar.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Test Sonar Cloud
on:
workflow_dispatch:
env:
PYTHON_VERSION: '3.8'
ACR_NAME: mroi
jobs:
qaqc-checks-pylint:
name: Run QA-QC checks with PyLint
runs-on: ubuntu-latest
steps:
- name: Checkout code from remote origin.
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup python version
uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: 'x64'
- name: Generate logs for reporting using pylint.
run: |
pip install pylint
pylint app -r n --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" --exit-zero > pylint.log
- name: Upload linting errors to to GitHub packages
uses: actions/upload-artifact@v2
with:
name: linting-reports
path: pylint.log
retention-days: 5
qaqc-checks-flake8:
name: Run QA-QC checks with flake8
runs-on: ubuntu-latest
steps:
- name: Checkout code from remote origin.
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup python version
uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: 'x64'
- name: Check linting using flake8 & generate report
run: |
pip install flake8
flake8 --exit-zero --output-file=flake8.txt .
- name: Upload flake8 errors to to GitHub packages.
uses: actions/upload-artifact@v2
with:
name: flake8-reports
path: flake8.txt
qaqc-checks-bandit:
name: Run QA-QC checks with Bandit
runs-on: ubuntu-latest
steps:
- name: Checkout code from remote origin
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup python version
uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: 'x64'
- name: Check linting using bandit & generate report
run: |
pip install bandit
bandit --exit-zero --format json --output bandit-report.json --recursive .
- name: Upload bandit errors to to GitHub packages.
uses: actions/upload-artifact@v2
with:
name: bandit-reports
path: bandit-report.json
retention-days: 5
unit-tests-pytest:
name: Run unit tests with pytest
runs-on: ubuntu-latest
steps:
- name: Checkout code from remote origin.
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup python version
uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: 'x64'
- name: Create cache depending on requirements file
uses: actions/cache@v2
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ env.pythonLocation }}-pip-
- name: Install dependencies & download data.
if: steps.cache.outputs.cache-hit != 'false' # Need to change later
run: |
pip install --upgrade pip
pip install -r pytest coverage coverage-badge pytest-html pytest-cov
- name: Run pytest & generate test coverage report (unit tests).
run: |
coverage run -m pytest
coverage xml
- name: Upload test coverage report generated for unit tests using pytest to GitHub packages.
uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage.xml
retention-days: 5