From d0fda23a580c8ef117d88403c44853907f2cc51a Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Fri, 30 Dec 2022 20:20:30 +0000 Subject: [PATCH 1/4] fix: add timeout to POST request --- app/send_page.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/send_page.py b/app/send_page.py index 90f30cb..ee41111 100644 --- a/app/send_page.py +++ b/app/send_page.py @@ -26,7 +26,8 @@ def send_page(name: str, email: str, message: str) -> tuple: req = requests.post( api_url, json=payload, - headers={'Content-Type': 'application/json'} + headers={'Content-Type': 'application/json'}, + timeout=5 ) if req.status_code == 200 and req.json().get('status') == 1: -- 2.49.0 From 9ef59b7b72472361d0e102702e95d49fd41af1ed Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Fri, 30 Dec 2022 20:28:10 +0000 Subject: [PATCH 2/4] fix: CI job could not find Pytest --- .github/workflows/ci.yml | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 99b74f6..120c489 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,20 +31,10 @@ jobs: continue-on-error: true - name: Unit Test run: | - coverage run -m py.test -v --junitxml=testresults.xml + coverage run -m pytest -v --junitxml=testresults.xml coverage xml - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_CLOUD }} - # - name: SonarQube Scan - # uses: sonarsource/sonarqube-scan-action@master - # env: - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - # SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - # - name: SonarQube Quality Gate - # uses: sonarsource/sonarqube-quality-gate-action@master - # timeout-minutes: 5 - # env: - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} -- 2.49.0 From ae13c348184f1bbdef2771270a174b03be404ce9 Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Fri, 30 Dec 2022 20:34:46 +0000 Subject: [PATCH 3/4] fix: correct coverage report path --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 120c489..63dc223 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,7 @@ jobs: run: | coverage run -m pytest -v --junitxml=testresults.xml coverage xml + sed -i 's/\/home\/runner\/work\/epage\/epage\//\/github\/workspace\//g' coverage.xml - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: -- 2.49.0 From d40ee01a4a4a540b5c1b1f6259fbbd8ad165b170 Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Fri, 30 Dec 2022 20:42:48 +0000 Subject: [PATCH 4/4] fix: correct coverage source path --- .coveragerc | 3 +++ .github/workflows/ci.yml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..fa2ee67 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,3 @@ +[coverage:run] +relative_files = True +branch = True \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63dc223..1aed174 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: run: | coverage run -m pytest -v --junitxml=testresults.xml coverage xml - sed -i 's/\/home\/runner\/work\/epage\/epage\//\/github\/workspace\//g' coverage.xml + sed -i 's/\/home\/runner\/work\/epage\/epage/\/github\/workspace/g' coverage.xml - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: -- 2.49.0