From 95a3544e3e65864d76776f58d71ec6238f533cca Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Fri, 30 Dec 2022 20:45:43 +0000 Subject: [PATCH] Add timeout to POST request (#19) * fix: add timeout to POST request * fix: CI job could not find Pytest * fix: correct coverage report path * fix: correct coverage source path --- .coveragerc | 3 +++ .github/workflows/ci.yml | 15 +++------------ app/send_page.py | 3 ++- 3 files changed, 8 insertions(+), 13 deletions(-) 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 99b74f6..1aed174 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,20 +31,11 @@ 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 + sed -i 's/\/home\/runner\/work\/epage\/epage/\/github\/workspace/g' 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 }} 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: