From 93d794a90b25ef6d5b67c737203791513ca4f4ed Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Tue, 31 Aug 2021 17:02:07 -0500 Subject: [PATCH 01/46] chore(ci): migrate lint job to CircleCI --- .circleci/config.yml | 54 ++++++++++++++++++++++++++++++++++++++ .github/workflows/lint.yml | 40 ---------------------------- 2 files changed, 54 insertions(+), 40 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 .github/workflows/lint.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..d809037fd --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,54 @@ +version: 2.1 + +# These "CircleCI Orbs" are reusable bits of configuration that can be shared +# across projects. See https://circleci.com/orbs/ for more information. +orbs: + # Rust steps which are used below (like `rust/install`, `rust/test`) are + # defined in this orb. For reference, the orb can be found here: + # https://github.com/CircleCI-Public/rust-orb + rust: circleci/rust@1.5.0 + gh: circleci/github-cli@1.0.4 + node: circleci/node@4.7.0 + +executors: + gnu_linux: &gnu_linux_executor + docker: + - image: cimg/base:stable + +# reusable command snippets can be referred to in any `steps` object +commands: + install_node: + steps: + - node/install: + node-version: "16" + npm-version: "7" + gnu_linux_install_openssl: + steps: + - run: + name: Install OpenSSL + command: sudo apt-get update && sudo apt-get install -y libssl-dev + +jobs: + cargo_xtask_lint: + executor: gnu-linux + steps: + - checkout + - when: + condition: + equal: [ *gnu_linux_executor, << parameters.platform >> ] + steps: + - gnu_linux_install_openssl + - install_node + - rust/install: + version: stable + - restore_cache: + keys: + - rust-target-v1-<< parameters.platform >>-{{ checksum "Cargo.lock" }} + - run: + name: Lint + command: cargo xtask lint + +workflows: + lint: + jobs: + - cargo_xtask_lint \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index fc2355c90..000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Linters - -on: [pull_request] - -jobs: - lint: - name: Lint - runs-on: ubuntu-16.04 - steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-node@v2 - with: - node-version: '16' - - - name: Install Rust - run: | - rustup update stable - rustup default stable - rustup component add rustfmt - rustup component add clippy - - - name: Cache Cargo registry - uses: actions/cache@v2 - with: - path: ~/.cargo/registry - key: linux-stable-cargo-registry-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - linux-stable-cargo-registry- - - - name: Cache Cargo index - uses: actions/cache@v2 - with: - path: ~/.cargo/git - key: linux-stable-cargo-index-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - linux-stable-cargo-index- - - - name: Lint - run: cargo xtask lint --verbose From 4d6133eebd69c82075e5c4773efe9c61d56ecb4f Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Tue, 31 Aug 2021 17:09:54 -0500 Subject: [PATCH 02/46] fixup: don't check for nonexistent parameter --- .circleci/config.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d809037fd..365d49bbf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,11 +33,7 @@ jobs: executor: gnu-linux steps: - checkout - - when: - condition: - equal: [ *gnu_linux_executor, << parameters.platform >> ] - steps: - - gnu_linux_install_openssl + - gnu_linux_install_openssl - install_node - rust/install: version: stable @@ -51,4 +47,4 @@ jobs: workflows: lint: jobs: - - cargo_xtask_lint \ No newline at end of file + - cargo_xtask_lint From 68d7e03a3016378c4dc9bb910dd75bc3b958b777 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Tue, 31 Aug 2021 17:15:20 -0500 Subject: [PATCH 03/46] fixup: add back platform parameters --- .circleci/config.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 365d49bbf..34b6134a4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,10 +30,17 @@ commands: jobs: cargo_xtask_lint: - executor: gnu-linux + parameters: + platform: + type: executor + executor: << parameters.platform >> steps: - checkout - - gnu_linux_install_openssl + - when: + condition: + equal: [ *gnu_linux_executor, << parameters.platform >> ] + steps: + - gnu_linux_install_openssl - install_node - rust/install: version: stable @@ -47,4 +54,7 @@ jobs: workflows: lint: jobs: - - cargo_xtask_lint + - cargo_xtask_lint: + matrix: + parameters: + platform: [gnu_linux] \ No newline at end of file From 5037caf6b6bd8069b41f4de9da09db783e3b442b Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Wed, 1 Sep 2021 13:19:59 -0500 Subject: [PATCH 04/46] wip(ci): xtask test on circle --- .circleci/config.yml | 79 ++++++++++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 24 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 34b6134a4..887b2e88a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,19 +1,30 @@ version: 2.1 -# These "CircleCI Orbs" are reusable bits of configuration that can be shared -# across projects. See https://circleci.com/orbs/ for more information. -orbs: - # Rust steps which are used below (like `rust/install`, `rust/test`) are - # defined in this orb. For reference, the orb can be found here: - # https://github.com/CircleCI-Public/rust-orb - rust: circleci/rust@1.5.0 - gh: circleci/github-cli@1.0.4 - node: circleci/node@4.7.0 +# The main workflows executed for Rover +workflows: + lint: + jobs: + - xtask: + matrix: + parameters: + platform: [ubuntu] + rust_version: [stable] + command: [lint] + test: + jobs: + - xtask: + matrix: + parameters: + platform: [ubuntu] + rust_version: [stable, nightly] + command: [test] executors: - gnu_linux: &gnu_linux_executor + ubuntu: &ubuntu_executor docker: - image: cimg/base:stable + environment: + XTASK_TARGET: "x86_64-unknown-linux-gnu" # reusable command snippets can be referred to in any `steps` object commands: @@ -22,39 +33,59 @@ commands: - node/install: node-version: "16" npm-version: "7" - gnu_linux_install_openssl: + ubuntu_install_openssl: steps: - run: name: Install OpenSSL command: sudo apt-get update && sudo apt-get install -y libssl-dev jobs: - cargo_xtask_lint: + xtask: parameters: + rust_version: + type: enum + enum: ["stable", "nightly"] + default: stable platform: type: executor + command: + type: enum + enum: ["lint", "test"] executor: << parameters.platform >> steps: - checkout - when: condition: - equal: [ *gnu_linux_executor, << parameters.platform >> ] + equal: [ *ubuntu_executor, << parameters.platform >> ] steps: - - gnu_linux_install_openssl + - ubuntu_install_openssl - install_node - rust/install: - version: stable + version: << parameters.rust_version >> - restore_cache: keys: - rust-target-v1-<< parameters.platform >>-{{ checksum "Cargo.lock" }} + - when: + condition: + equal: [ lint, << parameters.command >> ] + steps: + - run: + command: cargo xtask << parameters.command >> --verbose + - when: + condition: + not: + equal: [ lint, << parameters.command >> ] + steps: + - run: + command: cargo xtask << parameters.command >> --target $XTASK_TARGET --verbose - run: - name: Lint - command: cargo xtask lint + command: cargo xtask << parameters.command >> --verbose + - save_cache: + key: rust-target-v1-<< parameters.platform >>-{{ checksum "Cargo.lock" }} + paths: + - target/ -workflows: - lint: - jobs: - - cargo_xtask_lint: - matrix: - parameters: - platform: [gnu_linux] \ No newline at end of file +orbs: + rust: circleci/rust@1.5.0 + gh: circleci/github-cli@1.0.4 + node: circleci/node@4.7.0 \ No newline at end of file From ede08c7c57ed98c0975daa2ac3ad0417716b0f64 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Wed, 1 Sep 2021 13:49:52 -0500 Subject: [PATCH 05/46] wip(ci): override tmp dir location --- .circleci/config.yml | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 887b2e88a..dfd99c2a9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ workflows: - xtask: matrix: parameters: - platform: [ubuntu] + platform: [ubuntu_gnu] rust_version: [stable] command: [lint] test: @@ -15,16 +15,22 @@ workflows: - xtask: matrix: parameters: - platform: [ubuntu] + platform: [ubuntu_gnu, ubuntu_musl] rust_version: [stable, nightly] command: [test] executors: - ubuntu: &ubuntu_executor + ubuntu_gnu: &ubuntu_gnu_executor docker: - image: cimg/base:stable environment: XTASK_TARGET: "x86_64-unknown-linux-gnu" + TMPDIR: "/project/tmp" + ubuntu_musl: &ubuntu_musl_executor + docker: + - image: cimg/base:stable + environment: + XTASK_TARGET: "x86_64-unknown-linux-musl" # reusable command snippets can be referred to in any `steps` object commands: @@ -33,11 +39,21 @@ commands: - node/install: node-version: "16" npm-version: "7" - ubuntu_install_openssl: + ubuntu_setup_tmp: + steps: + - run: + name: Create tmp directory + command: mkdir $TMPDIR + ubuntu_gnu_install_deps: steps: - run: name: Install OpenSSL command: sudo apt-get update && sudo apt-get install -y libssl-dev + ubuntu_musl_install_deps: + steps: + - run: + name: Install musl-tools + command: sudo apt update && sudo apt install musl-tools jobs: xtask: @@ -56,9 +72,15 @@ jobs: - checkout - when: condition: - equal: [ *ubuntu_executor, << parameters.platform >> ] + equal: [ *ubuntu_gnu_executor, << parameters.platform >> ] + steps: + - ubuntu_gnu_install_deps + - ubuntu_setup_tmp + - when: + condition: + equal: [ *ubuntu_musl_executor, << parameters.platform >> ] steps: - - ubuntu_install_openssl + - ubuntu_musl_install_deps - install_node - rust/install: version: << parameters.rust_version >> From fa56ec6fd27c57489fe763f5d7ff8e83b049dcb2 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Wed, 1 Sep 2021 14:14:24 -0500 Subject: [PATCH 06/46] wip(ci): place tmp dir in home directory --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index dfd99c2a9..a38db221a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,7 +25,7 @@ executors: - image: cimg/base:stable environment: XTASK_TARGET: "x86_64-unknown-linux-gnu" - TMPDIR: "/project/tmp" + TMPDIR: "$HOME/test_tmp" ubuntu_musl: &ubuntu_musl_executor docker: - image: cimg/base:stable From f8c78d03594fb6ad5278bd629b787bb983f375fa Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Wed, 1 Sep 2021 14:18:53 -0500 Subject: [PATCH 07/46] wip(ci): really place tmp dir in home directory --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a38db221a..bf92df70d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,7 +25,7 @@ executors: - image: cimg/base:stable environment: XTASK_TARGET: "x86_64-unknown-linux-gnu" - TMPDIR: "$HOME/test_tmp" + TMPDIR: "/home/circleci/test_tmp" ubuntu_musl: &ubuntu_musl_executor docker: - image: cimg/base:stable @@ -53,7 +53,7 @@ commands: steps: - run: name: Install musl-tools - command: sudo apt update && sudo apt install musl-tools + command: sudo apt-get update && sudo apt-get install -y musl-tools jobs: xtask: From a8b36e3c75ec5821eac52802e8b69a2e0aadeaa9 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Wed, 1 Sep 2021 14:59:31 -0500 Subject: [PATCH 08/46] wip(ci): don't use temp directories in CI --- .circleci/config.yml | 38 ++++++++++++--------- xtask/src/commands/test.rs | 2 +- xtask/src/tools/cargo.rs | 2 +- xtask/src/tools/git.rs | 69 ++++++++++++++++++++++++++++---------- 4 files changed, 75 insertions(+), 36 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bf92df70d..fe47cc981 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,15 +8,15 @@ workflows: matrix: parameters: platform: [ubuntu_gnu] - rust_version: [stable] + rust_channel: [stable] command: [lint] test: jobs: - xtask: matrix: parameters: - platform: [ubuntu_gnu, ubuntu_musl] - rust_version: [stable, nightly] + platform: [ubuntu_gnu, ubuntu_musl, macos] + rust_channel: [stable, nightly] command: [test] executors: @@ -25,12 +25,16 @@ executors: - image: cimg/base:stable environment: XTASK_TARGET: "x86_64-unknown-linux-gnu" - TMPDIR: "/home/circleci/test_tmp" ubuntu_musl: &ubuntu_musl_executor docker: - image: cimg/base:stable environment: XTASK_TARGET: "x86_64-unknown-linux-musl" + macos: &macos_executor + macos: + xcode: "12.5" + environment: + XTASK_TARGET: "x86_64-apple-darwin" # reusable command snippets can be referred to in any `steps` object commands: @@ -39,26 +43,26 @@ commands: - node/install: node-version: "16" npm-version: "7" - ubuntu_setup_tmp: + ubuntu_setup: steps: - run: - name: Create tmp directory - command: mkdir $TMPDIR - ubuntu_gnu_install_deps: + name: Update apt repository + command: sudo apt-get update + ubuntu_install_openssl: steps: - run: name: Install OpenSSL - command: sudo apt-get update && sudo apt-get install -y libssl-dev - ubuntu_musl_install_deps: + command: sudo apt-get install -y libssl-dev + ubuntu_install_musl_tools: steps: - run: name: Install musl-tools - command: sudo apt-get update && sudo apt-get install -y musl-tools + command: sudo apt-get install -y musl-tools jobs: xtask: parameters: - rust_version: + rust_channel: type: enum enum: ["stable", "nightly"] default: stable @@ -74,16 +78,18 @@ jobs: condition: equal: [ *ubuntu_gnu_executor, << parameters.platform >> ] steps: - - ubuntu_gnu_install_deps - - ubuntu_setup_tmp + - ubuntu_setup + - ubuntu_install_openssl - when: condition: equal: [ *ubuntu_musl_executor, << parameters.platform >> ] steps: - - ubuntu_musl_install_deps + - ubuntu_setup + - ubuntu_install_openssl + - ubuntu_install_musl_tools - install_node - rust/install: - version: << parameters.rust_version >> + version: << parameters.rust_channel >> - restore_cache: keys: - rust-target-v1-<< parameters.platform >>-{{ checksum "Cargo.lock" }} diff --git a/xtask/src/commands/test.rs b/xtask/src/commands/test.rs index 81a482d21..757076a88 100644 --- a/xtask/src/commands/test.rs +++ b/xtask/src/commands/test.rs @@ -15,7 +15,7 @@ impl Test { pub fn run(&self, verbose: bool) -> Result<()> { let release = false; let mut cargo_runner = CargoRunner::new(verbose)?; - let git_runner = GitRunner::new(verbose)?; + let git_runner = GitRunner::try_new(verbose)?; cargo_runner.test(&self.target)?; diff --git a/xtask/src/tools/cargo.rs b/xtask/src/tools/cargo.rs index d26efbe3d..abc6d2845 100644 --- a/xtask/src/tools/cargo.rs +++ b/xtask/src/tools/cargo.rs @@ -47,7 +47,7 @@ impl CargoRunner { version: Option<&RoverVersion>, ) -> Result { if let Some(version) = version { - let git_runner = GitRunner::new(self.runner.verbose)?; + let git_runner = GitRunner::try_new(self.runner.verbose)?; let repo_path = git_runner.checkout_rover_version(version.to_string().as_str())?; let versioned_schema_url = format!( "https://github.com/apollographql/rover/releases/download/{0}/rover-{0}-schema.graphql", diff --git a/xtask/src/tools/git.rs b/xtask/src/tools/git.rs index e9279125c..5b2ee8895 100644 --- a/xtask/src/tools/git.rs +++ b/xtask/src/tools/git.rs @@ -1,4 +1,5 @@ use std::convert::TryFrom; +use std::{env, fs}; use crate::tools::Runner; @@ -7,44 +8,76 @@ use assert_fs::TempDir; use camino::Utf8PathBuf; pub(crate) struct GitRunner { - temp_dir_path: Utf8PathBuf, + repo: GitRepo, runner: Runner, +} + +enum GitRepo { + TempDir { + temp_dir_path: Utf8PathBuf, + + // we store _temp_dir here since its Drop implementation deletes the directory + _temp_dir: TempDir, + }, + CiDir { + ci_dir_path: Utf8PathBuf, + }, +} + +impl GitRepo { + fn try_new() -> Result { + Ok(if env::var_os("CI").is_some() { + let ci_dir_path = Utf8PathBuf::try_from(env::current_dir()?)?.join("test_tmp"); + fs::create_dir_all(&ci_dir_path)?; + GitRepo::CiDir { ci_dir_path } + } else { + let temp_dir = TempDir::new().with_context(|| "Could not create temp directory")?; + let temp_dir_path = Utf8PathBuf::try_from(temp_dir.path().to_path_buf()) + .with_context(|| "Temp directory was not valid Utf-8")?; + GitRepo::TempDir { + temp_dir_path, + _temp_dir: temp_dir, + } + }) + } - // we store _temp_dir here since its Drop implementation deletes the directory - _temp_dir: TempDir, + fn get_path(&self) -> &Utf8PathBuf { + match self { + GitRepo::TempDir { + temp_dir_path, + _temp_dir: _, + } => temp_dir_path, + GitRepo::CiDir { ci_dir_path } => ci_dir_path, + } + } } impl GitRunner { - pub(crate) fn new(verbose: bool) -> Result { + pub(crate) fn try_new(verbose: bool) -> Result { let runner = Runner::new("git", verbose)?; - let temp_dir = TempDir::new().with_context(|| "Could not create temp directory")?; - let temp_dir_path = Utf8PathBuf::try_from(temp_dir.path().to_path_buf()) - .with_context(|| "Temp directory was not valid Utf-8")?; - - Ok(GitRunner { - runner, - temp_dir_path, - _temp_dir: temp_dir, - }) + + let repo = GitRepo::try_new()?; + + Ok(GitRunner { runner, repo }) } pub(crate) fn clone_supergraph_demo(&self) -> Result { let repo_name = "supergraph-demo"; let repo_url = format!("https://github.com/apollographql/{}", repo_name); self.runner - .exec(&["clone", &repo_url], &self.temp_dir_path, None)?; + .exec(&["clone", &repo_url], self.repo.get_path(), None)?; - let repo_path = self.temp_dir_path.join(repo_name); + let repo_path = self.repo.get_path().join(repo_name); Ok(repo_path) } pub(crate) fn checkout_rover_version(&self, rover_version: &str) -> Result { let repo_name = "rover"; let repo_url = format!("https://github.com/apollographql/{}", repo_name); - self.runner - .exec(&["clone", &repo_url], &self.temp_dir_path, None)?; + let repo_path = self.repo.get_path(); + self.runner.exec(&["clone", &repo_url], repo_path, None)?; - let repo_path = self.temp_dir_path.join(repo_name); + let repo_path = repo_path.join(repo_name); self.runner.exec( &["checkout", &format!("tags/{}", rover_version)], From f5375bd5826e6926fd11ea19a9838ab5f06ee44e Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Wed, 1 Sep 2021 15:34:36 -0500 Subject: [PATCH 09/46] Revert "wip(ci): don't use temp directories in CI" This reverts commit 753112117cbc2bfb020fce676a6b937da9960b7b. --- .circleci/config.yml | 38 +++++++++------------ xtask/src/commands/test.rs | 2 +- xtask/src/tools/cargo.rs | 2 +- xtask/src/tools/git.rs | 69 ++++++++++---------------------------- 4 files changed, 36 insertions(+), 75 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fe47cc981..bf92df70d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,15 +8,15 @@ workflows: matrix: parameters: platform: [ubuntu_gnu] - rust_channel: [stable] + rust_version: [stable] command: [lint] test: jobs: - xtask: matrix: parameters: - platform: [ubuntu_gnu, ubuntu_musl, macos] - rust_channel: [stable, nightly] + platform: [ubuntu_gnu, ubuntu_musl] + rust_version: [stable, nightly] command: [test] executors: @@ -25,16 +25,12 @@ executors: - image: cimg/base:stable environment: XTASK_TARGET: "x86_64-unknown-linux-gnu" + TMPDIR: "/home/circleci/test_tmp" ubuntu_musl: &ubuntu_musl_executor docker: - image: cimg/base:stable environment: XTASK_TARGET: "x86_64-unknown-linux-musl" - macos: &macos_executor - macos: - xcode: "12.5" - environment: - XTASK_TARGET: "x86_64-apple-darwin" # reusable command snippets can be referred to in any `steps` object commands: @@ -43,26 +39,26 @@ commands: - node/install: node-version: "16" npm-version: "7" - ubuntu_setup: + ubuntu_setup_tmp: steps: - run: - name: Update apt repository - command: sudo apt-get update - ubuntu_install_openssl: + name: Create tmp directory + command: mkdir $TMPDIR + ubuntu_gnu_install_deps: steps: - run: name: Install OpenSSL - command: sudo apt-get install -y libssl-dev - ubuntu_install_musl_tools: + command: sudo apt-get update && sudo apt-get install -y libssl-dev + ubuntu_musl_install_deps: steps: - run: name: Install musl-tools - command: sudo apt-get install -y musl-tools + command: sudo apt-get update && sudo apt-get install -y musl-tools jobs: xtask: parameters: - rust_channel: + rust_version: type: enum enum: ["stable", "nightly"] default: stable @@ -78,18 +74,16 @@ jobs: condition: equal: [ *ubuntu_gnu_executor, << parameters.platform >> ] steps: - - ubuntu_setup - - ubuntu_install_openssl + - ubuntu_gnu_install_deps + - ubuntu_setup_tmp - when: condition: equal: [ *ubuntu_musl_executor, << parameters.platform >> ] steps: - - ubuntu_setup - - ubuntu_install_openssl - - ubuntu_install_musl_tools + - ubuntu_musl_install_deps - install_node - rust/install: - version: << parameters.rust_channel >> + version: << parameters.rust_version >> - restore_cache: keys: - rust-target-v1-<< parameters.platform >>-{{ checksum "Cargo.lock" }} diff --git a/xtask/src/commands/test.rs b/xtask/src/commands/test.rs index 757076a88..81a482d21 100644 --- a/xtask/src/commands/test.rs +++ b/xtask/src/commands/test.rs @@ -15,7 +15,7 @@ impl Test { pub fn run(&self, verbose: bool) -> Result<()> { let release = false; let mut cargo_runner = CargoRunner::new(verbose)?; - let git_runner = GitRunner::try_new(verbose)?; + let git_runner = GitRunner::new(verbose)?; cargo_runner.test(&self.target)?; diff --git a/xtask/src/tools/cargo.rs b/xtask/src/tools/cargo.rs index abc6d2845..d26efbe3d 100644 --- a/xtask/src/tools/cargo.rs +++ b/xtask/src/tools/cargo.rs @@ -47,7 +47,7 @@ impl CargoRunner { version: Option<&RoverVersion>, ) -> Result { if let Some(version) = version { - let git_runner = GitRunner::try_new(self.runner.verbose)?; + let git_runner = GitRunner::new(self.runner.verbose)?; let repo_path = git_runner.checkout_rover_version(version.to_string().as_str())?; let versioned_schema_url = format!( "https://github.com/apollographql/rover/releases/download/{0}/rover-{0}-schema.graphql", diff --git a/xtask/src/tools/git.rs b/xtask/src/tools/git.rs index 5b2ee8895..e9279125c 100644 --- a/xtask/src/tools/git.rs +++ b/xtask/src/tools/git.rs @@ -1,5 +1,4 @@ use std::convert::TryFrom; -use std::{env, fs}; use crate::tools::Runner; @@ -8,76 +7,44 @@ use assert_fs::TempDir; use camino::Utf8PathBuf; pub(crate) struct GitRunner { - repo: GitRepo, + temp_dir_path: Utf8PathBuf, runner: Runner, -} - -enum GitRepo { - TempDir { - temp_dir_path: Utf8PathBuf, - - // we store _temp_dir here since its Drop implementation deletes the directory - _temp_dir: TempDir, - }, - CiDir { - ci_dir_path: Utf8PathBuf, - }, -} - -impl GitRepo { - fn try_new() -> Result { - Ok(if env::var_os("CI").is_some() { - let ci_dir_path = Utf8PathBuf::try_from(env::current_dir()?)?.join("test_tmp"); - fs::create_dir_all(&ci_dir_path)?; - GitRepo::CiDir { ci_dir_path } - } else { - let temp_dir = TempDir::new().with_context(|| "Could not create temp directory")?; - let temp_dir_path = Utf8PathBuf::try_from(temp_dir.path().to_path_buf()) - .with_context(|| "Temp directory was not valid Utf-8")?; - GitRepo::TempDir { - temp_dir_path, - _temp_dir: temp_dir, - } - }) - } - fn get_path(&self) -> &Utf8PathBuf { - match self { - GitRepo::TempDir { - temp_dir_path, - _temp_dir: _, - } => temp_dir_path, - GitRepo::CiDir { ci_dir_path } => ci_dir_path, - } - } + // we store _temp_dir here since its Drop implementation deletes the directory + _temp_dir: TempDir, } impl GitRunner { - pub(crate) fn try_new(verbose: bool) -> Result { + pub(crate) fn new(verbose: bool) -> Result { let runner = Runner::new("git", verbose)?; - - let repo = GitRepo::try_new()?; - - Ok(GitRunner { runner, repo }) + let temp_dir = TempDir::new().with_context(|| "Could not create temp directory")?; + let temp_dir_path = Utf8PathBuf::try_from(temp_dir.path().to_path_buf()) + .with_context(|| "Temp directory was not valid Utf-8")?; + + Ok(GitRunner { + runner, + temp_dir_path, + _temp_dir: temp_dir, + }) } pub(crate) fn clone_supergraph_demo(&self) -> Result { let repo_name = "supergraph-demo"; let repo_url = format!("https://github.com/apollographql/{}", repo_name); self.runner - .exec(&["clone", &repo_url], self.repo.get_path(), None)?; + .exec(&["clone", &repo_url], &self.temp_dir_path, None)?; - let repo_path = self.repo.get_path().join(repo_name); + let repo_path = self.temp_dir_path.join(repo_name); Ok(repo_path) } pub(crate) fn checkout_rover_version(&self, rover_version: &str) -> Result { let repo_name = "rover"; let repo_url = format!("https://github.com/apollographql/{}", repo_name); - let repo_path = self.repo.get_path(); - self.runner.exec(&["clone", &repo_url], repo_path, None)?; + self.runner + .exec(&["clone", &repo_url], &self.temp_dir_path, None)?; - let repo_path = repo_path.join(repo_name); + let repo_path = self.temp_dir_path.join(repo_name); self.runner.exec( &["checkout", &format!("tags/{}", rover_version)], From a2dd6db96effbe1de6b807d20f93f58b4ee5626a Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Wed, 1 Sep 2021 15:37:11 -0500 Subject: [PATCH 10/46] wip(ci): setup docker for ubuntu tests --- .circleci/config.yml | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bf92df70d..371f1303f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,7 +16,7 @@ workflows: matrix: parameters: platform: [ubuntu_gnu, ubuntu_musl] - rust_version: [stable, nightly] + rust_version: [stable] command: [test] executors: @@ -25,7 +25,6 @@ executors: - image: cimg/base:stable environment: XTASK_TARGET: "x86_64-unknown-linux-gnu" - TMPDIR: "/home/circleci/test_tmp" ubuntu_musl: &ubuntu_musl_executor docker: - image: cimg/base:stable @@ -39,21 +38,21 @@ commands: - node/install: node-version: "16" npm-version: "7" - ubuntu_setup_tmp: + ubuntu_setup: steps: - run: - name: Create tmp directory - command: mkdir $TMPDIR - ubuntu_gnu_install_deps: + name: Update apt repositories + command: sudo apt-get update + ubuntu_install_openssl: steps: - run: name: Install OpenSSL - command: sudo apt-get update && sudo apt-get install -y libssl-dev - ubuntu_musl_install_deps: + command: sudo apt-get install -y libssl-dev + ubuntu_install_musl_tools: steps: - run: name: Install musl-tools - command: sudo apt-get update && sudo apt-get install -y musl-tools + command: sudo apt-get install -y musl-tools jobs: xtask: @@ -74,13 +73,16 @@ jobs: condition: equal: [ *ubuntu_gnu_executor, << parameters.platform >> ] steps: - - ubuntu_gnu_install_deps - - ubuntu_setup_tmp + - ubuntu_setup + - ubuntu_install_openssl + - setup_remote_docker - when: condition: equal: [ *ubuntu_musl_executor, << parameters.platform >> ] steps: - - ubuntu_musl_install_deps + - ubuntu_setup + - ubuntu_install_openssl + - ubuntu_install_musl_tools - install_node - rust/install: version: << parameters.rust_version >> From 96a09ed90a314a1033107085e49b0bf1b0c33f6d Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Wed, 1 Sep 2021 17:30:51 -0500 Subject: [PATCH 11/46] wip(ci): separate integration from unit tests --- .circleci/config.yml | 96 ++++++++++++++++---------- xtask/src/commands/integration_test.rs | 37 ++++++++++ xtask/src/commands/mod.rs | 4 ++ xtask/src/commands/test.rs | 25 +++---- xtask/src/commands/unit_test.rs | 20 ++++++ xtask/src/main.rs | 14 +++- xtask/src/target.rs | 8 +-- 7 files changed, 143 insertions(+), 61 deletions(-) create mode 100644 xtask/src/commands/integration_test.rs create mode 100644 xtask/src/commands/unit_test.rs diff --git a/.circleci/config.yml b/.circleci/config.yml index 371f1303f..c68c4a07c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,53 +7,46 @@ workflows: - xtask: matrix: parameters: - platform: [ubuntu_gnu] + platform: [ubuntu_gnu_docker] rust_version: [stable] command: [lint] - test: + unit_test: jobs: - xtask: + name: unit_test_<< matrix.platform >>_<< matrix.rust_version >> matrix: parameters: - platform: [ubuntu_gnu, ubuntu_musl] + platform: [ubuntu_gnu_docker, ubuntu_musl] rust_version: [stable] - command: [test] - + command: [unit-test] + integration_test: + jobs: + - xtask: + matrix: + parameters: + platform: [ubuntu_gnu_vm] + rust_version: [stable] + command: [integration-test] + requires: + - unit_test_ubuntu_gnu_docker_<< matrix.rust_version >> + executors: - ubuntu_gnu: &ubuntu_gnu_executor + ubuntu_gnu_docker: &ubuntu_gnu_docker_executor docker: - image: cimg/base:stable environment: XTASK_TARGET: "x86_64-unknown-linux-gnu" + ubuntu_gnu_vm: &ubuntu_gnu_vm_executor + machine: + image: ubuntu-1604:202104-01 + environment: + XTASK_TARGET: "x86_64-unknown-linux-gnu" ubuntu_musl: &ubuntu_musl_executor docker: - image: cimg/base:stable environment: XTASK_TARGET: "x86_64-unknown-linux-musl" -# reusable command snippets can be referred to in any `steps` object -commands: - install_node: - steps: - - node/install: - node-version: "16" - npm-version: "7" - ubuntu_setup: - steps: - - run: - name: Update apt repositories - command: sudo apt-get update - ubuntu_install_openssl: - steps: - - run: - name: Install OpenSSL - command: sudo apt-get install -y libssl-dev - ubuntu_install_musl_tools: - steps: - - run: - name: Install musl-tools - command: sudo apt-get install -y musl-tools - jobs: xtask: parameters: @@ -65,23 +58,29 @@ jobs: type: executor command: type: enum - enum: ["lint", "test"] + enum: ["lint", "test", "test-e2e"] executor: << parameters.platform >> steps: - checkout - when: condition: - equal: [ *ubuntu_gnu_executor, << parameters.platform >> ] + or: + - equal: [ *ubuntu_gnu_docker_executor, << parameters.platform >> ] + - equal: [ *ubuntu_gnu_vm_executor, << parameters.platform >> ] + - equal: [ *ubuntu_musl_executor, << parameters.platform >> ] steps: - - ubuntu_setup + - ubuntu_update_apt - ubuntu_install_openssl - - setup_remote_docker + # - when: + # condition: + # or: + # - equal: [ *ubuntu_gnu_vm_executor, << parameters.platform >>] + # steps: + # - setup_remote_docker - when: condition: equal: [ *ubuntu_musl_executor, << parameters.platform >> ] steps: - - ubuntu_setup - - ubuntu_install_openssl - ubuntu_install_musl_tools - install_node - rust/install: @@ -102,8 +101,6 @@ jobs: steps: - run: command: cargo xtask << parameters.command >> --target $XTASK_TARGET --verbose - - run: - command: cargo xtask << parameters.command >> --verbose - save_cache: key: rust-target-v1-<< parameters.platform >>-{{ checksum "Cargo.lock" }} paths: @@ -112,4 +109,27 @@ jobs: orbs: rust: circleci/rust@1.5.0 gh: circleci/github-cli@1.0.4 - node: circleci/node@4.7.0 \ No newline at end of file + node: circleci/node@4.7.0 + +# reusable command snippets can be referred to in any `steps` object +commands: + install_node: + steps: + - node/install: + node-version: "16" + npm-version: "7" + ubuntu_update_apt: + steps: + - run: + name: Update apt repositories + command: sudo apt-get update + ubuntu_install_openssl: + steps: + - run: + name: Install OpenSSL + command: sudo apt-get install -y libssl-dev + ubuntu_install_musl_tools: + steps: + - run: + name: Install musl-tools + command: sudo apt-get install -y musl-tools \ No newline at end of file diff --git a/xtask/src/commands/integration_test.rs b/xtask/src/commands/integration_test.rs new file mode 100644 index 000000000..6a26e5c40 --- /dev/null +++ b/xtask/src/commands/integration_test.rs @@ -0,0 +1,37 @@ +use anyhow::Result; +use structopt::StructOpt; + +use crate::target::{Target, TARGET_GNU_LINUX}; +use crate::tools::{CargoRunner, GitRunner, MakeRunner}; +use crate::utils; + +#[derive(Debug, StructOpt)] +pub struct IntegrationTest { + // The target to build Rover for + #[structopt(long = "target", default_value, possible_values = &[TARGET_GNU_LINUX])] + pub(crate) target: Target, +} + +impl IntegrationTest { + pub fn run(&self, verbose: bool) -> Result<()> { + let release = false; + let mut cargo_runner = CargoRunner::new(verbose)?; + let git_runner = GitRunner::new(verbose)?; + + if let Target::GnuLinux = self.target { + let make_runner = + MakeRunner::new(verbose, cargo_runner.get_bin_path(&self.target, release)?)?; + cargo_runner.build(&self.target, release, None)?; + + let repo_path = git_runner.clone_supergraph_demo()?; + make_runner.test_supergraph_demo(&repo_path)?; + } else { + utils::info(&format!( + "skipping integration tests for --target {}", + &self.target + )); + } + + Ok(()) + } +} diff --git a/xtask/src/commands/mod.rs b/xtask/src/commands/mod.rs index 0d3d5e799..773dafb54 100644 --- a/xtask/src/commands/mod.rs +++ b/xtask/src/commands/mod.rs @@ -1,10 +1,14 @@ pub(crate) mod dist; +pub(crate) mod integration_test; pub(crate) mod lint; pub(crate) mod prep; pub(crate) mod test; +pub(crate) mod unit_test; pub(crate) mod version; pub(crate) use dist::Dist; +pub(crate) use integration_test::IntegrationTest; pub(crate) use lint::Lint; pub(crate) use prep::Prep; pub(crate) use test::Test; +pub(crate) use unit_test::UnitTest; diff --git a/xtask/src/commands/test.rs b/xtask/src/commands/test.rs index 81a482d21..815629d5f 100644 --- a/xtask/src/commands/test.rs +++ b/xtask/src/commands/test.rs @@ -1,8 +1,8 @@ use anyhow::Result; use structopt::StructOpt; +use crate::commands::{IntegrationTest, UnitTest}; use crate::target::{Target, POSSIBLE_TARGETS}; -use crate::tools::{CargoRunner, GitRunner, MakeRunner}; #[derive(Debug, StructOpt)] pub struct Test { @@ -13,21 +13,14 @@ pub struct Test { impl Test { pub fn run(&self, verbose: bool) -> Result<()> { - let release = false; - let mut cargo_runner = CargoRunner::new(verbose)?; - let git_runner = GitRunner::new(verbose)?; - - cargo_runner.test(&self.target)?; - - if let Target::GnuLinux = self.target { - let make_runner = - MakeRunner::new(verbose, cargo_runner.get_bin_path(&self.target, release)?)?; - cargo_runner.build(&self.target, release, None)?; - - let repo_path = git_runner.clone_supergraph_demo()?; - make_runner.test_supergraph_demo(&repo_path)?; - } - + let unit_test_runner = UnitTest { + target: self.target.clone(), + }; + unit_test_runner.run(verbose)?; + let integration_test_runner = IntegrationTest { + target: self.target.clone(), + }; + integration_test_runner.run(verbose)?; Ok(()) } } diff --git a/xtask/src/commands/unit_test.rs b/xtask/src/commands/unit_test.rs new file mode 100644 index 000000000..de75979c8 --- /dev/null +++ b/xtask/src/commands/unit_test.rs @@ -0,0 +1,20 @@ +use anyhow::Result; +use structopt::StructOpt; + +use crate::target::{Target, POSSIBLE_TARGETS}; +use crate::tools::CargoRunner; + +#[derive(Debug, StructOpt)] +pub struct UnitTest { + // The target to build Rover for + #[structopt(long = "target", default_value, possible_values = &POSSIBLE_TARGETS)] + pub(crate) target: Target, +} + +impl UnitTest { + pub fn run(&self, verbose: bool) -> Result<()> { + let mut cargo_runner = CargoRunner::new(verbose)?; + cargo_runner.test(&self.target)?; + Ok(()) + } +} diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 4a44e2384..3eae60846 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -35,11 +35,17 @@ pub enum Command { /// Run linters for Rover Lint(commands::Lint), - /// Run tests for Rover - Test(commands::Test), - /// Prepare Rover for a release Prep(commands::Prep), + + /// Run all available tests for Rover + Test(commands::Test), + + /// Run only unit tests for Rover + UnitTest(commands::UnitTest), + + /// Run supergraph-demo with a local Rover build + IntegrationTest(commands::IntegrationTest), } impl Xtask { @@ -47,6 +53,8 @@ impl Xtask { match &self.command { Command::Dist(command) => command.run(self.verbose), Command::Lint(command) => command.run(self.verbose), + Command::UnitTest(command) => command.run(self.verbose), + Command::IntegrationTest(command) => command.run(self.verbose), Command::Test(command) => command.run(self.verbose), Command::Prep(command) => command.run(self.verbose), }?; diff --git a/xtask/src/target.rs b/xtask/src/target.rs index ca7320df5..df3eb8c63 100644 --- a/xtask/src/target.rs +++ b/xtask/src/target.rs @@ -5,10 +5,10 @@ use std::{collections::HashMap, fmt, str::FromStr}; use crate::Result; -const TARGET_MUSL_LINUX: &str = "x86_64-unknown-linux-musl"; -const TARGET_GNU_LINUX: &str = "x86_64-unknown-linux-gnu"; -const TARGET_WINDOWS: &str = "x86_64-pc-windows-msvc"; -const TARGET_MACOS: &str = "x86_64-apple-darwin"; +pub(crate) const TARGET_MUSL_LINUX: &str = "x86_64-unknown-linux-musl"; +pub(crate) const TARGET_GNU_LINUX: &str = "x86_64-unknown-linux-gnu"; +pub(crate) const TARGET_WINDOWS: &str = "x86_64-pc-windows-msvc"; +pub(crate) const TARGET_MACOS: &str = "x86_64-apple-darwin"; pub(crate) const POSSIBLE_TARGETS: [&str; 4] = [ TARGET_MUSL_LINUX, From 2acaf4b7222a596e85d0955c3255ca11a8e26829 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Wed, 1 Sep 2021 17:39:25 -0500 Subject: [PATCH 12/46] fixup: ci config issue --- .circleci/config.yml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c68c4a07c..2cb3e7749 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,27 +8,26 @@ workflows: matrix: parameters: platform: [ubuntu_gnu_docker] - rust_version: [stable] + rust_channel: [stable] command: [lint] - unit_test: + test: jobs: - xtask: - name: unit_test_<< matrix.platform >>_<< matrix.rust_version >> + name: unit_test_<< matrix.platform >>_<< matrix.rust_channel >> matrix: parameters: platform: [ubuntu_gnu_docker, ubuntu_musl] - rust_version: [stable] + rust_channel: [stable] command: [unit-test] - integration_test: - jobs: - xtask: + name: integration_test_<< matrix.platform >>_<< matrix.rust_channel >> matrix: parameters: platform: [ubuntu_gnu_vm] - rust_version: [stable] + rust_channel: [stable] command: [integration-test] requires: - - unit_test_ubuntu_gnu_docker_<< matrix.rust_version >> + - unit_test_ubuntu_gnu_docker_<< matrix.rust_channel >> executors: ubuntu_gnu_docker: &ubuntu_gnu_docker_executor @@ -50,7 +49,7 @@ executors: jobs: xtask: parameters: - rust_version: + rust_channel: type: enum enum: ["stable", "nightly"] default: stable @@ -58,7 +57,7 @@ jobs: type: executor command: type: enum - enum: ["lint", "test", "test-e2e"] + enum: ["lint", "unit-test", "integration-test"] executor: << parameters.platform >> steps: - checkout @@ -84,7 +83,7 @@ jobs: - ubuntu_install_musl_tools - install_node - rust/install: - version: << parameters.rust_version >> + version: << parameters.rust_channel >> - restore_cache: keys: - rust-target-v1-<< parameters.platform >>-{{ checksum "Cargo.lock" }} From ed07746063a434eb928c9d3904e761a249e30fb9 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Wed, 1 Sep 2021 17:43:53 -0500 Subject: [PATCH 13/46] wip(ci): install proper rust toolchain --- .circleci/config.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2cb3e7749..37338a146 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -82,8 +82,8 @@ jobs: steps: - ubuntu_install_musl_tools - install_node - - rust/install: - version: << parameters.rust_channel >> + - install_rust_toolchain: + rust_channel: << parameters.rust_channel >> - restore_cache: keys: - rust-target-v1-<< parameters.platform >>-{{ checksum "Cargo.lock" }} @@ -117,6 +117,15 @@ commands: - node/install: node-version: "16" npm-version: "7" + install_rust_toolchain: + parameters: + rust_channel: + type: enum + enum: ["stable", "nightly"] + steps: + - run: + name: Install toolchain + command: rustup target add $XTASK_TARGET ubuntu_update_apt: steps: - run: From 60f5001daef2e5fc1e9c117353dbb9beafadf46c Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Wed, 1 Sep 2021 17:58:20 -0500 Subject: [PATCH 14/46] fixup: node installation --- .circleci/config.yml | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 37338a146..4b2497ebc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,5 +1,9 @@ version: 2.1 +environment: + NODE_VERSION: 16.8.0 + NPM_VERSION: 7.21.1 + # The main workflows executed for Rover workflows: lint: @@ -70,18 +74,26 @@ jobs: steps: - ubuntu_update_apt - ubuntu_install_openssl - # - when: - # condition: - # or: - # - equal: [ *ubuntu_gnu_vm_executor, << parameters.platform >>] - # steps: - # - setup_remote_docker - when: condition: equal: [ *ubuntu_musl_executor, << parameters.platform >> ] steps: - ubuntu_install_musl_tools - - install_node + - unless: + condition: + equal: [ *ubuntu_gnu_vm_executor, << parameters.platform >>] + steps: + - install_node + - when: + condition: + equal: [ *ubuntu_gnu_vm_executor, << parameters.platform >>] + steps: + - run: + name: Install specific version of node + command: nvm use $NODE_VERSION + - run: + name: Install specific version of npm + command: npm install -g npm@$NPM_VERSION - install_rust_toolchain: rust_channel: << parameters.rust_channel >> - restore_cache: @@ -115,8 +127,8 @@ commands: install_node: steps: - node/install: - node-version: "16" - npm-version: "7" + node-version: $NODE_VERSION + npm-version: $NPM_VERSION install_rust_toolchain: parameters: rust_channel: From 93774d7c10c462aa392cae22f45bfaf934ae8663 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Wed, 1 Sep 2021 18:03:10 -0500 Subject: [PATCH 15/46] fixup: install specific node version --- .circleci/config.yml | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4b2497ebc..f84616f09 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,9 +1,5 @@ version: 2.1 -environment: - NODE_VERSION: 16.8.0 - NPM_VERSION: 7.21.1 - # The main workflows executed for Rover workflows: lint: @@ -79,21 +75,7 @@ jobs: equal: [ *ubuntu_musl_executor, << parameters.platform >> ] steps: - ubuntu_install_musl_tools - - unless: - condition: - equal: [ *ubuntu_gnu_vm_executor, << parameters.platform >>] - steps: - - install_node - - when: - condition: - equal: [ *ubuntu_gnu_vm_executor, << parameters.platform >>] - steps: - - run: - name: Install specific version of node - command: nvm use $NODE_VERSION - - run: - name: Install specific version of npm - command: npm install -g npm@$NPM_VERSION + - install_node - install_rust_toolchain: rust_channel: << parameters.rust_channel >> - restore_cache: @@ -127,8 +109,8 @@ commands: install_node: steps: - node/install: - node-version: $NODE_VERSION - npm-version: $NPM_VERSION + node-version: 14.17.1 + npm-version: 7.21.1 install_rust_toolchain: parameters: rust_channel: From ce86d915b339e029813c72a440b58b5452002d56 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Wed, 1 Sep 2021 18:04:41 -0500 Subject: [PATCH 16/46] fixup: add back rust installation --- .circleci/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index f84616f09..957b4eb37 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -117,6 +117,8 @@ commands: type: enum enum: ["stable", "nightly"] steps: + - rust/install: + version: << parameters.rust_channel >> - run: name: Install toolchain command: rustup target add $XTASK_TARGET From 5e2774b2d1d2833f1c1ea628a63c3df3d033e044 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 09:57:58 -0500 Subject: [PATCH 17/46] wip(ci): use volta to install node --- .circleci/config.yml | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 957b4eb37..af2aed6c0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -70,12 +70,13 @@ jobs: steps: - ubuntu_update_apt - ubuntu_install_openssl + - ubuntu_install_node - when: condition: equal: [ *ubuntu_musl_executor, << parameters.platform >> ] steps: - ubuntu_install_musl_tools - - install_node + # - install_node - install_rust_toolchain: rust_channel: << parameters.rust_channel >> - restore_cache: @@ -102,15 +103,27 @@ jobs: orbs: rust: circleci/rust@1.5.0 gh: circleci/github-cli@1.0.4 - node: circleci/node@4.7.0 + # node: circleci/node@4.7.0 # reusable command snippets can be referred to in any `steps` object commands: - install_node: + ubuntu_install_node: steps: - - node/install: - node-version: 14.17.1 - npm-version: 7.21.1 + - run: + name: Install volta + command: | + curl https://get.volta.sh | bash + echo 'export VOLTA_HOME=$HOME/.volta' >> $BASH_ENV + echo 'export PATH=$VOLTA_HOME:$PATH' >> $BASH_ENV + - run: + name: Install specific version of node + command: volta install node@14.17.1 + - run: + name: Install specific version of npm + command: volta install npm@7.21.1 + # - node/install: + # node-version: 14.17.1 + # npm-version: 7.21.1 install_rust_toolchain: parameters: rust_channel: From 1759e679e3ebe20f2676c08e8df45888f2e3f1fd Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 10:04:58 -0500 Subject: [PATCH 18/46] wip(ci): dont use bash env for volta --- .circleci/config.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index af2aed6c0..ee72c6cf5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -113,8 +113,6 @@ commands: name: Install volta command: | curl https://get.volta.sh | bash - echo 'export VOLTA_HOME=$HOME/.volta' >> $BASH_ENV - echo 'export PATH=$VOLTA_HOME:$PATH' >> $BASH_ENV - run: name: Install specific version of node command: volta install node@14.17.1 From 97fc89853e786624eeeb1c0a211475bd950ffa16 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 10:07:10 -0500 Subject: [PATCH 19/46] wip(ci): use exact path to volta bin --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ee72c6cf5..c5b608b6b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -115,10 +115,10 @@ commands: curl https://get.volta.sh | bash - run: name: Install specific version of node - command: volta install node@14.17.1 + command: ~/.volta/bin/volta install node@14.17.1 - run: name: Install specific version of npm - command: volta install npm@7.21.1 + command: ~/.volta/bin/volta install npm@7.21.1 # - node/install: # node-version: 14.17.1 # npm-version: 7.21.1 From fa0b4ce770cdfdb6bc6caeae35b712c681806c0e Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 10:32:23 -0500 Subject: [PATCH 20/46] wip(ci): move platform specific stuff to commands --- .circleci/config.yml | 79 +++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 31 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c5b608b6b..fe642d4b8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -61,22 +61,12 @@ jobs: executor: << parameters.platform >> steps: - checkout - - when: - condition: - or: - - equal: [ *ubuntu_gnu_docker_executor, << parameters.platform >> ] - - equal: [ *ubuntu_gnu_vm_executor, << parameters.platform >> ] - - equal: [ *ubuntu_musl_executor, << parameters.platform >> ] - steps: - - ubuntu_update_apt - - ubuntu_install_openssl - - ubuntu_install_node - - when: - condition: - equal: [ *ubuntu_musl_executor, << parameters.platform >> ] - steps: - - ubuntu_install_musl_tools - # - install_node + - install_system_deps: + platform: << parameters.platform >> + - install_node: + node_version: "14.17.1" + npm_version: "7.21.1" + platform: << parameters.platform >> - install_rust_toolchain: rust_channel: << parameters.rust_channel >> - restore_cache: @@ -103,25 +93,33 @@ jobs: orbs: rust: circleci/rust@1.5.0 gh: circleci/github-cli@1.0.4 - # node: circleci/node@4.7.0 # reusable command snippets can be referred to in any `steps` object commands: - ubuntu_install_node: + install_node: + parameters: + node_version: + type: string + npm_version: + type: string + platform: + type: executor steps: - - run: - name: Install volta - command: | - curl https://get.volta.sh | bash - - run: - name: Install specific version of node - command: ~/.volta/bin/volta install node@14.17.1 - - run: - name: Install specific version of npm - command: ~/.volta/bin/volta install npm@7.21.1 - # - node/install: - # node-version: 14.17.1 - # npm-version: 7.21.1 + - when: + condition: + or: + - equal: [ *ubuntu_gnu_docker_executor, << parameters.platform >> ] + - equal: [ *ubuntu_gnu_vm_executor, << parameters.platform >> ] + steps: + - run: + name: Install volta + command: curl https://get.volta.sh | bash + - run: + name: Install specific version of node + command: ~/.volta/bin/volta install node@${<< parameters.node_version >>} + - run: + name: Install specific version of npm + command: ~/.volta/bin/volta install npm@${<< parameters.npm_version >>} install_rust_toolchain: parameters: rust_channel: @@ -133,6 +131,25 @@ commands: - run: name: Install toolchain command: rustup target add $XTASK_TARGET + install_system_deps: + parameters: + platform: + type: executor + steps: + - when: + condition: + or: + - equal: [ *ubuntu_gnu_docker_executor, << parameters.platform >> ] + - equal: [ *ubuntu_gnu_vm_executor, << parameters.platform >> ] + - equal: [ *ubuntu_musl_executor, << parameters.platform >> ] + steps: + - ubuntu_update_apt + - ubuntu_install_openssl + - when: + condition: + equal: [ *ubuntu_musl_executor, << parameters.platform >> ] + steps: + - ubuntu_install_musl_tools ubuntu_update_apt: steps: - run: From 58220f065f9700d03aeadd9f6571dd274b2f1e87 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 10:42:37 -0500 Subject: [PATCH 21/46] wip(ci): further cleanup --- .circleci/config.yml | 73 ++++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fe642d4b8..4a4c4b7af 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,23 +28,6 @@ workflows: command: [integration-test] requires: - unit_test_ubuntu_gnu_docker_<< matrix.rust_channel >> - -executors: - ubuntu_gnu_docker: &ubuntu_gnu_docker_executor - docker: - - image: cimg/base:stable - environment: - XTASK_TARGET: "x86_64-unknown-linux-gnu" - ubuntu_gnu_vm: &ubuntu_gnu_vm_executor - machine: - image: ubuntu-1604:202104-01 - environment: - XTASK_TARGET: "x86_64-unknown-linux-gnu" - ubuntu_musl: &ubuntu_musl_executor - docker: - - image: cimg/base:stable - environment: - XTASK_TARGET: "x86_64-unknown-linux-musl" jobs: xtask: @@ -72,24 +55,34 @@ jobs: - restore_cache: keys: - rust-target-v1-<< parameters.platform >>-{{ checksum "Cargo.lock" }} - - when: - condition: - equal: [ lint, << parameters.command >> ] - steps: - - run: - command: cargo xtask << parameters.command >> --verbose - - when: - condition: - not: - equal: [ lint, << parameters.command >> ] - steps: - - run: - command: cargo xtask << parameters.command >> --target $XTASK_TARGET --verbose + - exec_xtask: + command: << parameters.command >> - save_cache: key: rust-target-v1-<< parameters.platform >>-{{ checksum "Cargo.lock" }} paths: - target/ +# The machines we use to run our workflows on +executors: + ubuntu_gnu_docker: &ubuntu_gnu_docker_executor + docker: + - image: cimg/base:stable + environment: + XTASK_TARGET: "x86_64-unknown-linux-gnu" + + # This is only used to run supergraph-demo since you can't run Docker from Docker + ubuntu_gnu_vm: &ubuntu_gnu_vm_executor + machine: + image: ubuntu-1604:202104-01 + environment: + XTASK_TARGET: "x86_64-unknown-linux-gnu" + + ubuntu_musl: &ubuntu_musl_executor + docker: + - image: cimg/base:stable + environment: + XTASK_TARGET: "x86_64-unknown-linux-musl" + orbs: rust: circleci/rust@1.5.0 gh: circleci/github-cli@1.0.4 @@ -150,6 +143,26 @@ commands: equal: [ *ubuntu_musl_executor, << parameters.platform >> ] steps: - ubuntu_install_musl_tools + exec_xtask: + parameters: + command: + type: enum + enum: [lint, integration-test, unit-test] + steps: + - when: + condition: + # cargo xtask lint is the only xtask command that doesn't take a target + equal: [ lint, << parameters.command >> ] + steps: + - run: + command: cargo xtask << parameters.command >> --verbose + - when: + condition: + not: + equal: [ lint, << parameters.command >> ] + steps: + - run: + command: cargo xtask << parameters.command >> --target $XTASK_TARGET --verbose ubuntu_update_apt: steps: - run: From 59db4116a7cbfa39498b546d13e15b3ad6407df9 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 10:43:58 -0500 Subject: [PATCH 22/46] wip(ci): dont try $ substitution --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4a4c4b7af..5b9dc88ba 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -109,10 +109,10 @@ commands: command: curl https://get.volta.sh | bash - run: name: Install specific version of node - command: ~/.volta/bin/volta install node@${<< parameters.node_version >>} + command: ~/.volta/bin/volta install node@<< parameters.node_version >> - run: name: Install specific version of npm - command: ~/.volta/bin/volta install npm@${<< parameters.npm_version >>} + command: ~/.volta/bin/volta install npm@<< parameters.npm_version >> install_rust_toolchain: parameters: rust_channel: From 575014be0218a4b579febe1cad96685f81352ae5 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 11:01:24 -0500 Subject: [PATCH 23/46] wip(ci): add back BASH_ENV --- .circleci/config.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5b9dc88ba..da32397cd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -106,13 +106,21 @@ commands: steps: - run: name: Install volta - command: curl https://get.volta.sh | bash + command: | + curl https://get.volta.sh | bash + echo 'export VOLTA_HOME=$HOME/.volta' >> $BASH_ENV + echo 'export PATH=$VOLTA_HOME:$PATH' >> $BASH_ENV - run: name: Install specific version of node - command: ~/.volta/bin/volta install node@<< parameters.node_version >> + command: volta install node@<< parameters.node_version >> - run: name: Install specific version of npm - command: ~/.volta/bin/volta install npm@<< parameters.npm_version >> + command: volta install npm@<< parameters.npm_version >> + - run: + name: Print npm and node versions + command: | + node --version + npm --version install_rust_toolchain: parameters: rust_channel: @@ -122,7 +130,7 @@ commands: - rust/install: version: << parameters.rust_channel >> - run: - name: Install toolchain + name: Install specific rust toolchain command: rustup target add $XTASK_TARGET install_system_deps: parameters: From b6fcc75266d56cd5e340074cc644fc2d81f2c674 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 11:05:41 -0500 Subject: [PATCH 24/46] wip(ci): try sh instead of bash --- .circleci/config.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index da32397cd..4af4de791 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -107,9 +107,10 @@ commands: - run: name: Install volta command: | - curl https://get.volta.sh | bash - echo 'export VOLTA_HOME=$HOME/.volta' >> $BASH_ENV - echo 'export PATH=$VOLTA_HOME:$PATH' >> $BASH_ENV + curl https://get.volta.sh | sh + + # echo 'export VOLTA_HOME=$HOME/.volta' >> $BASH_ENV + # echo 'export PATH=$VOLTA_HOME:$PATH' >> $BASH_ENV - run: name: Install specific version of node command: volta install node@<< parameters.node_version >> From 75ead03761024b6078994c5fb723f4dc12a94bbe Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 11:10:27 -0500 Subject: [PATCH 25/46] wip(ci): use volta's skip-setup flag --- .circleci/config.yml | 9 +- volta.sh | 459 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 464 insertions(+), 4 deletions(-) create mode 100755 volta.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 4af4de791..dff914a3d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -107,10 +107,11 @@ commands: - run: name: Install volta command: | - curl https://get.volta.sh | sh - - # echo 'export VOLTA_HOME=$HOME/.volta' >> $BASH_ENV - # echo 'export PATH=$VOLTA_HOME:$PATH' >> $BASH_ENV + curl -sSL https://get.volta.sh > ./volta.sh + chmod +x ./volta.sh + ./volta.sh --skip-setup + echo 'export VOLTA_HOME=$HOME/.volta' >> $BASH_ENV + echo 'export PATH=$VOLTA_HOME:$PATH' >> $BASH_ENV - run: name: Install specific version of node command: volta install node@<< parameters.node_version >> diff --git a/volta.sh b/volta.sh new file mode 100755 index 000000000..c9c93c5ad --- /dev/null +++ b/volta.sh @@ -0,0 +1,459 @@ +#!/usr/bin/env bash + +# This is the bootstrap Unix installer served by `https://get.volta.sh`. +# Its responsibility is to query the system to determine what OS (and in the +# case of Linux, what OpenSSL version) the system has, fetch and install the +# appropriate build of Volta, and modify the user's profile. + +# NOTE: to use an internal company repo, change how this determines the latest version +get_latest_release() { + curl --silent "https://volta.sh/latest-version" +} + +release_url() { + echo "https://github.com/volta-cli/volta/releases" +} + +download_release_from_repo() { + local version="$1" + local os_info="$2" + local tmpdir="$3" + + local filename="volta-$version-$os_info.tar.gz" + local download_file="$tmpdir/$filename" + local archive_url="$(release_url)/download/v$version/$filename" + + curl --progress-bar --show-error --location --fail "$archive_url" --output "$download_file" --write-out '%{filename_effective}' +} + +usage() { + cat >&2 < Install a specific release version of Volta +END_USAGE +} + +info() { + local action="$1" + local details="$2" + command printf '\033[1;32m%12s\033[0m %s\n' "$action" "$details" 1>&2 +} + +error() { + command printf '\033[1;31mError\033[0m: %s\n\n' "$1" 1>&2 +} + +warning() { + command printf '\033[1;33mWarning\033[0m: %s\n\n' "$1" 1>&2 +} + +request() { + command printf '\033[1m%s\033[0m\n' "$1" 1>&2 +} + +eprintf() { + command printf '%s\n' "$1" 1>&2 +} + +bold() { + command printf '\033[1m%s\033[0m' "$1" +} + +# check for issue with VOLTA_HOME +# if it is set, and exists, but is not a directory, the install will fail +volta_home_is_ok() { + if [ -n "${VOLTA_HOME-}" ] && [ -e "$VOLTA_HOME" ] && ! [ -d "$VOLTA_HOME" ]; then + error "\$VOLTA_HOME is set but is not a directory ($VOLTA_HOME)." + eprintf "Please check your profile scripts and environment." + return 1 + fi + return 0 +} + +# Check if it is OK to upgrade to the new version +upgrade_is_ok() { + local will_install_version="$1" + local install_dir="$2" + local is_dev_install="$3" + + # check for Volta in both the old location and the new 0.7.0 location + local volta_bin="$install_dir/volta" + if [ ! -x "$volta_bin" ]; then + volta_bin="$install_dir/bin/volta" + fi + + # this is not able to install Volta prior to 0.5.0 (when it was renamed) + if [[ "$will_install_version" =~ ^([0-9]+\.[0-9]+) ]]; then + local major_minor="${BASH_REMATCH[1]}" + case "$major_minor" in + 0.1|0.2|0.3|0.4|0.5) + eprintf "" + error "Cannot install Volta prior to version 0.6.0" + request " To install Volta version $will_install_version, please check out the source and build manually." + eprintf "" + return 1 + ;; + esac + fi + + if [[ -n "$install_dir" && -x "$volta_bin" ]]; then + local prev_version="$( ($volta_bin --version 2>/dev/null || echo 0.1) | sed -E 's/^.*([0-9]+\.[0-9]+\.[0-9]+).*$/\1/')" + # if this is a local dev install, skip the equality check + # if installing the same version, this is a no-op + if [ "$is_dev_install" != "true" ] && [ "$prev_version" == "$will_install_version" ]; then + eprintf "Version $will_install_version already installed" + return 1 + fi + # in the future, check $prev_version for incompatible upgrades + fi + return 0 +} + +# returns the os name to be used in the packaged release, +# including the openssl info if necessary +parse_os_info() { + local uname_str="$1" + local openssl_version="$2" + + case "$uname_str" in + Linux) + parsed_version="$(parse_openssl_version "$openssl_version")" + exit_code="$?" + if [ "$exit_code" != 0 ]; then + return "$exit_code" + fi + + echo "linux-openssl-$parsed_version" + ;; + Darwin) + if [ "$(uname -m)" == "arm64" ]; then + echo "macos-aarch64" + else + echo "macos" + fi + ;; + *) + return 1 + esac + return 0 +} + +parse_os_pretty() { + local uname_str="$1" + + case "$uname_str" in + Linux) + echo "Linux" + ;; + Darwin) + echo "macOS" + ;; + *) + echo "$uname_str" + esac +} + +# return true(0) if the element is contained in the input arguments +# called like: +# if element_in "foo" "${array[@]}"; then ... +element_in() { + local match="$1"; + shift + + local element; + # loop over the input arguments and return when a match is found + for element in "$@"; do + [ "$element" == "$match" ] && return 0 + done + return 1 +} + +# parse the OpenSSL version from the input text +# for most distros, we only care about MAJOR.MINOR, with the exception of RHEL/CENTOS, +parse_openssl_version() { + local version_str="$1" + + # array containing the SSL libraries that are supported + # would be nice to use a bash 4.x associative array, but bash 3.x is the default on OSX + SUPPORTED_SSL_LIBS=( 'OpenSSL' ) + + # use regex to get the library name and version + # typical version string looks like 'OpenSSL 1.0.1e-fips 11 Feb 2013' + if [[ "$version_str" =~ ^([^\ ]*)\ ([0-9]+\.[0-9]+) ]] + then + # check that the lib is supported + libname="${BASH_REMATCH[1]}" + major_minor="${BASH_REMATCH[2]}" + if ! element_in "$libname" "${SUPPORTED_SSL_LIBS[@]}" + then + error "Releases for '$libname' not currently supported. Supported libraries are: ${SUPPORTED_SSL_LIBS[@]}." + return 1 + fi + + # for version 1.0.x, check for RHEL/CentOS style OpenSSL SONAME (.so.10) + if [ "$major_minor" == "1.0" ] && [ -f "/usr/lib64/libcrypto.so.10" ]; then + echo "rhel" + else + echo "$major_minor" + fi + return 0 + else + error "Could not determine OpenSSL version for '$version_str'." + return 1 + fi +} + +create_tree() { + local install_dir="$1" + + info 'Creating' "directory layout" + + # .volta/ + # bin/ + + mkdir -p "$install_dir" && mkdir -p "$install_dir"/bin + if [ "$?" != 0 ] + then + error "Could not create directory layout. Please make sure the target directory is writeable: $install_dir" + exit 1 + fi +} + +install_version() { + local version_to_install="$1" + local install_dir="$2" + local should_run_setup="$3" + + if ! volta_home_is_ok; then + exit 1 + fi + + case "$version_to_install" in + latest) + local latest_version="$(get_latest_release)" + info 'Installing' "latest version of Volta ($latest_version)" + install_release "$latest_version" "$install_dir" + ;; + local-dev) + info 'Installing' "Volta locally after compiling" + install_local "dev" "$install_dir" + ;; + local-release) + info 'Installing' "Volta locally after compiling with '--release'" + install_local "release" "$install_dir" + ;; + *) + # assume anything else is a specific version + info 'Installing' "Volta version $version_to_install" + install_release "$version_to_install" "$install_dir" + ;; + esac + + if [ "$?" == 0 ] + then + if [ "$should_run_setup" == "true" ]; then + info 'Finished' "installation. Updating user profile settings." + "$install_dir"/bin/volta setup + else + "$install_dir"/bin/volta --version &>/dev/null # creates the default shims + info 'Finished' "installation. No changes were made to user profile settings." + fi + fi +} + +# parse the 'version = "X.Y.Z"' line from the input Cargo.toml contents +# and return the version string +parse_cargo_version() { + local contents="$1" + + while read -r line + do + if [[ "$line" =~ ^version\ =\ \"(.*)\" ]] + then + echo "${BASH_REMATCH[1]}" + return 0 + fi + done <<< "$contents" + + error "Could not determine the current version from Cargo.toml" + return 1 +} + +install_release() { + local version="$1" + local install_dir="$2" + local is_dev_install="false" + + info 'Checking' "for existing Volta installation" + if upgrade_is_ok "$version" "$install_dir" "$is_dev_install" + then + download_archive="$(download_release "$version"; exit "$?")" + exit_status="$?" + if [ "$exit_status" != 0 ] + then + error "Could not download Volta version '$version'. See $(release_url) for a list of available releases" + return "$exit_status" + fi + + install_from_file "$download_archive" "$install_dir" + else + # existing legacy install, or upgrade problem + return 1 + fi +} + +install_local() { + local dev_or_release="$1" + local install_dir="$2" + # this is a local install, so skip the version equality check + local is_dev_install="true" + + info 'Checking' "for existing Volta installation" + install_version="$(parse_cargo_version "$(/dev/null 2>&1 && pwd )" + + # call the release script to create the packaged archive file + # '2> >(tee /dev/stderr)' copies stderr to stdout, to collect it and parse the filename + release_output="$( "$DIR/release.sh" "--$dev_or_release" 2> >(tee /dev/stderr) )" + [ "$?" != 0 ] && return 1 + + # parse the release filename and return that + if [[ "$release_output" =~ release\ in\ file\ (target[^\ ]+) ]]; then + echo "${BASH_REMATCH[1]}" + else + error "Could not determine output filename" + return 1 + fi +} + +download_release() { + local version="$1" + + local uname_str="$(uname -s)" + local openssl_version="$(openssl version)" + local os_info + os_info="$(parse_os_info "$uname_str" "$openssl_version")" + if [ "$?" != 0 ]; then + error "The current operating system ($uname_str) does not appear to be supported by Volta." + return 1 + fi + local pretty_os_name="$(parse_os_pretty "$uname_str")" + + info 'Fetching' "archive for $pretty_os_name, version $version" + # store the downloaded archive in a temporary directory + local download_dir="$(mktemp -d)" + download_release_from_repo "$version" "$os_info" "$download_dir" +} + +install_from_file() { + local archive="$1" + local install_dir="$2" + + create_tree "$install_dir" + + info 'Extracting' "Volta binaries and launchers" + # extract the files to the specified directory + tar -xf "$archive" -C "$install_dir"/bin +} + +check_architecture() { + local version="$1" + local arch="$2" + + if [[ "$version" != "local"* ]]; then + case "$arch" in + x86_64) + return 0 + ;; + arm64) + if [ "$(uname -s)" = "Darwin" ]; then + return 0 + fi + ;; + esac + + error "Sorry! Volta currently only provides pre-built binaries for x86_64 architectures." + return 1 + fi +} + + +# return if sourced (for testing the functions above) +return 0 2>/dev/null + +# default to installing the latest available version +version_to_install="latest" + +# default to running setup after installing +should_run_setup="true" + +# install to VOLTA_HOME, defaulting to ~/.volta +install_dir="${VOLTA_HOME:-"$HOME/.volta"}" + +# parse command line options +while [ $# -gt 0 ] +do + arg="$1" + + case "$arg" in + -h|--help) + usage + exit 0 + ;; + --dev) + shift # shift off the argument + version_to_install="local-dev" + ;; + --release) + shift # shift off the argument + version_to_install="local-release" + ;; + --version) + shift # shift off the argument + version_to_install="$1" + shift # shift off the value + ;; + --skip-setup) + shift # shift off the argument + should_run_setup="false" + ;; + *) + error "unknown option: '$arg'" + usage + exit 1 + ;; + esac +done + +check_architecture "$version_to_install" "$(uname -m)" || exit 1 + +install_version "$version_to_install" "$install_dir" "$should_run_setup" From dc06a83d8e8a2457bc299ede9b4eb7f03d99276b Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 11:29:22 -0500 Subject: [PATCH 26/46] wip(ci): just use the base node image --- .circleci/config.yml | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index dff914a3d..884e7720f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -19,6 +19,7 @@ workflows: platform: [ubuntu_gnu_docker, ubuntu_musl] rust_channel: [stable] command: [unit-test] + - xtask: name: integration_test_<< matrix.platform >>_<< matrix.rust_channel >> matrix: @@ -46,8 +47,7 @@ jobs: - checkout - install_system_deps: platform: << parameters.platform >> - - install_node: - node_version: "14.17.1" + - install_npm: npm_version: "7.21.1" platform: << parameters.platform >> - install_rust_toolchain: @@ -66,7 +66,7 @@ jobs: executors: ubuntu_gnu_docker: &ubuntu_gnu_docker_executor docker: - - image: cimg/base:stable + - image: cimg/base:node:14.17.1 environment: XTASK_TARGET: "x86_64-unknown-linux-gnu" @@ -89,10 +89,8 @@ orbs: # reusable command snippets can be referred to in any `steps` object commands: - install_node: + install_npm: parameters: - node_version: - type: string npm_version: type: string platform: @@ -100,29 +98,12 @@ commands: steps: - when: condition: - or: - - equal: [ *ubuntu_gnu_docker_executor, << parameters.platform >> ] - - equal: [ *ubuntu_gnu_vm_executor, << parameters.platform >> ] + equal: [ *ubuntu_gnu_docker_executor, << parameters.platform >> ] steps: - - run: - name: Install volta - command: | - curl -sSL https://get.volta.sh > ./volta.sh - chmod +x ./volta.sh - ./volta.sh --skip-setup - echo 'export VOLTA_HOME=$HOME/.volta' >> $BASH_ENV - echo 'export PATH=$VOLTA_HOME:$PATH' >> $BASH_ENV - - run: - name: Install specific version of node - command: volta install node@<< parameters.node_version >> - run: name: Install specific version of npm - command: volta install npm@<< parameters.npm_version >> - - run: - name: Print npm and node versions - command: | - node --version - npm --version + command: npm i -g npm@<< parameters.npm_version >> + install_rust_toolchain: parameters: rust_channel: @@ -134,6 +115,7 @@ commands: - run: name: Install specific rust toolchain command: rustup target add $XTASK_TARGET + install_system_deps: parameters: platform: @@ -153,6 +135,7 @@ commands: equal: [ *ubuntu_musl_executor, << parameters.platform >> ] steps: - ubuntu_install_musl_tools + exec_xtask: parameters: command: @@ -173,16 +156,19 @@ commands: steps: - run: command: cargo xtask << parameters.command >> --target $XTASK_TARGET --verbose + ubuntu_update_apt: steps: - run: name: Update apt repositories command: sudo apt-get update + ubuntu_install_openssl: steps: - run: name: Install OpenSSL command: sudo apt-get install -y libssl-dev + ubuntu_install_musl_tools: steps: - run: From b9d19ecf60453d57fd08c81b4090252fa530f4ce Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 11:30:01 -0500 Subject: [PATCH 27/46] fixup: use the right image name --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 884e7720f..9cef14e4a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -66,7 +66,7 @@ jobs: executors: ubuntu_gnu_docker: &ubuntu_gnu_docker_executor docker: - - image: cimg/base:node:14.17.1 + - image: cimg/node:14.17.1 environment: XTASK_TARGET: "x86_64-unknown-linux-gnu" From 92093d2264c6c39507b57c2801369742add65a60 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 12:12:46 -0500 Subject: [PATCH 28/46] fixup: back to the orb --- .circleci/config.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9cef14e4a..5ad111fb3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -49,6 +49,7 @@ jobs: platform: << parameters.platform >> - install_npm: npm_version: "7.21.1" + node_version: "14.17.1" platform: << parameters.platform >> - install_rust_toolchain: rust_channel: << parameters.rust_channel >> @@ -66,7 +67,7 @@ jobs: executors: ubuntu_gnu_docker: &ubuntu_gnu_docker_executor docker: - - image: cimg/node:14.17.1 + - image: cimg/base:node environment: XTASK_TARGET: "x86_64-unknown-linux-gnu" @@ -86,6 +87,7 @@ executors: orbs: rust: circleci/rust@1.5.0 gh: circleci/github-cli@1.0.4 + node: circleci/node@4.7.0 # reusable command snippets can be referred to in any `steps` object commands: @@ -93,6 +95,8 @@ commands: parameters: npm_version: type: string + node_version: + type: string platform: type: executor steps: @@ -100,9 +104,9 @@ commands: condition: equal: [ *ubuntu_gnu_docker_executor, << parameters.platform >> ] steps: - - run: - name: Install specific version of npm - command: npm i -g npm@<< parameters.npm_version >> + - node/install: + node-version: << parameters.node_version >> + npm-version: << parameters.npm_version >> install_rust_toolchain: parameters: From 3310638f0cdc9018adf23e4e036cf9556be9af0c Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 12:13:26 -0500 Subject: [PATCH 29/46] fixup: correct image --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5ad111fb3..1c4b71831 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -67,7 +67,7 @@ jobs: executors: ubuntu_gnu_docker: &ubuntu_gnu_docker_executor docker: - - image: cimg/base:node + - image: cimg/base:stable environment: XTASK_TARGET: "x86_64-unknown-linux-gnu" From 5594375d129c26dd49fdc33339ad0ca64d452e25 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 13:34:45 -0500 Subject: [PATCH 30/46] fixup: broken link --- README.md | 2 +- installers/binstall/scripts/nix/install.sh | 2 +- installers/binstall/scripts/windows/install.ps1 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index aa2515841..af4f17212 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,6 @@ See [this page](https://go.apollo.dev/r/contributing) for info about contributin ## License -This project is licensed under the MIT License ([LICENSE] or http://opensource.org/licenses/MIT). +This project is licensed under the MIT License ([LICENSE] or https://opensource.org/licenses/MIT). [LICENSE]: https://github.com/apollographql/rover/blob/main/LICENSE diff --git a/installers/binstall/scripts/nix/install.sh b/installers/binstall/scripts/nix/install.sh index 8d34aad51..b69d0004f 100755 --- a/installers/binstall/scripts/nix/install.sh +++ b/installers/binstall/scripts/nix/install.sh @@ -1,7 +1,7 @@ #!/bin/bash # # Licensed under the MIT license -# , at your +# , at your # option. This file may not be copied, modified, or distributed # except according to those terms. diff --git a/installers/binstall/scripts/windows/install.ps1 b/installers/binstall/scripts/windows/install.ps1 index e93c59688..38868922b 100644 --- a/installers/binstall/scripts/windows/install.ps1 +++ b/installers/binstall/scripts/windows/install.ps1 @@ -1,5 +1,5 @@ # Licensed under the MIT license -# , at your +# , at your # option. This file may not be copied, modified, or distributed # except according to those terms. From 5d87595df633d62a93d1110284f7d7255c59b10a Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 14:10:59 -0500 Subject: [PATCH 31/46] chore(ci): add macos to test matrix --- .circleci/config.yml | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1c4b71831..58578628f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,5 +1,11 @@ version: 2.1 +# Our CircleCI dependencies +orbs: + rust: circleci/rust@1.5.0 + gh: circleci/github-cli@1.0.4 + node: circleci/node@4.7.0 + # The main workflows executed for Rover workflows: lint: @@ -16,7 +22,7 @@ workflows: name: unit_test_<< matrix.platform >>_<< matrix.rust_channel >> matrix: parameters: - platform: [ubuntu_gnu_docker, ubuntu_musl] + platform: [ubuntu_gnu_docker, ubuntu_musl, macos] rust_channel: [stable] command: [unit-test] @@ -47,21 +53,14 @@ jobs: - checkout - install_system_deps: platform: << parameters.platform >> - - install_npm: + - install_node: npm_version: "7.21.1" node_version: "14.17.1" platform: << parameters.platform >> - install_rust_toolchain: rust_channel: << parameters.rust_channel >> - - restore_cache: - keys: - - rust-target-v1-<< parameters.platform >>-{{ checksum "Cargo.lock" }} - exec_xtask: command: << parameters.command >> - - save_cache: - key: rust-target-v1-<< parameters.platform >>-{{ checksum "Cargo.lock" }} - paths: - - target/ # The machines we use to run our workflows on executors: @@ -83,15 +82,14 @@ executors: - image: cimg/base:stable environment: XTASK_TARGET: "x86_64-unknown-linux-musl" - -orbs: - rust: circleci/rust@1.5.0 - gh: circleci/github-cli@1.0.4 - node: circleci/node@4.7.0 + + macos: &macos_executor + macos: + xcode: "11.4" # reusable command snippets can be referred to in any `steps` object commands: - install_npm: + install_node: parameters: npm_version: type: string @@ -146,6 +144,9 @@ commands: type: enum enum: [lint, integration-test, unit-test] steps: + - restore_cache: + keys: + - rust-target-v1-<< parameters.platform >>-{{ checksum "Cargo.lock" }} - when: condition: # cargo xtask lint is the only xtask command that doesn't take a target @@ -160,6 +161,10 @@ commands: steps: - run: command: cargo xtask << parameters.command >> --target $XTASK_TARGET --verbose + - save_cache: + key: rust-target-v1-<< parameters.platform >>-{{ checksum "Cargo.lock" }} + paths: + - target/ ubuntu_update_apt: steps: From cf93bbfb0d89d376332faef5f1df5bfca18e64a6 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 14:12:25 -0500 Subject: [PATCH 32/46] fixup: add parameter to exec_xtask --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 58578628f..df98e4e7b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -61,6 +61,7 @@ jobs: rust_channel: << parameters.rust_channel >> - exec_xtask: command: << parameters.command >> + platform: << parameters.platform >> # The machines we use to run our workflows on executors: @@ -143,6 +144,8 @@ commands: command: type: enum enum: [lint, integration-test, unit-test] + platform: + type: executor steps: - restore_cache: keys: From 52b063aa102e0ea24e18e2b17edd257572655858 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 14:20:09 -0500 Subject: [PATCH 33/46] fixup: add XTASK_TARGET to macos executor --- .circleci/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index df98e4e7b..eea6f4c89 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -87,6 +87,8 @@ executors: macos: &macos_executor macos: xcode: "11.4" + environment: + XTASK_TARGET: "x86_64-apple-darwin" # reusable command snippets can be referred to in any `steps` object commands: From dbd16f84ded2e7fc6617a040b3ebf25a45ecde92 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 14:32:46 -0500 Subject: [PATCH 34/46] wip(ci): use xl machines so cc doesn't OOM --- .circleci/config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index eea6f4c89..8100dd4a4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -68,6 +68,7 @@ executors: ubuntu_gnu_docker: &ubuntu_gnu_docker_executor docker: - image: cimg/base:stable + resource_class: xlarge environment: XTASK_TARGET: "x86_64-unknown-linux-gnu" @@ -75,18 +76,21 @@ executors: ubuntu_gnu_vm: &ubuntu_gnu_vm_executor machine: image: ubuntu-1604:202104-01 + resource_class: xlarge environment: XTASK_TARGET: "x86_64-unknown-linux-gnu" ubuntu_musl: &ubuntu_musl_executor docker: - image: cimg/base:stable + resource_class: xlarge environment: XTASK_TARGET: "x86_64-unknown-linux-musl" macos: &macos_executor macos: xcode: "11.4" + resource_class: xlarge environment: XTASK_TARGET: "x86_64-apple-darwin" From 3d3a724a7802b907f16119a29f96bf5d196de84e Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 14:56:15 -0500 Subject: [PATCH 35/46] chore(ci): add windows to test matrix --- .circleci/config.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8100dd4a4..9309473f0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,7 +22,7 @@ workflows: name: unit_test_<< matrix.platform >>_<< matrix.rust_channel >> matrix: parameters: - platform: [ubuntu_gnu_docker, ubuntu_musl, macos] + platform: [ubuntu_gnu_docker, ubuntu_musl, macos, windows] rust_channel: [stable] command: [unit-test] @@ -94,6 +94,12 @@ executors: environment: XTASK_TARGET: "x86_64-apple-darwin" + windows: &windows_executor + machine: + image: 'windows-server-2019-vs2019:stable' + resource_class: xlarge + shell: powershell.exe -ExecutionPolicy Bypass + # reusable command snippets can be referred to in any `steps` object commands: install_node: From 56ddd88e97d33686a78282822dc95c607e289310 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 15:00:20 -0500 Subject: [PATCH 36/46] fixup: use windows.xlarge --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9309473f0..e83fc44e1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -97,7 +97,7 @@ executors: windows: &windows_executor machine: image: 'windows-server-2019-vs2019:stable' - resource_class: xlarge + resource_class: windows.xlarge shell: powershell.exe -ExecutionPolicy Bypass # reusable command snippets can be referred to in any `steps` object From 7894cbf601720ea2f8450c8993b0bf640f92bf1d Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 15:09:30 -0500 Subject: [PATCH 37/46] chore(ci): install rust for windows --- .circleci/config.yml | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e83fc44e1..e74a90ff4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -59,6 +59,7 @@ jobs: platform: << parameters.platform >> - install_rust_toolchain: rust_channel: << parameters.rust_channel >> + platform: << parameters.platform >> - exec_xtask: command: << parameters.command >> platform: << parameters.platform >> @@ -124,9 +125,40 @@ commands: rust_channel: type: enum enum: ["stable", "nightly"] + platform: + type: executor steps: - - rust/install: - version: << parameters.rust_channel >> + - unless: + condition: + equal: [ *windows_executor, << parameters.platform >> ] + steps: + - rust/install: + version: << parameters.rust_channel >> + - when: + condition: + equal: [ *windows_executor, << parameters.platform >> ] + steps: + - run: + name: Install rustup + environment: + # Override auto-detection of RAM for rustc install. + # https://github.com/rust-lang/rustup/issues/2229#issuecomment-585855925 + RUSTUP_UNPACK_RAM: "21474836480" + command: | + $installer_dir = "$Env:TEMP" + echo "Downloading rustup" + (New-Object System.Net.WebClient).DownloadFile("https://win.rustup.rs/x86_64", "$installer_dir\rustup-init.exe") + echo "Installing rustup" + & $installer_dir\rustup-init.exe --profile minimal -y + exit $LASTEXITCODE + - run: + name: Special case for Windows because of ssh-agent + command: | + Add-Content -path "${Env:USERPROFILE}\.cargo\config.toml" @" + [net] + git-fetch-with-cli = true + "@ + - run: name: Install specific rust toolchain command: rustup target add $XTASK_TARGET From 1bf0e7e18eebe0dd281ef59081402c46e6dfdfef Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 15:21:10 -0500 Subject: [PATCH 38/46] fixup: set XTASK_TARGET for windows --- .circleci/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index e74a90ff4..901ddd318 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -100,6 +100,8 @@ executors: image: 'windows-server-2019-vs2019:stable' resource_class: windows.xlarge shell: powershell.exe -ExecutionPolicy Bypass + environment: + XTASK_TARGET: "x86_64-pc-windows-msvc" # reusable command snippets can be referred to in any `steps` object commands: From 00122994653777b8ac8aa83744ae650366a19a01 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 15:29:03 -0500 Subject: [PATCH 39/46] wip(test): try setting windows shell to bash --- .circleci/config.yml | 65 +++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 901ddd318..90e14a2a5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -99,7 +99,7 @@ executors: machine: image: 'windows-server-2019-vs2019:stable' resource_class: windows.xlarge - shell: powershell.exe -ExecutionPolicy Bypass + shell: bash environment: XTASK_TARGET: "x86_64-pc-windows-msvc" @@ -130,36 +130,39 @@ commands: platform: type: executor steps: - - unless: - condition: - equal: [ *windows_executor, << parameters.platform >> ] - steps: - - rust/install: - version: << parameters.rust_channel >> - - when: - condition: - equal: [ *windows_executor, << parameters.platform >> ] - steps: - - run: - name: Install rustup - environment: - # Override auto-detection of RAM for rustc install. - # https://github.com/rust-lang/rustup/issues/2229#issuecomment-585855925 - RUSTUP_UNPACK_RAM: "21474836480" - command: | - $installer_dir = "$Env:TEMP" - echo "Downloading rustup" - (New-Object System.Net.WebClient).DownloadFile("https://win.rustup.rs/x86_64", "$installer_dir\rustup-init.exe") - echo "Installing rustup" - & $installer_dir\rustup-init.exe --profile minimal -y - exit $LASTEXITCODE - - run: - name: Special case for Windows because of ssh-agent - command: | - Add-Content -path "${Env:USERPROFILE}\.cargo\config.toml" @" - [net] - git-fetch-with-cli = true - "@ + - rust/install: + version: << parameters.rust_channel >> + + # - unless: + # condition: + # equal: [ *windows_executor, << parameters.platform >> ] + # steps: + # - rust/install: + # version: << parameters.rust_channel >> + # - when: + # condition: + # equal: [ *windows_executor, << parameters.platform >> ] + # steps: + # - run: + # name: Install rustup + # environment: + # # Override auto-detection of RAM for rustc install. + # # https://github.com/rust-lang/rustup/issues/2229#issuecomment-585855925 + # RUSTUP_UNPACK_RAM: "21474836480" + # command: | + # $installer_dir = "$Env:TEMP" + # echo "Downloading rustup" + # (New-Object System.Net.WebClient).DownloadFile("https://win.rustup.rs/x86_64", "$installer_dir\rustup-init.exe") + # echo "Installing rustup" + # & $installer_dir\rustup-init.exe --profile minimal -y + # exit $LASTEXITCODE + # - run: + # name: Special case for Windows because of ssh-agent + # command: | + # Add-Content -path "${Env:USERPROFILE}\.cargo\config.toml" @" + # [net] + # git-fetch-with-cli = true + # "@ - run: name: Install specific rust toolchain From 6bfccfc2ef6a60409b38aa569a583005b267e4ed Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 15:34:32 -0500 Subject: [PATCH 40/46] keep it windowsy --- .circleci/config.yml | 72 +++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 90e14a2a5..e3b69fb2d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -99,7 +99,7 @@ executors: machine: image: 'windows-server-2019-vs2019:stable' resource_class: windows.xlarge - shell: bash + shell: powershell.exe -ExecutionPolicy Bypass environment: XTASK_TARGET: "x86_64-pc-windows-msvc" @@ -130,43 +130,39 @@ commands: platform: type: executor steps: - - rust/install: - version: << parameters.rust_channel >> - - # - unless: - # condition: - # equal: [ *windows_executor, << parameters.platform >> ] - # steps: - # - rust/install: - # version: << parameters.rust_channel >> - # - when: - # condition: - # equal: [ *windows_executor, << parameters.platform >> ] - # steps: - # - run: - # name: Install rustup - # environment: - # # Override auto-detection of RAM for rustc install. - # # https://github.com/rust-lang/rustup/issues/2229#issuecomment-585855925 - # RUSTUP_UNPACK_RAM: "21474836480" - # command: | - # $installer_dir = "$Env:TEMP" - # echo "Downloading rustup" - # (New-Object System.Net.WebClient).DownloadFile("https://win.rustup.rs/x86_64", "$installer_dir\rustup-init.exe") - # echo "Installing rustup" - # & $installer_dir\rustup-init.exe --profile minimal -y - # exit $LASTEXITCODE - # - run: - # name: Special case for Windows because of ssh-agent - # command: | - # Add-Content -path "${Env:USERPROFILE}\.cargo\config.toml" @" - # [net] - # git-fetch-with-cli = true - # "@ - - - run: - name: Install specific rust toolchain - command: rustup target add $XTASK_TARGET + - unless: + condition: + equal: [ *windows_executor, << parameters.platform >> ] + steps: + - rust/install: + version: << parameters.rust_channel >> + - run: + name: Install specific rust toolchain + command: rustup target add $XTASK_TARGET + - when: + condition: + equal: [ *windows_executor, << parameters.platform >> ] + steps: + - run: + name: Install rustup + environment: + # Override auto-detection of RAM for rustc install. + # https://github.com/rust-lang/rustup/issues/2229#issuecomment-585855925 + RUSTUP_UNPACK_RAM: "21474836480" + command: | + $installer_dir = "$Env:TEMP" + echo "Downloading rustup" + (New-Object System.Net.WebClient).DownloadFile("https://win.rustup.rs/x86_64", "$installer_dir\rustup-init.exe") + echo "Installing rustup" + & $installer_dir\rustup-init.exe --profile minimal -y + exit $LASTEXITCODE + - run: + name: Special case for Windows because of ssh-agent + command: | + Add-Content -path "${Env:USERPROFILE}\.cargo\config.toml" @" + [net] + git-fetch-with-cli = true + "@ install_system_deps: parameters: From adab790b62ddeb6f70e2236bf3c0078829ef30be Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 2 Sep 2021 15:44:14 -0500 Subject: [PATCH 41/46] use medium macos executor --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e3b69fb2d..e047bf116 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -91,7 +91,7 @@ executors: macos: &macos_executor macos: xcode: "11.4" - resource_class: xlarge + resource_class: medium environment: XTASK_TARGET: "x86_64-apple-darwin" From 58b4482e9c52d2beaba92775bbdf2682dfb68c4c Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Mon, 13 Sep 2021 10:24:14 -0500 Subject: [PATCH 42/46] chore(ci): updates step names --- .circleci/config.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e047bf116..d13c90303 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,6 +11,7 @@ workflows: lint: jobs: - xtask: + name: Lint matrix: parameters: platform: [ubuntu_gnu_docker] @@ -19,7 +20,7 @@ workflows: test: jobs: - xtask: - name: unit_test_<< matrix.platform >>_<< matrix.rust_channel >> + name: Cargo tests (<< matrix.rust_channel >> on << matrix.platform >>) matrix: parameters: platform: [ubuntu_gnu_docker, ubuntu_musl, macos, windows] @@ -27,7 +28,7 @@ workflows: command: [unit-test] - xtask: - name: integration_test_<< matrix.platform >>_<< matrix.rust_channel >> + name: Supergraph demo tests (<< matrix.rust_channel >> on << matrix.platform >>) matrix: parameters: platform: [ubuntu_gnu_vm] @@ -157,7 +158,7 @@ commands: & $installer_dir\rustup-init.exe --profile minimal -y exit $LASTEXITCODE - run: - name: Special case for Windows because of ssh-agent + name: Configure cargo for Windows command: | Add-Content -path "${Env:USERPROFILE}\.cargo\config.toml" @" [net] @@ -201,6 +202,7 @@ commands: equal: [ lint, << parameters.command >> ] steps: - run: + name: cargo xtask << parameters.command >> command: cargo xtask << parameters.command >> --verbose - when: condition: @@ -208,6 +210,7 @@ commands: equal: [ lint, << parameters.command >> ] steps: - run: + name: cargo xtask << parameters.command >> command: cargo xtask << parameters.command >> --target $XTASK_TARGET --verbose - save_cache: key: rust-target-v1-<< parameters.platform >>-{{ checksum "Cargo.lock" }} From 7e2712d4eba9088ed418553a4aa692542426b176 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Mon, 13 Sep 2021 10:29:31 -0500 Subject: [PATCH 43/46] fixup: require workflow --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d13c90303..5b805878b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -35,7 +35,7 @@ workflows: rust_channel: [stable] command: [integration-test] requires: - - unit_test_ubuntu_gnu_docker_<< matrix.rust_channel >> + - Cargo tests (<< matrix.rust_channel >> on ubuntu_gnu_docker) jobs: xtask: From 44e6f99291942ae7a844053f2b0c85093719ddc2 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Mon, 13 Sep 2021 11:44:54 -0500 Subject: [PATCH 44/46] chore(ci): removes tests from GH actions --- .github/workflows/test.yml | 104 ------------------------------------- 1 file changed, 104 deletions(-) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index b938164fa..000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,104 +0,0 @@ -name: Tests - -on: - push: - branches: - - "**" - # Tests are run in the release job on tag pushes - - # We don't need to run them twice. - tags-ignore: - - "v*" - -jobs: - test: - name: Test - - runs-on: ${{ matrix.os }} - continue-on-error: ${{ contains(matrix.build, 'nightly') }} - strategy: - fail-fast: false - matrix: - build: - [ - linux-musl-stable, - linux-musl-nightly, - linux-gnu-stable, - linux-gnu-nightly, - macos-stable, - macos-nightly, - windows-stable, - windows-nightly - ] - include: - - build: linux-musl-stable - os: ubuntu-16.04 - rust: stable - target: x86_64-unknown-linux-musl - - - build: linux-gnu-stable - os: ubuntu-16.04 - rust: stable - target: x86_64-unknown-linux-gnu - - - build: macos-stable - os: macos-latest - rust: stable - target: x86_64-apple-darwin - - - build: windows-stable - os: windows-latest - rust: stable - target: x86_64-pc-windows-msvc - - - build: linux-musl-nightly - os: ubuntu-16.04 - rust: nightly - target: x86_64-unknown-linux-musl - - - build: linux-gnu-nightly - os: ubuntu-16.04 - rust: nightly - target: x86_64-unknown-linux-gnu - - - build: macos-nightly - os: macos-latest - rust: nightly - target: x86_64-apple-darwin - - - build: windows-nightly - os: windows-latest - rust: nightly - target: x86_64-pc-windows-msvc - steps: - - uses: actions/checkout@v2 - - - name: Cache Cargo registry - uses: actions/cache@v2 - with: - path: ~/.cargo/registry - key: ${{ matrix.build }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ matrix.build }}-cargo-registry- - - - name: Cache Cargo index - uses: actions/cache@v2 - with: - path: ~/.cargo/git - key: ${{ matrix.build }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ matrix.build }}-cargo-index- - - - name: Install Rust - run: | - rustup update ${{ matrix.rust }} --no-self-update - rustup default ${{ matrix.rust }} - rustup target add ${{ matrix.target }} - - - name: Install musl-tools - if: startsWith(matrix.build, 'linux-musl-') - run: | - sudo apt update - sudo apt install musl-tools - - - name: Run Tests - run: cargo xtask test --verbose --target ${{ matrix.target }} \ No newline at end of file From cf82f91d966dc02ee6b81fe4090ce3646867a4e0 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Mon, 13 Sep 2021 11:56:45 -0500 Subject: [PATCH 45/46] chore(ci): remove accidentally committed volta.sh --- volta.sh | 459 ------------------------------------------------------- 1 file changed, 459 deletions(-) delete mode 100755 volta.sh diff --git a/volta.sh b/volta.sh deleted file mode 100755 index c9c93c5ad..000000000 --- a/volta.sh +++ /dev/null @@ -1,459 +0,0 @@ -#!/usr/bin/env bash - -# This is the bootstrap Unix installer served by `https://get.volta.sh`. -# Its responsibility is to query the system to determine what OS (and in the -# case of Linux, what OpenSSL version) the system has, fetch and install the -# appropriate build of Volta, and modify the user's profile. - -# NOTE: to use an internal company repo, change how this determines the latest version -get_latest_release() { - curl --silent "https://volta.sh/latest-version" -} - -release_url() { - echo "https://github.com/volta-cli/volta/releases" -} - -download_release_from_repo() { - local version="$1" - local os_info="$2" - local tmpdir="$3" - - local filename="volta-$version-$os_info.tar.gz" - local download_file="$tmpdir/$filename" - local archive_url="$(release_url)/download/v$version/$filename" - - curl --progress-bar --show-error --location --fail "$archive_url" --output "$download_file" --write-out '%{filename_effective}' -} - -usage() { - cat >&2 < Install a specific release version of Volta -END_USAGE -} - -info() { - local action="$1" - local details="$2" - command printf '\033[1;32m%12s\033[0m %s\n' "$action" "$details" 1>&2 -} - -error() { - command printf '\033[1;31mError\033[0m: %s\n\n' "$1" 1>&2 -} - -warning() { - command printf '\033[1;33mWarning\033[0m: %s\n\n' "$1" 1>&2 -} - -request() { - command printf '\033[1m%s\033[0m\n' "$1" 1>&2 -} - -eprintf() { - command printf '%s\n' "$1" 1>&2 -} - -bold() { - command printf '\033[1m%s\033[0m' "$1" -} - -# check for issue with VOLTA_HOME -# if it is set, and exists, but is not a directory, the install will fail -volta_home_is_ok() { - if [ -n "${VOLTA_HOME-}" ] && [ -e "$VOLTA_HOME" ] && ! [ -d "$VOLTA_HOME" ]; then - error "\$VOLTA_HOME is set but is not a directory ($VOLTA_HOME)." - eprintf "Please check your profile scripts and environment." - return 1 - fi - return 0 -} - -# Check if it is OK to upgrade to the new version -upgrade_is_ok() { - local will_install_version="$1" - local install_dir="$2" - local is_dev_install="$3" - - # check for Volta in both the old location and the new 0.7.0 location - local volta_bin="$install_dir/volta" - if [ ! -x "$volta_bin" ]; then - volta_bin="$install_dir/bin/volta" - fi - - # this is not able to install Volta prior to 0.5.0 (when it was renamed) - if [[ "$will_install_version" =~ ^([0-9]+\.[0-9]+) ]]; then - local major_minor="${BASH_REMATCH[1]}" - case "$major_minor" in - 0.1|0.2|0.3|0.4|0.5) - eprintf "" - error "Cannot install Volta prior to version 0.6.0" - request " To install Volta version $will_install_version, please check out the source and build manually." - eprintf "" - return 1 - ;; - esac - fi - - if [[ -n "$install_dir" && -x "$volta_bin" ]]; then - local prev_version="$( ($volta_bin --version 2>/dev/null || echo 0.1) | sed -E 's/^.*([0-9]+\.[0-9]+\.[0-9]+).*$/\1/')" - # if this is a local dev install, skip the equality check - # if installing the same version, this is a no-op - if [ "$is_dev_install" != "true" ] && [ "$prev_version" == "$will_install_version" ]; then - eprintf "Version $will_install_version already installed" - return 1 - fi - # in the future, check $prev_version for incompatible upgrades - fi - return 0 -} - -# returns the os name to be used in the packaged release, -# including the openssl info if necessary -parse_os_info() { - local uname_str="$1" - local openssl_version="$2" - - case "$uname_str" in - Linux) - parsed_version="$(parse_openssl_version "$openssl_version")" - exit_code="$?" - if [ "$exit_code" != 0 ]; then - return "$exit_code" - fi - - echo "linux-openssl-$parsed_version" - ;; - Darwin) - if [ "$(uname -m)" == "arm64" ]; then - echo "macos-aarch64" - else - echo "macos" - fi - ;; - *) - return 1 - esac - return 0 -} - -parse_os_pretty() { - local uname_str="$1" - - case "$uname_str" in - Linux) - echo "Linux" - ;; - Darwin) - echo "macOS" - ;; - *) - echo "$uname_str" - esac -} - -# return true(0) if the element is contained in the input arguments -# called like: -# if element_in "foo" "${array[@]}"; then ... -element_in() { - local match="$1"; - shift - - local element; - # loop over the input arguments and return when a match is found - for element in "$@"; do - [ "$element" == "$match" ] && return 0 - done - return 1 -} - -# parse the OpenSSL version from the input text -# for most distros, we only care about MAJOR.MINOR, with the exception of RHEL/CENTOS, -parse_openssl_version() { - local version_str="$1" - - # array containing the SSL libraries that are supported - # would be nice to use a bash 4.x associative array, but bash 3.x is the default on OSX - SUPPORTED_SSL_LIBS=( 'OpenSSL' ) - - # use regex to get the library name and version - # typical version string looks like 'OpenSSL 1.0.1e-fips 11 Feb 2013' - if [[ "$version_str" =~ ^([^\ ]*)\ ([0-9]+\.[0-9]+) ]] - then - # check that the lib is supported - libname="${BASH_REMATCH[1]}" - major_minor="${BASH_REMATCH[2]}" - if ! element_in "$libname" "${SUPPORTED_SSL_LIBS[@]}" - then - error "Releases for '$libname' not currently supported. Supported libraries are: ${SUPPORTED_SSL_LIBS[@]}." - return 1 - fi - - # for version 1.0.x, check for RHEL/CentOS style OpenSSL SONAME (.so.10) - if [ "$major_minor" == "1.0" ] && [ -f "/usr/lib64/libcrypto.so.10" ]; then - echo "rhel" - else - echo "$major_minor" - fi - return 0 - else - error "Could not determine OpenSSL version for '$version_str'." - return 1 - fi -} - -create_tree() { - local install_dir="$1" - - info 'Creating' "directory layout" - - # .volta/ - # bin/ - - mkdir -p "$install_dir" && mkdir -p "$install_dir"/bin - if [ "$?" != 0 ] - then - error "Could not create directory layout. Please make sure the target directory is writeable: $install_dir" - exit 1 - fi -} - -install_version() { - local version_to_install="$1" - local install_dir="$2" - local should_run_setup="$3" - - if ! volta_home_is_ok; then - exit 1 - fi - - case "$version_to_install" in - latest) - local latest_version="$(get_latest_release)" - info 'Installing' "latest version of Volta ($latest_version)" - install_release "$latest_version" "$install_dir" - ;; - local-dev) - info 'Installing' "Volta locally after compiling" - install_local "dev" "$install_dir" - ;; - local-release) - info 'Installing' "Volta locally after compiling with '--release'" - install_local "release" "$install_dir" - ;; - *) - # assume anything else is a specific version - info 'Installing' "Volta version $version_to_install" - install_release "$version_to_install" "$install_dir" - ;; - esac - - if [ "$?" == 0 ] - then - if [ "$should_run_setup" == "true" ]; then - info 'Finished' "installation. Updating user profile settings." - "$install_dir"/bin/volta setup - else - "$install_dir"/bin/volta --version &>/dev/null # creates the default shims - info 'Finished' "installation. No changes were made to user profile settings." - fi - fi -} - -# parse the 'version = "X.Y.Z"' line from the input Cargo.toml contents -# and return the version string -parse_cargo_version() { - local contents="$1" - - while read -r line - do - if [[ "$line" =~ ^version\ =\ \"(.*)\" ]] - then - echo "${BASH_REMATCH[1]}" - return 0 - fi - done <<< "$contents" - - error "Could not determine the current version from Cargo.toml" - return 1 -} - -install_release() { - local version="$1" - local install_dir="$2" - local is_dev_install="false" - - info 'Checking' "for existing Volta installation" - if upgrade_is_ok "$version" "$install_dir" "$is_dev_install" - then - download_archive="$(download_release "$version"; exit "$?")" - exit_status="$?" - if [ "$exit_status" != 0 ] - then - error "Could not download Volta version '$version'. See $(release_url) for a list of available releases" - return "$exit_status" - fi - - install_from_file "$download_archive" "$install_dir" - else - # existing legacy install, or upgrade problem - return 1 - fi -} - -install_local() { - local dev_or_release="$1" - local install_dir="$2" - # this is a local install, so skip the version equality check - local is_dev_install="true" - - info 'Checking' "for existing Volta installation" - install_version="$(parse_cargo_version "$(/dev/null 2>&1 && pwd )" - - # call the release script to create the packaged archive file - # '2> >(tee /dev/stderr)' copies stderr to stdout, to collect it and parse the filename - release_output="$( "$DIR/release.sh" "--$dev_or_release" 2> >(tee /dev/stderr) )" - [ "$?" != 0 ] && return 1 - - # parse the release filename and return that - if [[ "$release_output" =~ release\ in\ file\ (target[^\ ]+) ]]; then - echo "${BASH_REMATCH[1]}" - else - error "Could not determine output filename" - return 1 - fi -} - -download_release() { - local version="$1" - - local uname_str="$(uname -s)" - local openssl_version="$(openssl version)" - local os_info - os_info="$(parse_os_info "$uname_str" "$openssl_version")" - if [ "$?" != 0 ]; then - error "The current operating system ($uname_str) does not appear to be supported by Volta." - return 1 - fi - local pretty_os_name="$(parse_os_pretty "$uname_str")" - - info 'Fetching' "archive for $pretty_os_name, version $version" - # store the downloaded archive in a temporary directory - local download_dir="$(mktemp -d)" - download_release_from_repo "$version" "$os_info" "$download_dir" -} - -install_from_file() { - local archive="$1" - local install_dir="$2" - - create_tree "$install_dir" - - info 'Extracting' "Volta binaries and launchers" - # extract the files to the specified directory - tar -xf "$archive" -C "$install_dir"/bin -} - -check_architecture() { - local version="$1" - local arch="$2" - - if [[ "$version" != "local"* ]]; then - case "$arch" in - x86_64) - return 0 - ;; - arm64) - if [ "$(uname -s)" = "Darwin" ]; then - return 0 - fi - ;; - esac - - error "Sorry! Volta currently only provides pre-built binaries for x86_64 architectures." - return 1 - fi -} - - -# return if sourced (for testing the functions above) -return 0 2>/dev/null - -# default to installing the latest available version -version_to_install="latest" - -# default to running setup after installing -should_run_setup="true" - -# install to VOLTA_HOME, defaulting to ~/.volta -install_dir="${VOLTA_HOME:-"$HOME/.volta"}" - -# parse command line options -while [ $# -gt 0 ] -do - arg="$1" - - case "$arg" in - -h|--help) - usage - exit 0 - ;; - --dev) - shift # shift off the argument - version_to_install="local-dev" - ;; - --release) - shift # shift off the argument - version_to_install="local-release" - ;; - --version) - shift # shift off the argument - version_to_install="$1" - shift # shift off the value - ;; - --skip-setup) - shift # shift off the argument - should_run_setup="false" - ;; - *) - error "unknown option: '$arg'" - usage - exit 1 - ;; - esac -done - -check_architecture "$version_to_install" "$(uname -m)" || exit 1 - -install_version "$version_to_install" "$install_dir" "$should_run_setup" From eb8832a6ac97cf494a0044f52074882868ad8848 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Mon, 13 Sep 2021 12:29:05 -0500 Subject: [PATCH 46/46] chore(ci): small cleanup --- .circleci/config.yml | 99 ++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 55 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5b805878b..0f3ecbd75 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,7 +11,7 @@ workflows: lint: jobs: - xtask: - name: Lint + name: Lint (<< matrix.rust_channel >> rust on << matrix.platform >>) matrix: parameters: platform: [ubuntu_gnu_docker] @@ -20,7 +20,7 @@ workflows: test: jobs: - xtask: - name: Cargo tests (<< matrix.rust_channel >> on << matrix.platform >>) + name: Cargo tests (<< matrix.rust_channel >> rust on << matrix.platform >>) matrix: parameters: platform: [ubuntu_gnu_docker, ubuntu_musl, macos, windows] @@ -28,14 +28,14 @@ workflows: command: [unit-test] - xtask: - name: Supergraph demo tests (<< matrix.rust_channel >> on << matrix.platform >>) + name: Supergraph demo tests (<< matrix.rust_channel >> rust on << matrix.platform >>) matrix: parameters: platform: [ubuntu_gnu_vm] rust_channel: [stable] command: [integration-test] requires: - - Cargo tests (<< matrix.rust_channel >> on ubuntu_gnu_docker) + - Cargo tests (<< matrix.rust_channel >> rust on ubuntu_gnu_docker) jobs: xtask: @@ -54,13 +54,7 @@ jobs: - checkout - install_system_deps: platform: << parameters.platform >> - - install_node: - npm_version: "7.21.1" - node_version: "14.17.1" - platform: << parameters.platform >> - - install_rust_toolchain: rust_channel: << parameters.rust_channel >> - platform: << parameters.platform >> - exec_xtask: command: << parameters.command >> platform: << parameters.platform >> @@ -106,22 +100,54 @@ executors: # reusable command snippets can be referred to in any `steps` object commands: - install_node: + install_system_deps: parameters: - npm_version: - type: string - node_version: - type: string platform: type: executor + rust_channel: + type: enum + enum: ["stable", "nightly"] steps: + - when: + condition: + or: + - equal: [ *ubuntu_gnu_docker_executor, << parameters.platform >> ] + - equal: [ *ubuntu_gnu_vm_executor, << parameters.platform >> ] + - equal: [ *ubuntu_musl_executor, << parameters.platform >> ] + steps: + - run: + name: Update apt repositories + command: sudo apt-get update + - run: + name: Install OpenSSL + command: sudo apt-get install -y libssl-dev + - when: + condition: + equal: [ *ubuntu_musl_executor, << parameters.platform >> ] + steps: + - run: + name: Install musl-tools + command: sudo apt-get install -y musl-tools - when: condition: equal: [ *ubuntu_gnu_docker_executor, << parameters.platform >> ] steps: - node/install: - node-version: << parameters.node_version >> - npm-version: << parameters.npm_version >> + node-version: "14.17.1" + npm-version: "7.21.1" + - when: + condition: + equal: [ *macos_executor, << parameters.platform >> ] + steps: + - run: + name: Install OpenSSL@1.1 + command: brew install openssl@1.1 + - run: + name: Install p7zip + command: brew install p7zip + - install_rust_toolchain: + rust_channel: << parameters.rust_channel >> + platform: << parameters.platform >> install_rust_toolchain: parameters: @@ -165,26 +191,6 @@ commands: git-fetch-with-cli = true "@ - install_system_deps: - parameters: - platform: - type: executor - steps: - - when: - condition: - or: - - equal: [ *ubuntu_gnu_docker_executor, << parameters.platform >> ] - - equal: [ *ubuntu_gnu_vm_executor, << parameters.platform >> ] - - equal: [ *ubuntu_musl_executor, << parameters.platform >> ] - steps: - - ubuntu_update_apt - - ubuntu_install_openssl - - when: - condition: - equal: [ *ubuntu_musl_executor, << parameters.platform >> ] - steps: - - ubuntu_install_musl_tools - exec_xtask: parameters: command: @@ -216,21 +222,4 @@ commands: key: rust-target-v1-<< parameters.platform >>-{{ checksum "Cargo.lock" }} paths: - target/ - - ubuntu_update_apt: - steps: - - run: - name: Update apt repositories - command: sudo apt-get update - - ubuntu_install_openssl: - steps: - - run: - name: Install OpenSSL - command: sudo apt-get install -y libssl-dev - - ubuntu_install_musl_tools: - steps: - - run: - name: Install musl-tools - command: sudo apt-get install -y musl-tools \ No newline at end of file + \ No newline at end of file