Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Temporarily remove migration check" #4771

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/migrate-touch.yml
Original file line number Diff line number Diff line change
@@ -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
Loading