Continue the Drone CI config

This commit is contained in:
Ana Gelez 2020-07-15 12:40:11 +02:00
parent b2829908f1
commit b26e785277

View File

@ -7,14 +7,6 @@
// Its Dockerfile can be found at https://git.joinplu.me/plume/buildenv // Its Dockerfile can be found at https://git.joinplu.me/plume/buildenv
local plumeEnv = "plumeorg/plume-buildenv:v0.0.9"; local plumeEnv = "plumeorg/plume-buildenv:v0.0.9";
// A utility function to generate a new pipeline
local basePipeline(name, steps) = {
kind: "pipeline",
name: name,
type: "docker",
steps: steps
};
// A pipeline step that restores the cache. // A pipeline step that restores the cache.
// The cache contains all the cargo build files. // The cache contains all the cargo build files.
// Thus, we don't have to download and compile all of our dependencies for each // Thus, we don't have to download and compile all of our dependencies for each
@ -74,50 +66,120 @@ local startDb(db) = if db == "postgres" then {
} }
}; };
// A utility function to generate a new pipeline
local basePipeline(name, steps) = {
kind: "pipeline",
name: name,
type: "docker",
steps: steps
};
// And this function creates a pipeline with caching
local cachedPipeline(name, commands) = basePipeline(
name,
[
restoreCache,
{
name: name,
image: plumeEnv,
commands: commands,
},
saveCache
]
);
// Here starts the actual list of pipelines! // Here starts the actual list of pipelines!
// First one: a pipeline that runs cargo fmt, and that fails if the style of // PIPELINE 1: a pipeline that runs cargo fmt, and that fails if the style of
// the code is not standard. // the code is not standard.
local CargoFmt() = basePipeline( local CargoFmt() = cachedPipeline(
"cargo-fmt", "cargo-fmt",
[ [ "cargo fmt --all -- --check" ]
restoreCache,
{
name: "cargo-fmt",
image: plumeEnv,
commands: [ "cargo fmt --all -- --check" ],
},
saveCache,
]
); );
local Clippy(db) = basePipeline( // PIPELINE 2: runs clippy, a tool that helps
"clippy-" + db, // you writing idiomatic Rust.
[
restoreCache, // Helper function:
{ local cmd(db, pkg, features=true) = if features then
local cmd(pkg, features=true) = if features then "cargo clippy --no-default-features --features " + db + "--release -p "
"cargo clippy --no-default-features --features " + db + pkg + " -- -D warnings"
+ "--release -p " + pkg + " -- -D warnings"
else else
"cargo clippy --no-default-features --release -p " "cargo clippy --no-default-features --release -p "
+ pkg + " -- -D warnings", + pkg + " -- -D warnings";
name: "clippy",
image: plumeEnv, // The actual pipeline:
commands: [ local Clippy(db) = cachedPipeline(
cmd("plume"), cmd("plume-cli"), cmd("plume-front", false) "clippy-" + db,
], [
}, cmd(db, "plume"),
saveCache, cmd(db, "plume-cli"),
cmd(db, "plume-front", false)
] ]
); );
// TODO // PIPELINE 3: runs unit tests
local Unit(db) = cachedPipeline(
"unit-" + db,
[
"cargo test --all --exclude plume-front --exclude plume-macro"
+ "--no-run --no-default-features --features=" + db
]
);
local Unit(db) = basePipeline("unit-" + db, []); // PIPELINE 4: runs integration tests
local Integration(db) = basePipeline("integration-" + db, []); // It installs a local instance an run integration test with Python scripts
local Release(db) = basePipeline("release-" + db, []); // that use Selenium (located in scripts/browser_test).
local PushTranslations() = basePipeline("push-translations", []); local Integration(db) = cachedPipeline(
"integration-" + db,
[
// Install the front-end
"cargo web deploy -p plume-front",
// Install the server
'cargo install --debug --no-default-features --features="'
+ db + '",test --force --path .',
// Install plm
'cargo install --debug --no-default-features --features="'
+ db + '",test --force --path plume-cli',
// Run the tests
"./script/run_browser_test.sh"
]
);
// PIPELINE 5: make a release build and save artifacts
//
// It should also deploy the SQlite build to a test instance
// located at https://pr-XXX.joinplu.me (but this system is not very
// stable, and often breaks).
//
// TODO: save the artifacts that are generated somewhere
local Release(db) = cachedPipeline(
"release-" + db,
[
"cargo web deploy -p plume-front --release",
"cargo build --release --no-default-features --features=" + db + " -p plume",
"cargo build --release --no-default-features --features=" + db + " -p plume-cli",
"./script/generate_artifact.sh",
] + if db == "sqlite" then [ "./script/upload_test_environment.sh" ] else []
);
// PIPELINE 6: upload the new PO templates (.pot) to Crowdin
//
// TODO: run only on master
local PushTranslations() = basePipeline(
"push-translations",
[
{
name: "push-translations",
image: plumeEnv,
commands: [
"cargo build",
"crowdin upload -b master"
]
}
]
);
// And finally, the list of all our pipelines: // And finally, the list of all our pipelines:
[ [