From c567402f50866a8044f30327f0e225792507b3cd Mon Sep 17 00:00:00 2001 From: Jon Jenkins Date: Fri, 16 Sep 2022 09:46:34 -0500 Subject: [PATCH] Streamline test patch application While working issue #45, we discovered that the test patches were failing to apply, failing silently (the pipeline still returned a green status), and not specifying which patch file failed. This indicates that that the files we're patching in gitlab-com have drifted "out of sync" with this set of patches, and when this happens in the future we need a way to quickly detect and fix the offending patch. This commit does the following: * Renames patches in order of application for easy collated shell expansion. * Adds a new script to apply the patches using shell expansion. This makes adding/removing new patches easier. * Uses `set -e` in the new script to ensure that failing patches fail loudly. --- ...e-Migration.patch => 005-New-Table-Migration.patch} | 0 ...on.patch => 010-Drop-table-in-post-migration.patch} | 0 ...n.patch => 015-Exception-Raised-in-Migration.patch} | 0 ... 020-Add-a-migration-that-takes-five-seconds.patch} | 0 ...gration-inheriting-Gitlab-Database-Migration.patch} | 0 ... 030-Migration-that-requires-Gitlab-com-true.patch} | 0 ...ions.patch => 035-Test-background-migrations.patch} | 0 docker/gitlab/patches/testing/apply.sh | 8 ++++++++ docker/gitlab/prepare.sh | 10 ++-------- 9 files changed, 10 insertions(+), 8 deletions(-) rename docker/gitlab/patches/testing/{New-Table-Migration.patch => 005-New-Table-Migration.patch} (100%) rename docker/gitlab/patches/testing/{Drop-table-in-post-migration.patch => 010-Drop-table-in-post-migration.patch} (100%) rename docker/gitlab/patches/testing/{Exception-Raised-in-Migration.patch => 015-Exception-Raised-in-Migration.patch} (100%) rename docker/gitlab/patches/testing/{Add-a-migration-that-takes-five-seconds.patch => 020-Add-a-migration-that-takes-five-seconds.patch} (100%) rename docker/gitlab/patches/testing/{Migration-inheriting-Gitlab-Database-Migration.patch => 025-Migration-inheriting-Gitlab-Database-Migration.patch} (100%) rename docker/gitlab/patches/testing/{Migration-that-requires-Gitlab-com-true.patch => 030-Migration-that-requires-Gitlab-com-true.patch} (100%) rename docker/gitlab/patches/testing/{Test-background-migrations.patch => 035-Test-background-migrations.patch} (100%) create mode 100755 docker/gitlab/patches/testing/apply.sh diff --git a/docker/gitlab/patches/testing/New-Table-Migration.patch b/docker/gitlab/patches/testing/005-New-Table-Migration.patch similarity index 100% rename from docker/gitlab/patches/testing/New-Table-Migration.patch rename to docker/gitlab/patches/testing/005-New-Table-Migration.patch diff --git a/docker/gitlab/patches/testing/Drop-table-in-post-migration.patch b/docker/gitlab/patches/testing/010-Drop-table-in-post-migration.patch similarity index 100% rename from docker/gitlab/patches/testing/Drop-table-in-post-migration.patch rename to docker/gitlab/patches/testing/010-Drop-table-in-post-migration.patch diff --git a/docker/gitlab/patches/testing/Exception-Raised-in-Migration.patch b/docker/gitlab/patches/testing/015-Exception-Raised-in-Migration.patch similarity index 100% rename from docker/gitlab/patches/testing/Exception-Raised-in-Migration.patch rename to docker/gitlab/patches/testing/015-Exception-Raised-in-Migration.patch diff --git a/docker/gitlab/patches/testing/Add-a-migration-that-takes-five-seconds.patch b/docker/gitlab/patches/testing/020-Add-a-migration-that-takes-five-seconds.patch similarity index 100% rename from docker/gitlab/patches/testing/Add-a-migration-that-takes-five-seconds.patch rename to docker/gitlab/patches/testing/020-Add-a-migration-that-takes-five-seconds.patch diff --git a/docker/gitlab/patches/testing/Migration-inheriting-Gitlab-Database-Migration.patch b/docker/gitlab/patches/testing/025-Migration-inheriting-Gitlab-Database-Migration.patch similarity index 100% rename from docker/gitlab/patches/testing/Migration-inheriting-Gitlab-Database-Migration.patch rename to docker/gitlab/patches/testing/025-Migration-inheriting-Gitlab-Database-Migration.patch diff --git a/docker/gitlab/patches/testing/Migration-that-requires-Gitlab-com-true.patch b/docker/gitlab/patches/testing/030-Migration-that-requires-Gitlab-com-true.patch similarity index 100% rename from docker/gitlab/patches/testing/Migration-that-requires-Gitlab-com-true.patch rename to docker/gitlab/patches/testing/030-Migration-that-requires-Gitlab-com-true.patch diff --git a/docker/gitlab/patches/testing/Test-background-migrations.patch b/docker/gitlab/patches/testing/035-Test-background-migrations.patch similarity index 100% rename from docker/gitlab/patches/testing/Test-background-migrations.patch rename to docker/gitlab/patches/testing/035-Test-background-migrations.patch diff --git a/docker/gitlab/patches/testing/apply.sh b/docker/gitlab/patches/testing/apply.sh new file mode 100755 index 00000000..2ab82ebb --- /dev/null +++ b/docker/gitlab/patches/testing/apply.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +for PATCH in /gitlab/patches/testing/*.patch; do + echo "Applying patch file ${PATCH}" + git am < $PATCH +done diff --git a/docker/gitlab/prepare.sh b/docker/gitlab/prepare.sh index 94d8e2bb..1d92d4fe 100755 --- a/docker/gitlab/prepare.sh +++ b/docker/gitlab/prepare.sh @@ -30,14 +30,8 @@ test: &test EOF if test "$VALIDATION_PIPELINE"; then - echo "Applying test patch" - git am < /gitlab/patches/testing/New-Table-Migration.patch - git am < /gitlab/patches/testing/Drop-table-in-post-migration.patch - git am < /gitlab/patches/testing/Exception-Raised-in-Migration.patch - git am < /gitlab/patches/testing/Add-a-migration-that-takes-five-seconds.patch - git am < /gitlab/patches/testing/Migration-inheriting-Gitlab-Database-Migration.patch - git am < /gitlab/patches/testing/Migration-that-requires-Gitlab-com-true.patch - git am < /gitlab/patches/testing/Test-background-migrations.patch + echo "Applying test patches" + /gitlab/patches/testing/apply.sh fi ### REDIS -- GitLab