@@ -33,11 +33,10 @@ def runDockerWithPostgresSidecar(String command, String stashsrc='', String stas
33
33
checkout scm
34
34
def rust_image = docker. build(" permaplant-rust" , " ./ci/container-images/permaplant-rust" )
35
35
docker. image(' postgis/postgis:13-3.1' ). withRun(' -e "POSTGRES_USER=ci" -e "POSTGRES_PASSWORD=ci"' ) { c ->
36
- rust_image. inside(" --link ${ c.id} :db -e 'DATABASE_URL=postgres://ci:ci@db/ci' -e 'BIND_ADDRESS_HOST=127.0.0.1' -e 'BIND_ADDRESS_PORT=8080' -e 'AUTH_DISCOVERY_URI=unused' -e 'AUTH_CLIENT_ID=unused' -e 'RUSTFLAGS=-D warnings' -e 'RUSTDOCFLAGS=-D warnings'" ) {
36
+ rust_image. inside(" --link ${ c.id} :db -e 'DATABASE_URL=postgres://ci:ci@db/ci' -e 'BIND_ADDRESS_HOST=127.0.0.1' -e 'BIND_ADDRESS_PORT=8080' -e 'AUTH_DISCOVERY_URI=unused' -e 'AUTH_CLIENT_ID=unused' -e 'RUSTFLAGS=-D warnings' -e 'RUSTDOCFLAGS=-D warnings' -e 'LC_ALL=C' " ) {
37
37
checkout scm
38
38
wait_for_db()
39
39
sh ' ./ci/build-scripts/build-schema.sh'
40
- // Because in Deploy the path for /target is a env in permaplant-deploy.sh, we can only solve it with prepending cd backend
41
40
sh " cd backend && ${ command} "
42
41
if (stashsrc != null && stashdir != ' ' ) {
43
42
stash includes : stashsrc, name : stashdir
@@ -109,39 +108,30 @@ def testAndBuildFrontend() {
109
108
}
110
109
}
111
110
111
+ def determineMigration () {
112
+ if (env. BRANCH_NAME != " master" ) {
113
+ return " make migration-redo && make migration-redo-a"
114
+ } else {
115
+ return " make migration-redo"
116
+ }
117
+ }
118
+
112
119
// PIPELINE BEGIN
113
120
abortPreviousRunUnlessMaster()
114
121
115
- // REQUIRED for Deployment
116
- // see Jenkinsfile.release
117
- stage(' FMT check Build Schema' ){
118
- node(' docker' ) {
119
- node_info()
120
- checkout scm
121
- def rust_image = docker. build(" permaplant-rust" , " ./ci/container-images/permaplant-rust" )
122
- docker. image(' postgis/postgis:13-3.1' ). withRun(' -e "POSTGRES_USER=ci" -e "POSTGRES_PASSWORD=ci"' ) { c ->
123
- rust_image. inside(" --link ${ c.id} :db -e 'DATABASE_URL=postgres://ci:ci@db/ci'" ) {
124
- checkout scm
125
- wait_for_db()
126
- withEnv([' RUSTFLAGS=-D warnings' , ' RUSTDOCFLAGS=-D warnings' ]) {
127
- // Workaround: we can't stop rustfmt from linting the generated schema.rs
128
- dir(" backend" ) {
129
- sh " /bin/bash -c 'echo \"\" > src/schema.rs'"
130
- sh " cargo fmt --check"
131
- // End of Workaround
132
- }
133
- sh ' ./ci/build-scripts/build-schema.sh'
134
- }
135
- stash includes : ' backend/src/schema.rs' , name : ' schema.rs'
136
- stash includes : ' frontend/src/bindings/definitions.ts' , name : ' definitions.ts'
137
- }
122
+ timeout(time : 2 , unit : ' HOURS' ) {
123
+ try {
124
+ stage(' Sanity' ) {
125
+ parallel(
126
+ // Workaround: we can't stop rustfmt from linting the generated schema.rs so we empty the file before.
127
+ " cargo-fmt" : runDockerWithPostgresSidecar(" /bin/bash -c 'echo \"\" > src/schema.rs' && cargo fmt --check" ),
128
+ " schema" : runDockerWithPostgresSidecar(' echo schema test' , ' backend/src/schema.rs' , ' schema.rs' ),
129
+ " migration" : runDockerWithPostgresSidecar(determineMigration()),
130
+ failFast : true
131
+ )
138
132
}
139
- }
140
- }
141
133
142
- stage(' Parallel Stage' ) {
143
- timeout(time : 2 , unit : ' HOURS' ){
144
- try {
134
+ stage(' Test and Build' ) {
145
135
parallel(
146
136
" cargo-build" : runDockerWithPostgresSidecar(' cargo build --release && cargo clippy' , ' backend/target/release/backend' , ' backend' ),
147
137
" cargo-check" : runDockerWithPostgresSidecar(' cargo check && cargo doc' ),
@@ -150,10 +140,10 @@ stage('Parallel Stage') {
150
140
" mdbook" : testAndBuildMdbook(),
151
141
failFast : true
152
142
)
153
- } catch (err) {
154
- deleteDir();
155
- throw err;
156
143
}
144
+ } catch (err) {
145
+ deleteDir();
146
+ throw err;
157
147
}
158
148
}
159
149
0 commit comments