From 838bc3d965bfd2ccdfe653e69b287c136d7c00b3 Mon Sep 17 00:00:00 2001 From: Pieter Date: Sun, 23 Apr 2023 21:01:56 +0200 Subject: [PATCH] ci: add mac qa (#801) * ci: add mac qa * ci: larger resource * ci: smaller resources * ci: install protobuf * ci: make project name unique * ci: install docker * ci: more time * bug: parse runtime version correctly * ci: more time * ci: more time * ci: more time * ci: remove Docker mac test * ci: mac-qa requirement --- .circleci/config.yml | 53 ++++++++++++++++++++++++++++++++++++---- .circleci/qa-docker.sh | 2 +- .circleci/qa.sh | 10 ++++---- cargo-shuttle/src/lib.rs | 5 ++-- 4 files changed, 57 insertions(+), 13 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2e5f63e1c..fb242a540 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -410,7 +410,7 @@ jobs: linux-qa: machine: image: ubuntu-2004:current - resource_class: xlarge + resource_class: medium steps: - checkout - run: @@ -427,7 +427,7 @@ jobs: cargo shuttle login --api-key ${SHUTTLE_API_KEY} - run: name: QA - command: ./.circleci/qa.sh + command: ./.circleci/qa.sh linux environment: SHUTTLE_API: https://api.unstable.shuttle.rs - run: git submodule sync @@ -438,6 +438,47 @@ jobs: - run: name: Test Docker command: ./.circleci/qa-docker.sh + mac-qa: + macos: + xcode: 12.5.1 + resource_class: medium + steps: + - checkout + - run: + name: "Install Protobuf" + command: | + brew install protobuf + - run: + name: "Install Rust" + command: | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + - run: + name: "Install Shuttle" + command: cargo install cargo-shuttle --path ./cargo-shuttle + - run: cargo shuttle --version + - run: + name: Login + command: | + cargo shuttle login --api-key ${SHUTTLE_API_KEY} + - run: + name: QA + command: ./.circleci/qa.sh mac + environment: + SHUTTLE_API: https://api.unstable.shuttle.rs + - run: git submodule sync + - run: git submodule update --init + - run: + name: Test WASM + command: ./.circleci/qa-wasm.sh + # We can't run Docker inside the MacOs executor at this time + # https://support.circleci.com/hc/en-us/articles/360045029591-Can-I-use-Docker-within-the-macOS-executor- + # - run: + # name: "Install Docker" + # command: | + # brew install --cask docker + # - run: + # name: Test Docker + # command: ./.circleci/qa-docker.sh workflows: ci: @@ -502,6 +543,10 @@ workflows: filters: branches: only: production + - mac-qa: + filters: + branches: + only: production - build-binaries-linux: name: build-binaries-x86_64-gnu image: ubuntu-2204:2022.04.1 @@ -536,14 +581,12 @@ workflows: branches: only: production - build-binaries-windows: - requires: - - linux-qa filters: branches: only: production - build-binaries-mac: requires: - - linux-qa + - mac-qa filters: branches: only: production diff --git a/.circleci/qa-docker.sh b/.circleci/qa-docker.sh index a3dfbb487..3c6d2a829 100755 --- a/.circleci/qa-docker.sh +++ b/.circleci/qa-docker.sh @@ -7,7 +7,7 @@ cd examples/rocket/postgres # Start locally cargo shuttle run & -sleep 100 +sleep 300 echo "Testing local docker endpoint" output=$(curl --silent --request POST --header "Content-Type: application/json" --data '{"note": "test"}' localhost:8000/todo) diff --git a/.circleci/qa.sh b/.circleci/qa.sh index a0206b7fb..e44111917 100755 --- a/.circleci/qa.sh +++ b/.circleci/qa.sh @@ -3,15 +3,15 @@ set -ue # Prepare directory -mkdir -p /tmp/qa-linux -cd /tmp/qa-linux +mkdir -p /tmp/qa-$1 +cd /tmp/qa-$1 # Init app -cargo shuttle init --name qa-linux --axum +cargo shuttle init --name qa-$1 --axum # Start locally cargo shuttle run & -sleep 70 +sleep 150 echo "Testing local hello endpoint" output=$(curl --silent localhost:8000/hello) @@ -24,7 +24,7 @@ cargo shuttle project start cargo shuttle deploy --allow-dirty echo "Testing remote hello endpoint" -output=$(curl --silent https://qa-linux.unstable.shuttleapp.rs/hello) +output=$(curl --silent https://qa-$1.unstable.shuttleapp.rs/hello) [ "$output" != "Hello, world!" ] && ( echo "Did not expect output: $output"; exit 1 ) cargo shuttle project stop diff --git a/cargo-shuttle/src/lib.rs b/cargo-shuttle/src/lib.rs index 725833552..0e9acc24a 100644 --- a/cargo-shuttle/src/lib.rs +++ b/cargo-shuttle/src/lib.rs @@ -526,7 +526,7 @@ impl Shuttle { // If the version of cargo-shuttle is different from shuttle-runtime, // or it isn't installed, try to install shuttle-runtime from crates.io. if let Err(err) = check_version(&runtime_path) { - warn!("{}", err); + warn!(error = ?err, "failed to check installed runtime version"); trace!("installing shuttle-runtime"); std::process::Command::new("cargo") @@ -1002,7 +1002,8 @@ fn check_version(runtime_path: &Path) -> Result<()> { .expect("shuttle-runtime version should be valid utf8") .split_once(' ') .expect("shuttle-runtime version should be in the `name version` format") - .1, + .1 + .trim(), ) .context("failed to convert runtime version to semver")? .to_string();