From c172c564a34686b5fbbc031cbeccbc9a88e4f3f2 Mon Sep 17 00:00:00 2001 From: Angela Tran Date: Fri, 24 May 2024 19:05:43 +0000 Subject: [PATCH 1/3] ci: add initial workflow definition for checking makemigrations run when files under /benefits are changed in a pull request or push --- .github/workflows/check-makemigrations.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .github/workflows/check-makemigrations.yml diff --git a/.github/workflows/check-makemigrations.yml b/.github/workflows/check-makemigrations.yml new file mode 100644 index 000000000..44808935e --- /dev/null +++ b/.github/workflows/check-makemigrations.yml @@ -0,0 +1,8 @@ +name: Check for up-to-date Django migrations +on: + pull_request: + paths: + - "benefits/**" + push: + paths: + - "benefits/**" From f42e6a3166f313c837b2f8dc0a29eff06f1633fb Mon Sep 17 00:00:00 2001 From: Angela Tran Date: Fri, 24 May 2024 19:06:37 +0000 Subject: [PATCH 2/3] ci: add steps needed to set up environment --- .github/workflows/check-makemigrations.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/check-makemigrations.yml b/.github/workflows/check-makemigrations.yml index 44808935e..3eab290d2 100644 --- a/.github/workflows/check-makemigrations.yml +++ b/.github/workflows/check-makemigrations.yml @@ -6,3 +6,24 @@ on: push: paths: - "benefits/**" + +jobs: + check-makemigrations: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Install system packages + run: | + sudo apt-get update -y + sudo apt-get install -y gettext + + - uses: actions/setup-python@v5 + with: + python-version-file: .github/workflows/.python-version + cache: pip + cache-dependency-path: "**/pyproject.toml" + + - name: Install Python dependencies + run: pip install -e .[dev,test] From 52e0906ce05d9546e5835ac9d6e1fa0b9fc2cb35 Mon Sep 17 00:00:00 2001 From: Angela Tran Date: Fri, 24 May 2024 19:07:50 +0000 Subject: [PATCH 3/3] ci: add step to run helper script and check output fail if expected message is not present ("No changes detected") --- .github/workflows/check-makemigrations.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/check-makemigrations.yml b/.github/workflows/check-makemigrations.yml index 3eab290d2..f79537f60 100644 --- a/.github/workflows/check-makemigrations.yml +++ b/.github/workflows/check-makemigrations.yml @@ -27,3 +27,12 @@ jobs: - name: Install Python dependencies run: pip install -e .[dev,test] + + - name: Run ./bin/makemigrations.sh + run: | + if ./bin/makemigrations.sh | grep -q 'No changes detected'; + then + exit 0; + else + exit 1; + fi