Skip to content

Commit d256de1

Browse files
committed
Added tests and coverage to pipeline
1 parent 7f8fece commit d256de1

4 files changed

Lines changed: 27 additions & 3 deletions

File tree

.github/workflows/lint-and-test.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,35 @@ jobs:
5656
- name: Check code errors
5757
run: ./scripts/check_pylint
5858

59+
test:
60+
runs-on: ubuntu-latest
61+
container:
62+
image: sergioteula/pytools
63+
volumes:
64+
- ${{github.workspace}}:/code
65+
steps:
66+
- name: Check out code
67+
uses: actions/checkout@v3
68+
- name: Run tests
69+
run: ./scripts/run_tests
70+
- name: Save code coverage file
71+
uses: actions/upload-artifact@v3
72+
with:
73+
name: coverage
74+
path: coverage.xml
75+
5976
sonar:
6077
runs-on: ubuntu-latest
78+
needs: [test]
6179
steps:
6280
- name: Check out code
6381
uses: actions/checkout@v3
6482
with:
6583
fetch-depth: 0
84+
- name: Download a single artifact
85+
uses: actions/download-artifact@v3
86+
with:
87+
name: coverage
6688
- name: Check code errors
6789
uses: SonarSource/sonarcloud-github-action@master
6890
env:

scripts/helpers

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ GREEN="\033[0;32m"
55
RED="\033[0;31m"
66
YELLOW="\033[0;33m"
77
NC="\033[0m"
8-
LINE="--------------------------------------------------------------------"
8+
LINE="----------------------------------------------------------------------"
99

1010
check_if_installed() {
1111
if [ -x "$(command -v "${1}")" ]; then

scripts/run_tests

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ header "Running tests"
77

88
if [ -n "$(check_if_installed docker)" ]; then
99
docker run -v "${PWD}:/code" sergioteula/pytools bash -c \
10-
"coverage run -m unittest && coverage xml && coverage html && coverage report"
10+
"coverage run -m unittest && coverage xml && coverage html && echo && coverage report"
1111
elif [ -n "$(check_if_installed coverage)" ]; then
12-
coverage run -m unittest && coverage xml && coverage html && coverage report
12+
coverage run -m unittest && coverage xml && coverage html && echo && coverage report
1313
else
1414
error "coverage is not installed"
1515
exit 1

sonar-project.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ sonar.sources=amazon_paapi
44
sonar.exclusions=**/sdk/**
55
sonar.qualitygate.wait=true
66
sonar.python.version=3.6,3.7,3.8,3.9,3.10
7+
sonar.tests=tests
8+
sonar.python.coverage.reportPaths=coverage.xml

0 commit comments

Comments
 (0)