Skip to content

Commit

Permalink
ci: add mac qa (#801)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
chesedo authored Apr 23, 2023
1 parent c596e46 commit 838bc3d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 13 deletions.
53 changes: 48 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ jobs:
linux-qa:
machine:
image: ubuntu-2004:current
resource_class: xlarge
resource_class: medium
steps:
- checkout
- run:
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .circleci/qa-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions .circleci/qa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 838bc3d

Please sign in to comment.