From 3bab43a7fc387e6bb7c20055d39da88d497b23f3 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Mon, 15 Jan 2024 11:49:59 +0100 Subject: [PATCH] No longer run e2e tests in Docker Signed-off-by: Ryan Levick --- .github/workflows/build.yml | 35 +++++++++----- Makefile | 13 +----- e2e-tests-aarch64.Dockerfile | 82 --------------------------------- e2e-tests-docker-compose.yml | 61 ------------------------- e2e-tests.Dockerfile | 88 ------------------------------------ tests/testcases/mod.rs | 9 +++- 6 files changed, 33 insertions(+), 255 deletions(-) delete mode 100644 e2e-tests-aarch64.Dockerfile delete mode 100644 e2e-tests-docker-compose.yml delete mode 100644 e2e-tests.Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d3c719f80..92481fba4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -197,23 +197,34 @@ jobs: # run on a larger runner for more SSD/resource access runs-on: ubuntu-22.04-4core-spin if: ${{ github.repository_owner == 'fermyon' }} - needs: build-rust-ubuntu steps: - uses: actions/checkout@v3 - - name: Retrieve saved Spin Binary - uses: actions/download-artifact@v3 + # Install all the toolchain dependencies + - name: Install Rust wasm target + run: rustup target add wasm32-wasi && rustup target add wasm32-unknown-unknown + - uses: goto-bus-stop/setup-zig@v2 + - uses: actions/setup-go@v4 with: - name: spin-ubuntu-latest - path: target/release/ - - - name: Build e2e tests image + go-version: '1.20.1' + - uses: acifani/setup-tinygo@v2 + with: + tinygo-version: '0.27.0' + - uses: actions/setup-node@v3 + with: + node-version: '16.x' + - name: Install Swift + run: | + wget https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.8-SNAPSHOT-2023-02-24-a/swift-wasm-5.8-SNAPSHOT-2023-02-24-a-ubuntu22.04_x86_64.tar.gz + tar -xf swift-wasm-5.8-SNAPSHOT-2023-02-24-a-ubuntu22.04_x86_64.tar.gz + echo "$PWD/swift-wasm-5.8-SNAPSHOT-2023-02-24-a/usr/bin" >> $GITHUB_PATH + - name: Install Grain run: | - export E2E_FETCH_SPIN=false - make build-test-spin-up + wget https://github.com/grain-lang/grain/releases/download/grain-v0.5.4/grain-linux-x64 + chmod +x grain-linux-x64 + mv grain-linux-x64 grain + echo "$PWD" >> $GITHUB_PATH - name: Run e2e tests run: | - chmod +x `pwd`/target/release/spin - export E2E_VOLUME_MOUNT="-v `pwd`/target/release/spin:/usr/local/bin/spin" - make run-test-spin-up + make test-spin-up diff --git a/Makefile b/Makefile index f47215e12..e8f28f3f9 100644 --- a/Makefile +++ b/Makefile @@ -99,17 +99,8 @@ test-integration: $(LOG_LEVEL_VAR) cargo test --test integration --no-fail-fast -- --skip spinup_tests --skip cloud_tests --nocapture .PHONY: test-spin-up -test-spin-up: build-test-spin-up run-test-spin-up - -.PHONY: build-test-spin-up -build-test-spin-up: - docker build -t spin-e2e-tests --build-arg FETCH_SPIN=$(E2E_FETCH_SPIN) --build-arg BUILD_SPIN=$(E2E_BUILD_SPIN) -f $(E2E_TESTS_DOCKERFILE) . - -.PHONY: run-test-spin-up -run-test-spin-up: - REDIS_IMAGE=$(REDIS_IMAGE) MYSQL_IMAGE=$(MYSQL_IMAGE) POSTGRES_IMAGE=$(POSTGRES_IMAGE) \ - BUILD_SPIN=$(E2E_BUILD_SPIN) \ - docker compose -f e2e-tests-docker-compose.yml run $(E2E_SPIN_RELEASE_VOLUME_MOUNT) $(E2E_SPIN_DEBUG_VOLUME_MOUNT) e2e-tests +test-spin-up: + cargo test --release spinup_tests --no-default-features --features e2e-tests --no-fail-fast -- --nocapture .PHONY: test-sdk-go test-sdk-go: diff --git a/e2e-tests-aarch64.Dockerfile b/e2e-tests-aarch64.Dockerfile deleted file mode 100644 index 4c2fc7134..000000000 --- a/e2e-tests-aarch64.Dockerfile +++ /dev/null @@ -1,82 +0,0 @@ -FROM ubuntu:22.04 - -ARG BUILD_SPIN=false -ARG SPIN_VERSION=canary - -WORKDIR /root -RUN apt-get update && apt-get install -y wget sudo xz-utils gcc git pkg-config redis clang libicu-dev docker.io - -# nodejs -RUN curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - -RUN apt-get install -y nodejs npm - -# golang -RUN wget https://go.dev/dl/go1.20.1.linux-arm64.tar.gz && \ - rm -rf /usr/local/go && tar -C /usr/local -xzf go1.20.1.linux-arm64.tar.gz -ENV PATH="$PATH:/usr/local/go/bin" - -# tinygo -RUN wget https://github.com/tinygo-org/tinygo/releases/download/v0.27.0/tinygo_0.27.0_arm64.deb && \ - sudo dpkg -i tinygo_0.27.0_arm64.deb && \ - tinygo env - -RUN wget https://ziglang.org/download/0.10.0/zig-linux-aarch64-0.10.0.tar.xz && \ - tar -xf zig-linux-aarch64-0.10.0.tar.xz -ENV PATH="$PATH:/root/zig-linux-aarch64-0.10.0" - -# # grain - disabled as no arm build -# RUN wget https://github.com/grain-lang/grain/releases/download/grain-v0.5.4/grain-linux-x64 && \ -# mv grain-linux-x64 /usr/local/bin/grain && chmod +x /usr/local/bin/grain - -# # rust -ENV RUSTUP_HOME=/usr/local/rustup \ - CARGO_HOME=/usr/local/cargo \ - PATH=/usr/local/cargo/bin:$PATH - -RUN url="https://static.rust-lang.org/rustup/dist/aarch64-unknown-linux-gnu/rustup-init"; \ - wget "$url"; \ - chmod +x rustup-init; \ - ./rustup-init -y --no-modify-path --default-toolchain 1.73 --default-host aarch64-unknown-linux-gnu; \ - rm rustup-init; \ - chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ - rustup --version; \ - cargo --version; \ - rustc --version; \ - rustup target add wasm32-wasi; \ - rustup target add wasm32-unknown-unknown; - -# swift -RUN wget https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.8-SNAPSHOT-2023-02-24-a/swift-wasm-5.8-SNAPSHOT-2023-02-24-a-ubuntu20.04_aarch64.tar.gz && \ - tar -xf swift-wasm-5.8-SNAPSHOT-2023-02-24-a-ubuntu20.04_aarch64.tar.gz -ENV PATH="$PATH:/root/swift-wasm-5.8-SNAPSHOT-2023-02-24-a/usr/bin" - -## check versions -RUN tinygo version; \ - go version; \ - zig version; \ - rustc --version; \ - node --version; \ - swift --version; - -## spin -RUN wget https://github.com/fermyon/spin/releases/download/${SPIN_VERSION}/spin-${SPIN_VERSION}-linux-aarch64.tar.gz && \ - tar -xvf spin-${SPIN_VERSION}-linux-aarch64.tar.gz && \ - ls -ltr && \ - mv spin /usr/local/bin/spin; - -WORKDIR /e2e-tests -COPY . . - -RUN printf '#!/bin/bash \n \ - if [[ "$BUILD_SPIN" == "true" ]]; then \n \ - echo "BUILD_SPIN is true. compiling spin" \n \ - cargo build --release \n \ - fi \n\n \ - cargo test spinup_tests --features e2e-tests --no-fail-fast -- --nocapture \n \ - ' > /usr/local/bin/entrypoint.sh - -RUN chmod +x /usr/local/bin/entrypoint.sh - -RUN spin --version -ENV PATH=/from-host/target/debug:/from-host/target/release:$HOME/.cargo/bin:$PATH -CMD /usr/local/bin/entrypoint.sh diff --git a/e2e-tests-docker-compose.yml b/e2e-tests-docker-compose.yml deleted file mode 100644 index b553891a3..000000000 --- a/e2e-tests-docker-compose.yml +++ /dev/null @@ -1,61 +0,0 @@ -version: "3.9" - -services: - mysql: - image: ${MYSQL_IMAGE:-mysql:8.0.22} - ports: - - "3306:3306" - volumes: - - db_data:/var/lib/mysql - restart: always - environment: - MYSQL_ROOT_PASSWORD: spin - MYSQL_DATABASE: spin_dev - MYSQL_USER: spin - MYSQL_PASSWORD: spin - - postgres: - image: ${POSTGRES_IMAGE:-postgres:14.7-alpine} - restart: always - environment: - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=postgres - - POSTGRES_DB=spin_dev - ports: - - '5432:5432' - volumes: - - postgres_data:/var/lib/postgresql/data - - redis: - image: ${REDIS_IMAGE:-redis:7.0.8-alpine3.17} - ports: - - "6379:6379" - restart: always - - registry: - image: ${REGISTRY_IMAGE:-registry:2} - ports: - - "5001:5000" - restart: always - environment: - - REGISTRY_HTTP_SECRET=secret - - e2e-tests: - depends_on: - - mysql - - redis - - postgres - - registry - image: spin-e2e-tests - entrypoint: /usr/local/bin/entrypoint.sh - volumes: - - target_cache:/e2e-tests/target - - cargo_registry_cache:/usr/local/cargo/registry - - cargo_git_cache:/usr/local/cargo/git - -volumes: - db_data: {} - postgres_data: {} - cargo_registry_cache: {} - cargo_git_cache: {} - target_cache: {} diff --git a/e2e-tests.Dockerfile b/e2e-tests.Dockerfile deleted file mode 100644 index ba9d86350..000000000 --- a/e2e-tests.Dockerfile +++ /dev/null @@ -1,88 +0,0 @@ -FROM ubuntu:22.04 - -ARG BUILD_SPIN=false -ARG FETCH_SPIN=true -ARG SPIN_VERSION=canary - -WORKDIR /root -RUN apt-get update && apt-get install -y wget sudo xz-utils gcc git pkg-config redis clang libicu-dev docker.io netcat - -# nodejs -RUN curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - -RUN apt-get install -y nodejs npm - -# golang -RUN wget https://go.dev/dl/go1.20.1.linux-amd64.tar.gz && \ - rm -rf /usr/local/go && tar -C /usr/local -xzf go1.20.1.linux-amd64.tar.gz -ENV PATH="$PATH:/usr/local/go/bin" - -# tinygo -RUN wget https://github.com/tinygo-org/tinygo/releases/download/v0.27.0/tinygo_0.27.0_amd64.deb && \ - sudo dpkg -i tinygo_0.27.0_amd64.deb && \ - tinygo env - -# zig -RUN wget https://ziglang.org/download/0.10.0/zig-linux-x86_64-0.10.0.tar.xz && \ - tar -xf zig-linux-x86_64-0.10.0.tar.xz -ENV PATH="$PATH:/root/zig-linux-x86_64-0.10.0" - -# grain -RUN wget https://github.com/grain-lang/grain/releases/download/grain-v0.5.4/grain-linux-x64 && \ - mv grain-linux-x64 /usr/local/bin/grain && chmod +x /usr/local/bin/grain - -# # rust -ENV RUSTUP_HOME=/usr/local/rustup \ - CARGO_HOME=/usr/local/cargo \ - PATH=/usr/local/cargo/bin:$PATH - -RUN url="https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init"; \ - wget "$url"; \ - chmod +x rustup-init; \ - ./rustup-init -y --no-modify-path --default-toolchain 1.73 --default-host x86_64-unknown-linux-gnu; \ - rm rustup-init; \ - chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ - rustup --version; \ - cargo --version; \ - rustc --version; \ - rustup target add wasm32-wasi; \ - rustup target add wasm32-unknown-unknown; - -# swift -RUN wget https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.8-SNAPSHOT-2023-02-24-a/swift-wasm-5.8-SNAPSHOT-2023-02-24-a-ubuntu22.04_x86_64.tar.gz && \ - tar -xf swift-wasm-5.8-SNAPSHOT-2023-02-24-a-ubuntu22.04_x86_64.tar.gz -ENV PATH="$PATH:/root/swift-wasm-5.8-SNAPSHOT-2023-02-24-a/usr/bin" - -## check versions -RUN tinygo version; \ - go version; \ - zig version; \ - rustc --version; \ - node --version; \ - swift --version; - -RUN if [ "${FETCH_SPIN}" = "true" ]; then \ - wget https://github.com/fermyon/spin/releases/download/${SPIN_VERSION}/spin-${SPIN_VERSION}-linux-amd64.tar.gz && \ - tar -xvf spin-${SPIN_VERSION}-linux-amd64.tar.gz && \ - ls -ltr && \ - mv spin /usr/local/bin/spin; \ - fi - -WORKDIR /e2e-tests -COPY . . - -RUN printf '#!/bin/bash \n \ - if [[ "$BUILD_SPIN" == "true" ]]; then \n \ - echo "BUILD_SPIN is true. compiling spin" \n \ - cargo build --release \n \ - fi \n\n \ - cargo test spinup_tests --features e2e-tests --no-fail-fast -- --nocapture \n \ - ' > /usr/local/bin/entrypoint.sh - -RUN chmod +x /usr/local/bin/entrypoint.sh - -RUN if [ "${FETCH_SPIN}" = "true" ] || [ "${BUILD_SPIN}" = "true" ]; then \ - spin --version; \ - fi - -ENV PATH=/from-host/target/debug:/from-host/target/release:$HOME/.cargo/bin:$PATH -CMD /usr/local/bin/entrypoint.sh diff --git a/tests/testcases/mod.rs b/tests/testcases/mod.rs index f98a5d4c4..4ef208a60 100644 --- a/tests/testcases/mod.rs +++ b/tests/testcases/mod.rs @@ -245,8 +245,15 @@ pub fn bootstrap_smoke_test( .args(new_app_args(&mut env)?); env.run_in(&mut new_app)?; prebuild_hook(&mut env)?; + let path = std::env::var("PATH").unwrap_or_default(); + let path = if path.is_empty() { + spin_binary().parent().unwrap().display().to_string() + } else { + format!("{path}:{}", spin_binary().parent().unwrap().display()) + }; let mut build = std::process::Command::new(spin_binary()); - build.args(["build"]); + // Ensure `spin` is on the path + build.env("PATH", path).args(["build"]); env.run_in(&mut build)?; let spin_up_args = spin_up_args(&mut env)?; let spin = testing_framework::Spin::start(&spin_binary(), &env, spin_up_args, spin_mode)?;