From 89166a7f61a3fb2781169df9425874be86114d91 Mon Sep 17 00:00:00 2001 From: Michael Skarbek Date: Tue, 14 Sep 2021 10:05:24 -0400 Subject: [PATCH] create `check-migrations` workflow (#3140) --- .github/scripts/check_migrations.sh | 15 +++++++++++++++ .github/workflows/check-clowdapp.yml | 4 ++-- .github/workflows/check-manifest.yml | 2 +- .github/workflows/pre-commit.yml | 2 +- .github/workflows/pre-release.yaml | 2 +- .github/workflows/unittests.yml | 14 +++++++++++++- 6 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 .github/scripts/check_migrations.sh diff --git a/.github/scripts/check_migrations.sh b/.github/scripts/check_migrations.sh new file mode 100644 index 0000000000..0c3f7576f7 --- /dev/null +++ b/.github/scripts/check_migrations.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +pipenv run make make-migrations + +changed=`git add -N . && git diff --name-only HEAD` + +if [[ $changed == *"migration"* ]]; then + echo "Migrations are out of sync with the models. Run 'make make-migrations' to update." + exit 1 +else + echo "Migrations are in sync." + exit 0 +fi diff --git a/.github/workflows/check-clowdapp.yml b/.github/workflows/check-clowdapp.yml index bdb077d8ed..ffd0429b7f 100644 --- a/.github/workflows/check-clowdapp.yml +++ b/.github/workflows/check-clowdapp.yml @@ -1,4 +1,4 @@ -name: ClowdApp check +name: Check Clowdapp on: pull_request: @@ -6,7 +6,7 @@ on: - main jobs: - clowdapp-check: + check-clowdapp: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/check-manifest.yml b/.github/workflows/check-manifest.yml index 98259d5f21..054ed36591 100644 --- a/.github/workflows/check-manifest.yml +++ b/.github/workflows/check-manifest.yml @@ -1,4 +1,4 @@ -name: Check manifest +name: Check Manifest on: pull_request: diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 6b8154d33e..9c15b23699 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -1,4 +1,4 @@ -name: pre-commit +name: Linting and Formatting on: pull_request: diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml index f7f59d1efb..2560eefa88 100644 --- a/.github/workflows/pre-release.yaml +++ b/.github/workflows/pre-release.yaml @@ -1,4 +1,4 @@ -name: pre release +name: Create Pre-Release on: workflow_dispatch: diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index f2533aa17a..22ecdc34f8 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -1,4 +1,4 @@ -name: Unit Tests +name: Check Migrations and Run Unit Tests on: pull_request: @@ -63,6 +63,18 @@ jobs: run: | pipenv install --dev --ignore-pipfile --python ${{ matrix.python-version }} + - name: Check migrations + run: bash .github/scripts/check_migrations.sh + env: + DATABASE_SERVICE_NAME: POSTGRES_SQL + DATABASE_ENGINE: postgresql + DATABASE_NAME: postgres + DATABASE_USER: postgres + DATABASE_PASSWORD: postgres + POSTGRES_SQL_SERVICE_HOST: localhost + POSTGRES_SQL_SERVICE_PORT: ${{ job.services.postgres.ports[5432] }} + prometheus_multiproc_dir: /tmp + - name: Run unit tests run: pipenv run coverage run ./koku/manage.py test --noinput --verbosity 2 ./koku/ env: