From 919e2e5d9e2b2ee4a5042ec2149a8c72965fe31d Mon Sep 17 00:00:00 2001 From: Nicolas Giard Date: Mon, 2 May 2022 18:43:01 -0400 Subject: [PATCH 1/3] ci: add db migrations checks to tests and build workflows --- .github/workflows/build.yml | 2 ++ .github/workflows/ci-run-tests.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1c9d458bb63..441272d7ca1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -128,6 +128,8 @@ jobs: run: | echo "Running checks..." ./ietf/manage.py check + echo "Validating migrations..." + $do ./ietf/manage.py makemigrations | tee /dev/stderr | $do grep -q "^No changes detected$" || die "Model changes without migrations found." echo "Running tests..." ./ietf/manage.py test --settings=settings_sqlitetest coverage xml diff --git a/.github/workflows/ci-run-tests.yml b/.github/workflows/ci-run-tests.yml index 43c961e9e53..5beb5f4e087 100644 --- a/.github/workflows/ci-run-tests.yml +++ b/.github/workflows/ci-run-tests.yml @@ -40,6 +40,8 @@ jobs: run: | echo "Running checks..." ./ietf/manage.py check + echo "Validating migrations..." + $do ./ietf/manage.py makemigrations | tee /dev/stderr | $do grep -q "^No changes detected$" || die "Model changes without migrations found." echo "Running tests..." ./ietf/manage.py test --settings=settings_sqlitetest coverage xml From cf8353549cc60cae0c2fb7970e3754a973588790 Mon Sep 17 00:00:00 2001 From: Nicolas Giard Date: Mon, 2 May 2022 23:16:55 -0400 Subject: [PATCH 2/3] ci: refactor migrations check expression --- .github/workflows/build.yml | 2 +- .github/workflows/ci-run-tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 441272d7ca1..b80d8afb315 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -129,7 +129,7 @@ jobs: echo "Running checks..." ./ietf/manage.py check echo "Validating migrations..." - $do ./ietf/manage.py makemigrations | tee /dev/stderr | $do grep -q "^No changes detected$" || die "Model changes without migrations found." + ./ietf/manage.py makemigrations | tee /dev/stderr | grep -q "^No changes detected$" || echo -e "\nModel changes without migrations found." && exit 1" echo "Running tests..." ./ietf/manage.py test --settings=settings_sqlitetest coverage xml diff --git a/.github/workflows/ci-run-tests.yml b/.github/workflows/ci-run-tests.yml index 5beb5f4e087..a65cb0dccef 100644 --- a/.github/workflows/ci-run-tests.yml +++ b/.github/workflows/ci-run-tests.yml @@ -41,7 +41,7 @@ jobs: echo "Running checks..." ./ietf/manage.py check echo "Validating migrations..." - $do ./ietf/manage.py makemigrations | tee /dev/stderr | $do grep -q "^No changes detected$" || die "Model changes without migrations found." + ./ietf/manage.py makemigrations | tee /dev/stderr | grep -q "^No changes detected$" || echo -e "\nModel changes without migrations found." && exit 1" echo "Running tests..." ./ietf/manage.py test --settings=settings_sqlitetest coverage xml From 9e27628618240777a668dc4d7c37b7c99bdd580e Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Tue, 3 May 2022 11:31:59 -0500 Subject: [PATCH 3/3] chore: rework conditional and exit --- .github/workflows/build.yml | 4 +++- .github/workflows/ci-run-tests.yml | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b80d8afb315..1f0a99dddce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -129,7 +129,9 @@ jobs: echo "Running checks..." ./ietf/manage.py check echo "Validating migrations..." - ./ietf/manage.py makemigrations | tee /dev/stderr | grep -q "^No changes detected$" || echo -e "\nModel changes without migrations found." && exit 1" + if ! (ietf/manage.py makemigrations 2>&1 | grep -q "^No changes detected$") ; then + echo -e "\nModel changes without migrations found." ; exit 1 + fi echo "Running tests..." ./ietf/manage.py test --settings=settings_sqlitetest coverage xml diff --git a/.github/workflows/ci-run-tests.yml b/.github/workflows/ci-run-tests.yml index a65cb0dccef..6037e2413cc 100644 --- a/.github/workflows/ci-run-tests.yml +++ b/.github/workflows/ci-run-tests.yml @@ -41,7 +41,9 @@ jobs: echo "Running checks..." ./ietf/manage.py check echo "Validating migrations..." - ./ietf/manage.py makemigrations | tee /dev/stderr | grep -q "^No changes detected$" || echo -e "\nModel changes without migrations found." && exit 1" + if ! (ietf/manage.py makemigrations 2>&1 | grep -q "^No changes detected$") ; then + echo -e "\nModel changes without migrations found." ; exit 1 + fi echo "Running tests..." ./ietf/manage.py test --settings=settings_sqlitetest coverage xml