Skip to content
This repository was archived by the owner on Apr 24, 2024. It is now read-only.

Commit 90be23c

Browse files
committed
New parallel sanity stage + test migrations
1 parent 2c634d9 commit 90be23c

File tree

2 files changed

+24
-34
lines changed

2 files changed

+24
-34
lines changed

ci/Jenkinsfile

+23-33
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ def runDockerWithPostgresSidecar(String command, String stashsrc='', String stas
3333
checkout scm
3434
def rust_image = docker.build("permaplant-rust", "./ci/container-images/permaplant-rust")
3535
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'") {
3737
checkout scm
3838
wait_for_db()
3939
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
4140
sh "cd backend && ${command}"
4241
if (stashsrc != null && stashdir != '') {
4342
stash includes: stashsrc, name: stashdir
@@ -109,39 +108,30 @@ def testAndBuildFrontend() {
109108
}
110109
}
111110

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+
112119
// PIPELINE BEGIN
113120
abortPreviousRunUnlessMaster()
114121

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+
)
138132
}
139-
}
140-
}
141133

142-
stage('Parallel Stage') {
143-
timeout(time: 2, unit: 'HOURS'){
144-
try {
134+
stage('Test and Build') {
145135
parallel(
146136
"cargo-build": runDockerWithPostgresSidecar('cargo build --release && cargo clippy', 'backend/target/release/backend', 'backend'),
147137
"cargo-check": runDockerWithPostgresSidecar('cargo check && cargo doc'),
@@ -150,10 +140,10 @@ stage('Parallel Stage') {
150140
"mdbook": testAndBuildMdbook(),
151141
failFast: true
152142
)
153-
} catch(err) {
154-
deleteDir();
155-
throw err;
156143
}
144+
} catch(err) {
145+
deleteDir();
146+
throw err;
157147
}
158148
}
159149

ci/container-images/permaplant-rust/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM rust:1.67.1-slim
22

3-
RUN apt update && apt install -y libpq-dev libssl-dev pkg-config postgresql-client
3+
RUN apt update && apt install -y make libpq-dev libssl-dev pkg-config postgresql-client
44
RUN rustup component add clippy rustfmt
55
RUN cargo install [email protected] --no-default-features --features postgres
66
RUN cargo install typeshare-cli

0 commit comments

Comments
 (0)