From 7cec3d19212377a1a7086412b5ad8392f7ed51f7 Mon Sep 17 00:00:00 2001 From: Anatolios Laskaris Date: Wed, 29 Mar 2023 19:28:53 +0300 Subject: [PATCH] chore: Update E2E [fixes FLU-297 and FLU-252 and FLU-298 and FLU-267] (#1538) * Update * Fix * Cleanup * Fix lint * Naming * Naming 2 * Cleanup --- .github/workflows/build.yml | 90 +++++++++++++++++++++ .github/workflows/e2e.yml | 55 +++++++++---- .github/workflows/{ci.yml => run-tests.yml} | 2 +- .github/workflows/snapshot.yml | 79 ++---------------- .github/workflows/tests.yml | 53 ++++-------- 5 files changed, 155 insertions(+), 124 deletions(-) create mode 100644 .github/workflows/build.yml rename .github/workflows/{ci.yml => run-tests.yml} (94%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..58c385025e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,90 @@ +name: "Build rust-peer binary" + +on: + workflow_call: + inputs: + ref: + description: "git ref to checkout to" + type: string + default: "master" + cargo-dependencies: + description: "Cargo dependencies map" + type: string + default: "null" + outputs: + rust-peer-sha: + description: "rust-peer sha256 hash" + value: ${{ jobs.build.outputs.sha256 }} + +jobs: + build: + name: "Build rust-peer" + runs-on: builder + timeout-minutes: 60 + + env: + RUSTFLAGS: "-D warnings --cfg tokio_unstable" + + outputs: + sha256: "${{ steps.sha.outputs.sha256 }}" + + steps: + - name: Checkout rust-peer + uses: actions/checkout@v3 + with: + repository: fluencelabs/rust-peer + ref: ${{ inputs.ref }} + + - name: Setup Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Get PR labels + id: labels + uses: joerick/pr-labels-action@v1.0.7 + + - name: Set profile + id: profile + run: | + if [[ -n "$GITHUB_PR_LABEL_PROFILING" ]]; then + echo "profile=profiling" >> $GITHUB_OUTPUT + echo "flags=--profile=profiling --features particle-node/dhat-heap" >> $GITHUB_OUTPUT + else + echo "profile=release" >> $GITHUB_OUTPUT + echo "flags=--profile=release" >> $GITHUB_OUTPUT + fi + + - name: Set dependencies + if: inputs.cargo-dependencies != 'null' + uses: fluencelabs/github-actions/cargo-set-dependency@main + with: + dependencies: ${{ inputs.cargo-dependencies }} + + - name: Generate snapshot version + id: version + uses: fluencelabs/github-actions/generate-snapshot-id@main + + - name: Set version + id: snapshot + uses: fluencelabs/github-actions/cargo-publish-snapshot@main + with: + id: ${{ steps.version.outputs.id }} + publish: false + + - name: Run cargo build + run: cargo build ${{ steps.profile.outputs.flags }} -p particle-node + + - name: Calculate SHA256 + id: sha + working-directory: ./target/${{ steps.profile.outputs.profile }} + run: | + # Calculate sha256 + du -hs particle-node + sha256sum particle-node + sha=($(sha256sum particle-node)) + echo "sha256=${sha}" >> $GITHUB_OUTPUT + + - name: Upload rust-peer binary + uses: actions/upload-artifact@v3 + with: + name: rust-peer + path: target/${{ steps.profile.outputs.profile }}/particle-node diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 58e8bf9cfa..0a2237c7de 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -3,10 +3,25 @@ name: "e2e" on: pull_request: paths-ignore: - - "!**.md" + - "**.md" + - ".github/**" + - "!.github/workflows/e2e.yml" + - "!.github/workflows/snapshot.yml" + - "!.github/workflows/container.yml" + types: + - "labeled" + - "synchronize" + - "opened" + - "reopened" push: branches: - "master" + paths-ignore: + - "**.md" + - ".github/**" + - "!.github/workflows/e2e.yml" + - "!.github/workflows/snapshot.yml" + - "!.github/workflows/container.yml" concurrency: group: "${{ github.workflow }}-${{ github.ref }}" @@ -14,16 +29,19 @@ concurrency: jobs: rust-peer: - uses: ./.github/workflows/snapshot.yml + if: > + github.event_name == 'push' || + ( + contains(github.event.pull_request.labels.*.name, 'e2e') && + !github.event.pull_request.head.repo.fork + ) + uses: ./.github/workflows/build.yml with: - image-name: "docker.fluence.dev/rust-peer" ref: ${{ github.ref }} rust-peer-flavours: name: "rust-peer" - needs: rust-peer - strategy: matrix: flavour: @@ -36,37 +54,46 @@ jobs: flavour: "${{ matrix.flavour }}" rust-peer-sha: "${{ needs.rust-peer.outputs.rust-peer-sha }}" + rust-peer-snapshot: + name: "rust-peer" + needs: rust-peer + uses: ./.github/workflows/container.yml + with: + image-name: "docker.fluence.dev/rust-peer" + flavour: "minimal" + rust-peer-sha: "${{ needs.rust-peer.outputs.rust-peer-sha }}" + js-client: needs: - - rust-peer + - rust-peer-snapshot uses: fluencelabs/js-client/.github/workflows/tests.yml@master with: - rust-peer-image: "${{ needs.rust-peer.outputs.rust-peer-image }}" + rust-peer-image: "${{ needs.rust-peer-snapshot.outputs.rust-peer-image }}" aqua-playground: needs: - - rust-peer + - rust-peer-snapshot uses: fluencelabs/aqua-playground/.github/workflows/tests.yml@master with: - rust-peer-image: "${{ needs.rust-peer.outputs.rust-peer-image }}" + rust-peer-image: "${{ needs.rust-peer-snapshot.outputs.rust-peer-image }}" registry: needs: - - rust-peer + - rust-peer-snapshot uses: fluencelabs/registry/.github/workflows/tests.yml@main with: - rust-peer-image: "${{ needs.rust-peer.outputs.rust-peer-image }}" + rust-peer-image: "${{ needs.rust-peer-snapshot.outputs.rust-peer-image }}" fluence-cli: needs: - - rust-peer + - rust-peer-snapshot uses: fluencelabs/fluence-cli/.github/workflows/tests.yml@main with: - rust-peer-image: "${{ needs.rust-peer.outputs.rust-peer-image }}" + rust-peer-image: "${{ needs.rust-peer-snapshot.outputs.rust-peer-image }}" status: + name: "e2e status" runs-on: ubuntu-latest - if: always() needs: - fluence-cli - registry diff --git a/.github/workflows/ci.yml b/.github/workflows/run-tests.yml similarity index 94% rename from .github/workflows/ci.yml rename to .github/workflows/run-tests.yml index 0802d81555..4cc5eacac2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/run-tests.yml @@ -1,4 +1,4 @@ -name: Run tests +name: "test" on: pull_request: diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index f4c74f4468..4f1073dc64 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -1,10 +1,11 @@ -name: Publish snapshot +# Compatibility workflow +name: "Publish snapshot" on: workflow_call: inputs: ref: - description: "GitHub ref to checkout to" + description: "git ref to checkout to" type: string default: "master" image-name: @@ -14,6 +15,7 @@ on: cargo-dependencies: description: "Cargo dependencies map" type: string + default: "null" outputs: rust-peer-image: description: "rust-peer snapshot image" @@ -24,76 +26,11 @@ on: jobs: build: + uses: ./.github/workflows/build.yml + with: + ref: ${{ inputs.ref }} name: "Build" - runs-on: builder - timeout-minutes: 60 - - outputs: - sha256: "${{ steps.sha.outputs.sha256 }}" - - steps: - - name: Checkout rust-peer - uses: actions/checkout@v3 - with: - repository: fluencelabs/rust-peer - ref: ${{ inputs.ref }} - - - name: Get PR labels - id: labels - uses: joerick/pr-labels-action@v1.0.8 - - - name: Setup Rust toolchain - uses: actions-rust-lang/setup-rust-toolchain@v1 - - - name: Set profile - id: profile - run: | - if [[ -n "$GITHUB_PR_LABEL_PROFILING" ]]; then - echo "profile=profiling" >> $GITHUB_OUTPUT - echo "flags=--profile=profiling --features particle-node/dhat-heap" >> $GITHUB_OUTPUT - else - echo "profile=release" >> $GITHUB_OUTPUT - echo "flags=--profile=release" >> $GITHUB_OUTPUT - fi - - - name: Set dependencies - if: inputs.cargo-dependencies != '' - uses: fluencelabs/github-actions/cargo-set-dependency@main - with: - dependencies: ${{ inputs.cargo-dependencies }} - - - name: Generate snapshot version - id: version - uses: fluencelabs/github-actions/generate-snapshot-id@main - - - name: Set version - id: snapshot - uses: fluencelabs/github-actions/cargo-publish-snapshot@main - with: - id: ${{ steps.version.outputs.id }} - publish: false - - - name: Run cargo build - env: - RUSTFLAGS: "--cfg tokio_unstable" - run: cargo build ${{ steps.profile.outputs.flags }} -p particle-node - - - name: Calculate SHA256 - id: sha - working-directory: ./target/${{ steps.profile.outputs.profile }} - run: | - # Calculate sha256 - du -hs particle-node - sha256sum particle-node - sha=($(sha256sum particle-node)) - echo "sha256=${sha}" >> $GITHUB_OUTPUT - - - name: Upload rust-peer binary - uses: actions/upload-artifact@v3 - with: - name: rust-peer - path: target/${{ steps.profile.outputs.profile }}/particle-node - + container: needs: build uses: ./.github/workflows/container.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index eb55c98fc7..362eb5db14 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,46 +1,23 @@ -name: Run tests +name: "Run tests with workflow_call" on: workflow_call: inputs: ref: - description: "GitHub ref to checkout to" + description: "git ref to checkout to" type: string default: "master" cargo-dependencies: description: "Cargo dependencies map" type: string + default: "null" -jobs: - lint: - name: cargo lints - runs-on: builder - steps: - - name: Checkout sources - uses: actions/checkout@v3 - with: - repository: fluencelabs/rust-peer - ref: ${{ inputs.ref }} - - - name: Setup Rust toolchain - uses: actions-rust-lang/setup-rust-toolchain@v1 - - - name: Set dependencies - if: inputs.cargo-dependencies != '' - uses: fluencelabs/github-actions/cargo-set-dependency@main - with: - dependencies: ${{ inputs.cargo-dependencies }} - - - name: Run cargo fmt - run: cargo fmt --all -- --check - - - name: Run cargo clippy - env: - RUSTFLAGS: "--cfg tokio_unstable" - run: cargo clippy -Z unstable-options --all +env: + RUSTFLAGS: "-D warnings --cfg tokio_unstable" +jobs: tests: - name: cargo nextest + name: "cargo nextest" runs-on: builder timeout-minutes: 60 @@ -55,20 +32,14 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1 - name: Set dependencies - if: inputs.cargo-dependencies != '' + if: inputs.cargo-dependencies != 'null' uses: fluencelabs/github-actions/cargo-set-dependency@main with: dependencies: ${{ inputs.cargo-dependencies }} - - name: Install cargo-nextest - uses: baptiste0928/cargo-install@v1.3.1 - with: - crate: cargo-nextest - version: 0.9.22 + - uses: taiki-e/install-action@nextest - name: Run cargo nextest - env: - RUSTFLAGS: "--cfg tokio_unstable" run: cargo nextest run --release --all-features --profile ci - name: Upload test report @@ -78,3 +49,9 @@ jobs: name: cargo nextest report path: target/nextest/ci/junit.xml reporter: java-junit + + - name: Run cargo fmt + run: cargo fmt --all -- --check + + - name: Run cargo clippy + run: cargo clippy -Z unstable-options --all