From 537ee5e2442e8bd4409a2472c5f9e2f939fd648f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20Garc=C3=ADa=20Veytia=20=28puerco=29?= Date: Thu, 17 Oct 2024 01:11:48 -0600 Subject: [PATCH] Revert "Temporarily remove migration check" This reverts commit aaa57c7f5b707a003ce64aa2816dba495a89005c. --- .github/workflows/migrate-touch.yml | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/migrate-touch.yml diff --git a/.github/workflows/migrate-touch.yml b/.github/workflows/migrate-touch.yml new file mode 100644 index 0000000000..030cd17d42 --- /dev/null +++ b/.github/workflows/migrate-touch.yml @@ -0,0 +1,41 @@ +# SPDX-FileCopyrightText: Copyright 2023 The Minder Authors +# SPDX-License-Identifier: Apache-2.0 + +# This test verifies that Pull Requests don't touch the merged database migrations. +# Folks should now only be adding new migrations to the `database/migrations/` directory. +name: Database Migrations Untouched +on: + pull_request: + paths: + - 'database/migrations/*' + - '.github/workflows/migrate-touch.yml' +jobs: + verify-migrations: + name: Don't touch existing migrations + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + with: + fetch-depth: 0 + - name: Verify Migration Files + run: | + # Check out the base branch + git checkout $GITHUB_BASE_REF + # Get files in migration directory before our changes + BEFORE=$(find database/migrations/ -type f | sort) + echo "Files before: $BEFORE" + + # Check out our changes + git checkout $GITHUB_SHA -- database/migrations/ + + # Verify that the existing migration files were not touched by the new changes + modified=$(git diff --name-only origin/$GITHUB_BASE_REF $GITHUB_SHA -- database/migrations/) + echo "Files modified: $modified" + for file in $modified; do + if [[ $BEFORE == *"$file"* ]]; then + echo "ERROR: $file was modified by this PR. Please only add new migrations to the database/migrations/ directory." + exit 1 + fi + done + shell: bash