Dear rust community,
Firstly, I hope that all of you are fine and is ready for a better 2021 than 2020.
I'm trying to optimize our gitlab CI/CD workflow, because a very small codebase (2 endpoints using actix-web, and sending mails with lettre). I'm not author of this codebase, just acting as a devops for this.
I have many stages, that you can figure with this graph (please see dot code for this graph, if someone wants to edit)
digraph G {
rankdir="LR";
subgraph cluster_pre {
label="Fetch";
fetch
}
subgraph cluster_build {
label="Build";
buildDebug
buildRelease
}
subgraph cluster_docker {
label="Docker build";
buildDocker
}
subgraph cluster_test {
label="Tests";
runTests
runFmt
}
subgraph cluster_deploy {
label="Deploy";
deployment
}
fetch -> {buildDebug,buildRelease,runFmt}
buildRelease->buildDocker->deployment
buildDebug->runTests
}
So, as far as I know, I need a build with debug to run cargo test
, and and need a build with --release
for my docker build that will be deployed.
But a build is really expansive, so this kind of pipeline took ~40min.
Is it possible to build debug & release in the same time, with the same command, to be more efficient ? Maybe sharing cache with sccache while buildling debug and release builds ?
Other question, buildRelease and buildDocker are both musl linux, and I don't know why build into docker rebuild dependencies, even when I copy .cargo
and target
, both have exactly the same toolchain.
Currently my workaround is to add an if
condition in dockerfile, to run cargo build
only if the binary doesnt exists.
Thanks for your help,
Gaël