use super::{Template, TemplateFile};
const SCRIPTS_TOML: &str = r#"# Generated by `cargo script init --template gitlab-ci`
[global_env]
RUST_BACKTRACE = "1"
CARGO_TERM_COLOR = "always"
[scripts]
ci = { include = ["fmt-check", "lint", "test", "build"], info = "Full CI pipeline" }
fmt-check = "cargo fmt --all -- --check"
lint = "cargo clippy --all-targets --all-features -- -D warnings"
test = "cargo test --all-features"
build = "cargo build --release"
"#;
const GITLAB_CI: &str = r#"# Generated by `cargo script init --template gitlab-ci`
image: rust:latest
stages: [check, build]
variables:
CARGO_HOME: $CI_PROJECT_DIR/.cargo
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .cargo/registry/cache
- target
before_script:
- rustup component add rustfmt clippy
- cargo install cargo-run
ci:
stage: check
script:
- cargo script ci
release:
stage: build
only:
- tags
script:
- cargo script build
"#;
pub const TEMPLATE: Template = Template {
name: "gitlab-ci",
description: "Scripts.toml + .gitlab-ci.yml for GitLab CI",
files: &[
TemplateFile { path: "Scripts.toml", contents: SCRIPTS_TOML },
TemplateFile { path: ".gitlab-ci.yml", contents: GITLAB_CI },
],
};