Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit45b45f1

Browse files
authored
ci: re-enable test migrations in release workflow (#13307)
1 parenta63d427 commit45b45f1

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
iferr:=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
iferr:=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
iferr!=nil {
94-
panic(err)
97+
friendlyError(os.Stderr,err,migrateFromVersion,migrateToVersion)
98+
os.Exit(1)
9599
}
96100

97101
ifdiff:=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+
funcfriendlyError(w io.Writer,errerror,v1,v2string) {
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
funcmakeMigrateFS(versionstring) (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)

[8]ページ先頭

©2009-2025 Movatter.jp