Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable macos CI #197

Merged
merged 4 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ target/
Dockerfile
.dockerignore
infra/
integration-tests/
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Integration tests
name: Integration
on:
push:
branches:
Expand All @@ -9,10 +9,20 @@ env:
RUSTFLAGS: -D warnings
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
name: Test
steps:
- uses: actions/checkout@v3
- name: Install Docker
if: ${{ matrix.os == 'macos-latest' }}
run: |
brew install docker
colima start
#
sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
Expand All @@ -33,6 +43,8 @@ jobs:
- uses: Swatinem/rust-cache@v1
- name: Install Protoc
uses: arduino/setup-protoc@v1.1.2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker image
uses: docker/build-push-action@v4
with:
Expand All @@ -43,3 +55,6 @@ jobs:
cache-to: type=gha,mode=max
- name: Test
run: cargo test -p mpc-recovery-integration-tests --jobs 1 -- --test-threads 1
env:
RUST_LOG: trace
RUST_BACKTRACE: 1
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml → .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Unit tests
name: Unit
on:
push:
branches:
Expand All @@ -10,7 +10,7 @@ env:
jobs:
test:
runs-on: ubuntu-latest
name: Test
name: Check & Test
steps:
- uses: actions/checkout@v3
- name: Install stable toolchain
Expand Down
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ COPY mpc-recovery/Cargo.toml Cargo.toml
RUN sed -i 's#src/main.rs#dummy.rs#' Cargo.toml
RUN cargo build --release
COPY . .
RUN sed -i 's#"integration-tests",##' Cargo.toml
RUN cargo build --release --package mpc-recovery

FROM debian:bullseye-slim as runtime
Expand Down
4 changes: 3 additions & 1 deletion integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ workspaces = { git = "https://github.com/near/workspaces-rs", branch = "main" }
[dev-dependencies]
once_cell = "1"
rand = "0.8"
test-log = { version = "0.2.12", default-features = false, features = ["trace"] }
test-log = { version = "0.2.12", features = ["log", "trace"] }
env_logger = "0.10.0"
tracing-log = "0.1.3"
tokio-util = { version = "0.7", features = ["full"] }
curv = { package = "curv-kzen", version = "0.9", default-features = false }
reqwest = "0.11.16"
Expand Down
9 changes: 7 additions & 2 deletions integration-tests/src/containers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ impl<'a> Sandbox<'a> {
tracing::info!("Running sandbox container...");
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
let image = GenericImage::new("ghcr.io/near/sandbox", "latest-aarch64")
.with_wait_for(WaitFor::seconds(2))
.with_wait_for(WaitFor::Nothing)
.with_exposed_port(Self::CONTAINER_RPC_PORT);
#[cfg(target_arch = "x86_64")]
let image = GenericImage::new("ghcr.io/near/sandbox", "latest")
.with_wait_for(WaitFor::seconds(2))
.with_wait_for(WaitFor::Nothing)
.with_exposed_port(Self::CONTAINER_RPC_PORT);
let image: RunnableImage<GenericImage> = (
image,
Expand All @@ -136,6 +136,11 @@ impl<'a> Sandbox<'a> {
.get_network_ip_address(&container, network)
.await?;

container.exec(ExecCommand {
cmd: format!("bash -c 'while [[ \"$(curl -s -o /dev/null -w ''%{{http_code}}'' localhost:{})\" != \"200\" ]]; do sleep 1; done'", Self::CONTAINER_RPC_PORT),
ready_conditions: vec![]
});

let full_address = format!("http://{}:{}", address, Self::CONTAINER_RPC_PORT);
tracing::info!("Sandbox container is running at {}", full_address);
Ok(Sandbox {
Expand Down