From bbc3ec54c785225068477187d16ac145f74c789c Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 26 Jun 2020 12:48:44 +1200 Subject: [PATCH] CI: Fetch and cache Sapling parameters for tests --- .github/workflows/ci.yml | 15 +++++++++++++++ .travis.yml | 19 ------------------- zcash_proofs/Cargo.toml | 4 ++++ zcash_proofs/examples/get-params-path.rs | 7 +++++++ zcash_proofs/src/lib.rs | 2 +- 5 files changed, 27 insertions(+), 20 deletions(-) delete mode 100644 .travis.yml create mode 100644 zcash_proofs/examples/get-params-path.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7724e4ab2..3735bf199 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,6 +50,21 @@ jobs: with: toolchain: 1.40.0 override: true + + - name: Fetch path to Zcash parameters + working-directory: ./zcash_proofs + run: echo "::set-env name=ZCASH_PARAMS::$(cargo run --release --example get-params-path --features directories)" + - name: Cache Zcash parameters + id: cache-params + uses: actions/cache@v2 + with: + path: ${{ env.ZCASH_PARAMS }} + key: ${{ runner.os }}-params + - name: Fetch Zcash parameters + if: steps.cache-params.outputs.cache-hit != 'true' + working-directory: ./zcash_proofs + run: cargo run --release --example download-params --features download-params + - name: cargo fetch uses: actions-rs/cargo@v1 with: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e77c9e296..000000000 --- a/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -language: rust -rust: - - 1.40.0 - -cache: cargo - -before_script: - - rustup component add rustfmt - -script: - - cargo build --verbose --release --all - - cargo fmt --all -- --check - - cargo test --verbose --release --all - - cargo test --verbose --release --all -- --ignored - -before_cache: - - rm -rf "$TRAVIS_HOME/.cargo/registry/src" - - cargo install cargo-update || echo "cargo-update already installed" - - cargo install-update -a # update outdated cached binaries diff --git a/zcash_proofs/Cargo.toml b/zcash_proofs/Cargo.toml index 62d568cef..4a58e9dfb 100644 --- a/zcash_proofs/Cargo.toml +++ b/zcash_proofs/Cargo.toml @@ -31,6 +31,10 @@ download-params = ["minreq"] local-prover = ["directories"] multicore = ["bellman/multicore"] +[[example]] +name = "get-params-path" +required-features = ["directories"] + [[example]] name = "download-params" required-features = ["download-params"] diff --git a/zcash_proofs/examples/get-params-path.rs b/zcash_proofs/examples/get-params-path.rs new file mode 100644 index 000000000..224b2f5ea --- /dev/null +++ b/zcash_proofs/examples/get-params-path.rs @@ -0,0 +1,7 @@ +fn main() { + if let Some(path) = zcash_proofs::default_params_folder() { + if let Some(path) = path.to_str() { + println!("{}", path); + } + } +} diff --git a/zcash_proofs/src/lib.rs b/zcash_proofs/src/lib.rs index e952be6be..e14a26953 100644 --- a/zcash_proofs/src/lib.rs +++ b/zcash_proofs/src/lib.rs @@ -39,7 +39,7 @@ const DOWNLOAD_URL: &str = "https://download.z.cash/downloads"; /// Returns the default folder that the Zcash proving parameters are located in. #[cfg(feature = "directories")] -fn default_params_folder() -> Option { +pub fn default_params_folder() -> Option { BaseDirs::new().map(|base_dirs| { if cfg!(any(windows, target_os = "macos")) { base_dirs.data_dir().join("ZcashParams")