From 0a01113c83c7eebf595239b1a24a94db153bf655 Mon Sep 17 00:00:00 2001 From: Nugine Date: Wed, 26 Feb 2025 14:20:05 +0800 Subject: [PATCH] ci: fix e2e tests --- .github/actions/setup/action.yml | 5 ++ .github/workflows/ci.yml | 137 +++++++++++++++++++++++++++-- .github/workflows/e2e.yml | 146 ------------------------------- scripts/e2e-run.sh | 11 +++ 4 files changed, 146 insertions(+), 153 deletions(-) delete mode 100644 .github/workflows/e2e.yml create mode 100755 scripts/e2e-run.sh diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 9447a8cd..ae177cb9 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -9,6 +9,9 @@ inputs: cache-shared-key: required: true default: "" + cache-save-if: + required: true + default: true runs: using: "composite" @@ -39,7 +42,9 @@ runs: - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true + cache-all-crates: true shared-key: ${{ inputs.cache-shared-key }} + save-if: ${{ inputs.cache-save-if }} - uses: mlugg/setup-zig@v1 - uses: taiki-e/install-action@cargo-zigbuild diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 486bfacd..c7a6cba0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,20 +33,143 @@ jobs: develop: needs: skip-check if: needs.skip-check.outputs.should_skip != 'true' - runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup + with: + cache-shared-key: "develop" + + - name: Install s3s-e2e + run: | + cargo install s3s-e2e --git https://github.com/Nugine/s3s.git + s3s-e2e --version - name: Format run: cargo fmt --all --check - name: Lint - run: cargo check - # run: cargo clippy - # run: cargo clippy -- -D warnings + run: cargo check --all-targets + # TODO: cargo clippy - - name: Test - run: cargo test --all --exclude e2e_test + - name: Build debug + run: | + touch rustfs/build.rs + cargo build -p rustfs --bins + + - name: Build release + run: | + touch rustfs/build.rs + cargo build -p rustfs --bins --release + + - run: | + mkdir -p ./target/artifacts + cp target/debug/rustfs ./target/artifacts/rustfs-debug + cp target/release/rustfs ./target/artifacts/rustfs-release + + - uses: actions/upload-artifact@v4 + with: + name: rustfs + path: ./target/artifacts/* + + test: + name: Test + needs: + - skip-check + - develop + if: needs.skip-check.outputs.should_skip != 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup + with: + cache-shared-key: "develop" + cache-save-if: "false" + - run: cargo test --all --exclude e2e_test + + s3s-e2e: + name: E2E (s3s-e2e) + needs: + - skip-check + - develop + if: needs.skip-check.outputs.should_skip != 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup + with: + cache-shared-key: "develop" + cache-save-if: false + + - name: Install s3s-e2e + run: | + cargo install s3s-e2e --git https://github.com/Nugine/s3s.git + s3s-e2e --version + + - uses: actions/download-artifact@v4 + with: + name: rustfs + path: ./target/artifacts + + - name: Run rustfs + run: | + ./scripts/e2e-run.sh ./target/artifacts/rustfs-debug /data/rustfs + sleep 10 + + - name: Run s3s-e2e + timeout-minutes: 10 + run: | + export AWS_ACCESS_KEY_ID=rustfsadmin + export AWS_SECRET_ACCESS_KEY=rustfsadmin + export AWS_REGION=us-east-1 + export AWS_ENDPOINT_URL=http://localhost:9000 + export RUST_LOG="s3s_e2e=debug,s3s_test=info,s3s=debug" + export RUST_BACKTRACE=full + s3s-e2e + sudo killall rustfs-debug + + - uses: actions/upload-artifact@v4 + with: + name: s3s-e2e.logs + path: /tmp/rustfs.log + + mint: + name: E2E (mint) + needs: + - skip-check + - develop + if: needs.skip-check.outputs.should_skip != 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup + with: + cache-shared-key: "develop" + cache-save-if: false + + - uses: actions/download-artifact@v4 + with: + name: rustfs + path: ./target/artifacts + + - name: Run rustfs + run: | + ./scripts/e2e-run.sh ./target/artifacts/rustfs-release /data/rustfs + sleep 10 + + - name: Run mint + timeout-minutes: 10 + run: | + docker run \ + -e "SERVER_ENDPOINT=localhost:9000" \ + -e "ACCESS_KEY=rustfsadmin" \ + -e "SECRET_KEY=rustfsadmin" \ + -e "ENABLE_HTTPS=0" \ + --network host \ + minio/mint:edge + sudo killall rustfs-release + + - uses: actions/upload-artifact@v4 + with: + name: mint.logs + path: /tmp/rustfs.log diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml deleted file mode 100644 index 9ec14b81..00000000 --- a/.github/workflows/e2e.yml +++ /dev/null @@ -1,146 +0,0 @@ -name: E2E - -on: - workflow_dispatch: - schedule: - - cron: '0 0 * * 0' # at midnight of each sunday - push: - branches: - - main - pull_request: - branches: - - main - -env: - CARGO_TERM_COLOR: always - -jobs: - skip-check: - permissions: - actions: write - contents: read - runs-on: ubuntu-latest - outputs: - should_skip: ${{ steps.skip_check.outputs.should_skip }} - steps: - - id: skip_check - uses: fkirc/skip-duplicate-actions@v5 - with: - concurrent_skipping: 'same_content_newer' - cancel_others: true - paths_ignore: '["*.md"]' - - s3s-e2e: - needs: skip-check - if: needs.skip-check.outputs.should_skip != 'true' - runs-on: ubuntu-latest - timeout-minutes: 20 - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/setup - - - name: Build binaries - run: | - touch rustfs/build.rs - cargo build -p rustfs --bins - - - name: Install s3s-e2e - run: | - mkdir -p target/s3s-e2e - cargo install s3s-e2e \ - --git https://github.com/Nugine/s3s.git \ - --target-dir target/s3s-e2e \ - --force - s3s-e2e --version - - - name: Run tests - run: | - export SKIP_BUILD=1 - nohup ./scripts/run.sh & - sleep 3 - - export AWS_ACCESS_KEY_ID=rustfsadmin - export AWS_SECRET_ACCESS_KEY=rustfsadmin - export AWS_REGION=us-east-1 - export AWS_ENDPOINT_URL=http://localhost:9000 - export RUST_LOG="s3s_e2e=debug,s3s_test=info,s3s=debug" - export RUST_BACKTRACE=full - s3s-e2e - killall rustfs - mint: - needs: skip-check - if: needs.skip-check.outputs.should_skip != 'true' - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/setup - - - name: Build binaries - run: | - touch rustfs/build.rs - cargo build -p rustfs --bins --release - - - name: run this rustfs server - run: | - sudo mkdir -p /data/rustfs - sudo nohup ./target/release/rustfs /data/rustfs & - - - name: run mint test task - run: | - ps aux | grep rustfs - SERVER_ADDRESS=$(ifconfig eth0 | awk 'NR==2 { print $2 }') - docker run -e SERVER_ENDPOINT=${SERVER_ADDRESS}:9000 \ - -e ACCESS_KEY=rustfsadmin \ - -e SECRET_KEY=rustfsadmin \ - -e ENABLE_HTTPS=0 \ - minio/mint - - ### Temporarily disabled because it is not working - # e2e: - # # See this url if required matrix jobs are hanging - # # https://github.com/fkirc/skip-duplicate-actions#how-to-use-skip-check-with-required-matrix-jobs - # needs: skip-check - # if: needs.skip-check.outputs.should_skip != 'true' - - # timeout-minutes: 30 - # runs-on: ubuntu-latest - # strategy: - # matrix: - # rust: - # - stable - # # - nightly - - # steps: - # - uses: arduino/setup-protoc@v3 - # with: - # version: "27.0" - - # - uses: Nugine/setup-flatc@v1 - # with: - # version: "24.3.25" - - # - uses: actions/checkout@v4 - - # - name: toolchain - # uses: dtolnay/rust-toolchain@master - # with: - # toolchain: ${{ matrix.rust }} - # # components: rustfmt, clippy - - # - uses: Swatinem/rust-cache@v2 - # with: - # cache-on-failure: true - - # - name: run fs start - # working-directory: . - # run: | - # nohup make e2e-server & - - # - name: run fs test - # working-directory: . - # run: | - # make probe-e2e - - # - name: e2e test - # run: cargo test -p e2e_test --lib diff --git a/scripts/e2e-run.sh b/scripts/e2e-run.sh new file mode 100755 index 00000000..26e3d9c6 --- /dev/null +++ b/scripts/e2e-run.sh @@ -0,0 +1,11 @@ +#!/bin/bash -ex +BIN=$1 +VOLUME=$2 + +chmod +x $BIN +sudo mkdir -p $VOLUME + +export RUST_LOG="rustfs=debug,ecstore=debug,s3s=debug,iam=debug" +export RUST_BACKTRACE=full + +sudo nohup $BIN $VOLUME > /tmp/rustfs.log 2>&1 &