From 8cc8056b499e2540c02e8280fc37a3d661f79532 Mon Sep 17 00:00:00 2001 From: Filip Markovic Date: Tue, 2 Apr 2024 12:47:53 +0200 Subject: [PATCH 01/11] added checking of schema.rs after migrations --- ci/Jenkinsfile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index 866ceb26b..6ac742dd5 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -223,7 +223,15 @@ timeout(time: 2, unit: 'HOURS') { 'schema': runDockerPostgresSidecar( 'echo schema test', schemaStashsrc, schemaStashdir ), - 'migration': runDockerPostgresSidecar(testMigrations()), + + def beforeChecksum = sh(script: "sha256sum backend/src/schema.rs", returnStdout: true).trim() + 'migration': runDockerPostgresSidecar(testMigrations(), ['backend/src/schema.rs'], ['schema.rs']), + unstash('schema.rs'), + def afterChecksum = sh(script: "sha256sum backend/src/schema.rs", returnStdout: true).trim() + if (beforeChecksum != afterChecksum) { + throw new Exception('Schema.rs was modified during migration tests.') + } + 'changelog': runDocker( './ci/scripts/check-changelog.sh', 'permaplant-node:ci', From 2226e504ca516b9441f2839f7acf13d26f5be19a Mon Sep 17 00:00:00 2001 From: Filip Markovic Date: Tue, 2 Apr 2024 14:40:53 +0200 Subject: [PATCH 02/11] fixed migration tests --- ci/Jenkinsfile | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index 6ac742dd5..e0fd761f4 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -192,9 +192,9 @@ def testAndBuildFrontend() { */ def testMigrations() { if (env.BRANCH_NAME != 'master') { - return 'make migration && make migration-redo && make migration-redo-a' + return 'make migration-redo && make migration-redo-a' } else { - return 'make migration && make migration-redo' + return 'make migration-redo' } } @@ -224,12 +224,18 @@ timeout(time: 2, unit: 'HOURS') { 'echo schema test', schemaStashsrc, schemaStashdir ), + 'migration': runDockerPostgresSidecar( + 'make migration', + ['backend/src/schema.rs'], + ['schema.rs'] + ), + unstash('schema.rs'), def beforeChecksum = sh(script: "sha256sum backend/src/schema.rs", returnStdout: true).trim() - 'migration': runDockerPostgresSidecar(testMigrations(), ['backend/src/schema.rs'], ['schema.rs']), + 'migration-test': runDockerPostgresSidecar(testMigrations(), ['backend/src/schema.rs'], ['schema.rs']), unstash('schema.rs'), def afterChecksum = sh(script: "sha256sum backend/src/schema.rs", returnStdout: true).trim() if (beforeChecksum != afterChecksum) { - throw new Exception('Schema.rs was modified during migration tests.') + throw new SchemaModifiedException() } 'changelog': runDocker( @@ -405,3 +411,11 @@ class UnequalStashException extends Exception { } } + +class SchemaModifiedException extends Exception { + + SchemaModifiedException() { + super('Schema.rs was modified during migration tests.') + } + +} From 48978b779a32650767f3da79d263f387c13f8377 Mon Sep 17 00:00:00 2001 From: Filip Markovic Date: Thu, 4 Apr 2024 14:51:21 +0200 Subject: [PATCH 03/11] fixed migration test --- ci/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index e0fd761f4..ada831601 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -192,9 +192,9 @@ def testAndBuildFrontend() { */ def testMigrations() { if (env.BRANCH_NAME != 'master') { - return 'make migration-redo && make migration-redo-a' + return 'make migration && make migration-redo && make migration-redo-a' } else { - return 'make migration-redo' + return 'make migration && make migration-redo' } } From 76c936fc96ac7155f6360344e5ac26c97782321a Mon Sep 17 00:00:00 2001 From: Filip Markovic Date: Fri, 5 Apr 2024 10:41:19 +0200 Subject: [PATCH 04/11] trying to fix jenkins compile error --- ci/Jenkinsfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index e1484a9bf..b235dad48 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -231,7 +231,10 @@ timeout(time: 2, unit: 'HOURS') { ), unstash('schema.rs'), def beforeChecksum = sh(script: "sha256sum backend/src/schema.rs", returnStdout: true).trim() - 'migration-test': runDockerPostgresSidecar(testMigrations(), ['backend/src/schema.rs'], ['schema.rs']), + 'migrationtest': runDockerPostgresSidecar( + testMigrations(), + ['backend/src/schema.rs'], + ['schema.rs']), unstash('schema.rs'), def afterChecksum = sh(script: "sha256sum backend/src/schema.rs", returnStdout: true).trim() if (beforeChecksum != afterChecksum) { From 45c7138db9ab18ba73011ac27b7fa4d63920f7ef Mon Sep 17 00:00:00 2001 From: Filip Markovic Date: Fri, 5 Apr 2024 12:44:19 +0200 Subject: [PATCH 05/11] try and fix failing jenkins --- ci/Jenkinsfile | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index b235dad48..73e097903 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -208,6 +208,7 @@ timeout(time: 2, unit: 'HOURS') { 'backend/src/schema.rs', 'frontend/src/api_types/definitions.ts' ] List schemaStashdir = ['schema.rs', 'definitions.ts'] + parallel( 'pre-commit': runDocker( './ci/scripts/check-pre-commit.sh', @@ -229,17 +230,6 @@ timeout(time: 2, unit: 'HOURS') { ['backend/src/schema.rs'], ['schema.rs'] ), - unstash('schema.rs'), - def beforeChecksum = sh(script: "sha256sum backend/src/schema.rs", returnStdout: true).trim() - 'migrationtest': runDockerPostgresSidecar( - testMigrations(), - ['backend/src/schema.rs'], - ['schema.rs']), - unstash('schema.rs'), - def afterChecksum = sh(script: "sha256sum backend/src/schema.rs", returnStdout: true).trim() - if (beforeChecksum != afterChecksum) { - throw new SchemaModifiedException() - } 'changelog': runDocker( './ci/scripts/check-changelog.sh', @@ -249,6 +239,21 @@ timeout(time: 2, unit: 'HOURS') { ), failFast: true ) + + unstash('schema.rs') + def beforeChecksum = sh(script: "sha256sum backend/src/schema.rs", returnStdout: true).trim() + + runDockerPostgresSidecar( + testMigrations(), + ['backend/src/schema.rs'], + ['schema.rs'] + ) + + unstash('schema.rs') + def afterChecksum = sh(script: "sha256sum backend/src/schema.rs", returnStdout: true).trim() + if (beforeChecksum != afterChecksum) { + throw new SchemaModifiedException() + } } stage('Test and Build') { From 5f295677ba1f9d2197f4cc742310a813008b4bbe Mon Sep 17 00:00:00 2001 From: Filip Markovic Date: Fri, 5 Apr 2024 12:52:26 +0200 Subject: [PATCH 06/11] added changelog --- doc/changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changelog.md b/doc/changelog.md index e20838886..c1014cc7e 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -84,7 +84,7 @@ Syntax: `- short text describing the change _(Your Name)_` - wrap api queries using react query _(Daniel Steinkogler)_ - _()_ - CI: unstash schemas in release pipeline in build-backend _(4ydan)_ -- _()_ +- CI: added check if schema.rs changes in remigration _(Filip Markovic)_ - _()_ - Add decision for polygon libraries _(Daniel Steinkogler)_ - _()_ From bceac5aa2d2a81c69e834ba2efb91c677d4d0105 Mon Sep 17 00:00:00 2001 From: Filip Markovic Date: Sat, 6 Apr 2024 12:51:23 +0200 Subject: [PATCH 07/11] fixed checking for schema changes in migration test --- ci/Jenkinsfile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index 73e097903..0c0e08d0d 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -228,7 +228,7 @@ timeout(time: 2, unit: 'HOURS') { 'migration': runDockerPostgresSidecar( 'make migration', ['backend/src/schema.rs'], - ['schema.rs'] + ['schemaold.rs'] ), 'changelog': runDocker( @@ -239,20 +239,20 @@ timeout(time: 2, unit: 'HOURS') { ), failFast: true ) - - unstash('schema.rs') - def beforeChecksum = sh(script: "sha256sum backend/src/schema.rs", returnStdout: true).trim() - runDockerPostgresSidecar( testMigrations(), ['backend/src/schema.rs'], - ['schema.rs'] + ['schemanew.rs'] ) - unstash('schema.rs') - def afterChecksum = sh(script: "sha256sum backend/src/schema.rs", returnStdout: true).trim() - if (beforeChecksum != afterChecksum) { - throw new SchemaModifiedException() + node('docker') { + unstash('schemaold.rs') + def beforeChecksum = sh(script: "sha256sum backend/src/schemaold.rs", returnStdout: true).trim() + unstash('schemanew.rs') + def afterChecksum = sh(script: "sha256sum backend/src/schemanew.rs", returnStdout: true).trim() + if (beforeChecksum != afterChecksum) { + throw new SchemaModifiedException() + } } } From 75d9a873352d389d86e8386360b09b34e1630d8c Mon Sep 17 00:00:00 2001 From: Filip Markovic Date: Sat, 6 Apr 2024 12:57:47 +0200 Subject: [PATCH 08/11] fixed checking of correct schema.rs files --- ci/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index 0c0e08d0d..b8cbf198d 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -247,9 +247,9 @@ timeout(time: 2, unit: 'HOURS') { node('docker') { unstash('schemaold.rs') - def beforeChecksum = sh(script: "sha256sum backend/src/schemaold.rs", returnStdout: true).trim() + def beforeChecksum = sh(script: "sha256sum backend/src/schema.rs", returnStdout: true).trim() unstash('schemanew.rs') - def afterChecksum = sh(script: "sha256sum backend/src/schemanew.rs", returnStdout: true).trim() + def afterChecksum = sh(script: "sha256sum backend/src/schema.rs", returnStdout: true).trim() if (beforeChecksum != afterChecksum) { throw new SchemaModifiedException() } From aba5d49d8657a3438657eb926bc6e2a0623272f2 Mon Sep 17 00:00:00 2001 From: Filip Markovic Date: Sat, 6 Apr 2024 13:13:00 +0200 Subject: [PATCH 09/11] put remigration test in parallel block --- ci/Jenkinsfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index b8cbf198d..ffefea9c8 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -231,6 +231,12 @@ timeout(time: 2, unit: 'HOURS') { ['schemaold.rs'] ), + runDockerPostgresSidecar( + testMigrations(), + ['backend/src/schema.rs'], + ['schemanew.rs'] + ), + 'changelog': runDocker( './ci/scripts/check-changelog.sh', 'permaplant-node:ci', @@ -239,11 +245,6 @@ timeout(time: 2, unit: 'HOURS') { ), failFast: true ) - runDockerPostgresSidecar( - testMigrations(), - ['backend/src/schema.rs'], - ['schemanew.rs'] - ) node('docker') { unstash('schemaold.rs') From b21e77db4c74e423cf02c42725d0484947374e2d Mon Sep 17 00:00:00 2001 From: Filip Markovic Date: Sat, 6 Apr 2024 13:15:42 +0200 Subject: [PATCH 10/11] correctly named function for testMigrations in parallel block --- ci/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index ffefea9c8..f10299c12 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -231,7 +231,7 @@ timeout(time: 2, unit: 'HOURS') { ['schemaold.rs'] ), - runDockerPostgresSidecar( + 'redomigration': runDockerPostgresSidecar( testMigrations(), ['backend/src/schema.rs'], ['schemanew.rs'] From 1fdd34f91178e13ecfb50cb199c3b4dd083cbce7 Mon Sep 17 00:00:00 2001 From: Filip Markovic Date: Sat, 6 Apr 2024 13:21:05 +0200 Subject: [PATCH 11/11] added message if schema.rs was not modified --- ci/Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index f10299c12..de3414ada 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -208,7 +208,6 @@ timeout(time: 2, unit: 'HOURS') { 'backend/src/schema.rs', 'frontend/src/api_types/definitions.ts' ] List schemaStashdir = ['schema.rs', 'definitions.ts'] - parallel( 'pre-commit': runDocker( './ci/scripts/check-pre-commit.sh', @@ -253,6 +252,8 @@ timeout(time: 2, unit: 'HOURS') { def afterChecksum = sh(script: "sha256sum backend/src/schema.rs", returnStdout: true).trim() if (beforeChecksum != afterChecksum) { throw new SchemaModifiedException() + } else { + echo 'Schema.rs was not modified during migration tests.' } } }