From d8c5c29d2dc2511a35bcd6140388f67fd25b2ecb Mon Sep 17 00:00:00 2001 From: Andrew Shumway Date: Mon, 17 Apr 2023 15:56:08 -0600 Subject: [PATCH 1/6] Added coverage commands to make test and dir to gitignore --- .gitignore | 2 ++ Makefile | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index ede52acef..08b0bf758 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,7 @@ pip-delete-this-directory.txt htmlcov/ .tox/ .coverage +.coverage_cache .coverage.* .cache .pytest_cache @@ -76,6 +77,7 @@ environment.sh varsfile celerybeat-schedule +celerybeat-schedule.db # CloudFoundry .cf diff --git a/Makefile b/Makefile index e6c70bc05..990327956 100644 --- a/Makefile +++ b/Makefile @@ -53,10 +53,12 @@ generate-version-file: ## Generates the app version file .PHONY: test test: export NEW_RELIC_ENVIRONMENT=test -test: ## Run tests +test: ## Run tests and create coverage report pipenv run flake8 . pipenv run isort --check-only ./app ./tests - pipenv run pytest -n4 --maxfail=10 + pipenv run coverage run -m pytest -n4 --maxfail=10 + pipenv run coverage report + pipenv run coverage html -d .coverage_cache .PHONY: freeze-requirements freeze-requirements: ## Pin all requirements including sub dependencies into requirements.txt From 1047b7079231124d520ecda9deabd7eb82afc89d Mon Sep 17 00:00:00 2001 From: Andrew Shumway Date: Tue, 18 Apr 2023 13:51:48 -0600 Subject: [PATCH 2/6] Added fail coverage threshold under 50% --- .github/workflows/checks.yml | 6 ++++-- Makefile | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 0e9535f73..c2e958f90 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -46,8 +46,10 @@ jobs: run: pipenv run flake8 . - name: Check imports alphabetized run: pipenv run isort --check-only ./app ./tests - - name: Run tests - run: pipenv run pytest -n4 --maxfail=10 + - name: Run tests with coverage + run: pipenv run coverage run --omit=*/notifications_utils/* -m pytest -n4 --maxfail=10 + - name: Check coverage threshold + run: pipenv run coverage report --fail-under=50 env: SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api diff --git a/Makefile b/Makefile index 990327956..625c761db 100644 --- a/Makefile +++ b/Makefile @@ -56,8 +56,8 @@ test: export NEW_RELIC_ENVIRONMENT=test test: ## Run tests and create coverage report pipenv run flake8 . pipenv run isort --check-only ./app ./tests - pipenv run coverage run -m pytest -n4 --maxfail=10 - pipenv run coverage report + pipenv run coverage run --omit=*/notifications_utils/* -m pytest -n4 --maxfail=10 + pipenv run coverage report --fail-under=50 pipenv run coverage html -d .coverage_cache .PHONY: freeze-requirements From 17c6083f6d91319a9136b7d9937cf5ab98de6396 Mon Sep 17 00:00:00 2001 From: Andrew Shumway Date: Tue, 18 Apr 2023 14:27:56 -0600 Subject: [PATCH 3/6] Check coverage in actions without omit --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index c2e958f90..7f8d15c8c 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -47,7 +47,7 @@ jobs: - name: Check imports alphabetized run: pipenv run isort --check-only ./app ./tests - name: Run tests with coverage - run: pipenv run coverage run --omit=*/notifications_utils/* -m pytest -n4 --maxfail=10 + run: pipenv run coverage run -m pytest -n4 --maxfail=10 - name: Check coverage threshold run: pipenv run coverage report --fail-under=50 env: From cbcb955f1f294a8371a180866e6d8409b0d008ce Mon Sep 17 00:00:00 2001 From: Andrew Shumway Date: Tue, 18 Apr 2023 15:48:10 -0600 Subject: [PATCH 4/6] Moved env: flag under test run --- .github/workflows/checks.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 7f8d15c8c..261d16a61 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -47,11 +47,11 @@ jobs: - name: Check imports alphabetized run: pipenv run isort --check-only ./app ./tests - name: Run tests with coverage - run: pipenv run coverage run -m pytest -n4 --maxfail=10 - - name: Check coverage threshold - run: pipenv run coverage report --fail-under=50 + run: pipenv run coverage run --omit=*/notifications_utils/* -m pytest -n4 --maxfail=10 env: SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + - name: Check coverage threshold + run: pipenv run coverage report --fail-under=50 validate-new-relic-config: runs-on: ubuntu-latest From 7e4043f85a58ed67303e3a03cb82742278665bfe Mon Sep 17 00:00:00 2001 From: Andrew Shumway Date: Wed, 19 Apr 2023 08:56:34 -0600 Subject: [PATCH 5/6] Test github actions coverage PR fail --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 261d16a61..b71608a57 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -51,7 +51,7 @@ jobs: env: SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - name: Check coverage threshold - run: pipenv run coverage report --fail-under=50 + run: pipenv run coverage report --fail-under=60 validate-new-relic-config: runs-on: ubuntu-latest From b623caa366c13ef0d96c0e530f964a7dc4073d82 Mon Sep 17 00:00:00 2001 From: Andrew Shumway Date: Wed, 19 Apr 2023 09:20:22 -0600 Subject: [PATCH 6/6] Test actions with 50% threshold --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index b71608a57..261d16a61 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -51,7 +51,7 @@ jobs: env: SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - name: Check coverage threshold - run: pipenv run coverage report --fail-under=60 + run: pipenv run coverage report --fail-under=50 validate-new-relic-config: runs-on: ubuntu-latest