From ef854715f3b135fc3c8277c0cab1df61c4fd1c33 Mon Sep 17 00:00:00 2001 From: Andreas Fuchs Date: Tue, 23 Oct 2018 12:25:44 +0200 Subject: [PATCH] Allow customizing the cache --- src/main.rs | 8 ++++++++ templates/travis.yml | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 6770cfd..b8d50c1 100755 --- a/src/main.rs +++ b/src/main.rs @@ -130,6 +130,9 @@ struct TemplateCIConfig<'a> { #[serde(default)] additional_matrix_entries: HashMap<&'a str, CustomEntry<'a>>, + #[serde(default = "TemplateCIConfig::default_cache")] + cache: &'a str, + #[serde(default = "TemplateCIConfig::default_os")] os: &'a str, @@ -152,6 +155,7 @@ impl<'a> Default for TemplateCIConfig<'a> { rustfmt: Default::default(), additional_matrix_entries: Default::default(), dist: "xenial", + cache: "cargo", os: "linux", versions: vec!["stable", "beta", "nightly"], test_commandline: "cargo test --verbose --all".to_owned(), @@ -160,6 +164,10 @@ impl<'a> Default for TemplateCIConfig<'a> { } impl<'a> TemplateCIConfig<'a> { + fn default_cache() -> &'a str { + Self::default().cache + } + fn default_os() -> &'a str { Self::default().os } diff --git a/templates/travis.yml b/templates/travis.yml index c723d14..e905400 100644 --- a/templates/travis.yml +++ b/templates/travis.yml @@ -4,7 +4,7 @@ dist: "{{dist}}" language: rust sudo: required -cache: cargo +cache: {{cache}} rust: - stable