Skip to content

Commit 45b45f1

Browse files
authored
ci: re-enable test migrations in release workflow (#13307)
1 parent a63d427 commit 45b45f1

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

.github/workflows/release.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ jobs:
178178
env:
179179
EV_SIGNING_CERT: ${{ secrets.EV_SIGNING_CERT }}
180180

181-
# - name: Test migrations from current ref to main
182-
# run: |
183-
# make test-migrations
181+
- name: Test migrations from current ref to main
182+
run: |
183+
make test-migrations
184184
185185
# Setup GCloud for signing Windows binaries.
186186
- name: Authenticate to Google Cloud

scripts/migrate-test/main.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"database/sql"
77
"flag"
88
"fmt"
9+
"io"
910
"io/fs"
1011
"os"
1112
"os/exec"
@@ -80,27 +81,39 @@ func main() {
8081

8182
_, _ = fmt.Fprintf(os.Stderr, "Init database at version %q\n", migrateFromVersion)
8283
if err := migrations.UpWithFS(conn, migrateFromFS); err != nil {
83-
panic(err)
84+
friendlyError(os.Stderr, err, migrateFromVersion, migrateToVersion)
85+
os.Exit(1)
8486
}
8587

8688
_, _ = fmt.Fprintf(os.Stderr, "Migrate to version %q\n", migrateToVersion)
8789
if err := migrations.UpWithFS(conn, migrateToFS); err != nil {
88-
panic(err)
90+
friendlyError(os.Stderr, err, migrateFromVersion, migrateToVersion)
91+
os.Exit(1)
8992
}
9093

9194
_, _ = fmt.Fprintf(os.Stderr, "Dump schema at version %q\n", migrateToVersion)
9295
dumpBytesAfter, err := dbtestutil.PGDumpSchemaOnly(postgresURL)
9396
if err != nil {
94-
panic(err)
97+
friendlyError(os.Stderr, err, migrateFromVersion, migrateToVersion)
98+
os.Exit(1)
9599
}
96100

97101
if diff := cmp.Diff(string(dumpBytesAfter), string(stripGenPreamble(expectedSchemaAfter))); diff != "" {
98-
_, _ = fmt.Fprintf(os.Stderr, "Schema differs from expected after migration: %s\n", diff)
102+
friendlyError(os.Stderr, xerrors.Errorf("Schema differs from expected after migration: %s", diff), migrateFromVersion, migrateToVersion)
99103
os.Exit(1)
100104
}
101105
_, _ = fmt.Fprintf(os.Stderr, "OK\n")
102106
}
103107

108+
func friendlyError(w io.Writer, err error, v1, v2 string) {
109+
_, _ = fmt.Fprintf(w, "Migrating from version %q to %q failed:\n", v1, v2)
110+
_, _ = fmt.Fprintf(w, "\t%s\n", err.Error())
111+
_, _ = fmt.Fprintf(w, "Check the following:\n")
112+
_, _ = fmt.Fprintf(w, " - All migrations from version %q must exist in version %q with the same migration numbers.\n", v2, v1)
113+
_, _ = fmt.Fprintf(w, " - Each migration must have the same effect.\n")
114+
_, _ = fmt.Fprintf(w, " - There must be no gaps or duplicates in the migration numbers.\n")
115+
}
116+
104117
func makeMigrateFS(version string) (fs.FS, error) {
105118
// Export the migrations from the requested version to a zip archive
106119
out, err := exec.Command("git", "archive", "--format=zip", version, "coderd/database/migrations").CombinedOutput()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy