From 07347e819ab561940c7908984282ceb22f43e741 Mon Sep 17 00:00:00 2001 From: Flouse <1297478+Flouse@users.noreply.github.com> Date: Wed, 16 Aug 2023 13:09:57 +0000 Subject: [PATCH] refactor(CI): use reusable `build-axon' job to reduce time consuming --- .github/workflows/openzeppelin_test_11.yml | 23 +++++++++-- .github/workflows/openzeppelin_test_16_19.yml | 23 +++++++++-- .github/workflows/openzeppelin_test_6_10.yml | 23 +++++++++-- .github/workflows/v3_core_test.yml | 23 +++++++++-- .github/workflows/web3_compatible.yml | 39 +++++++++++++++---- 5 files changed, 107 insertions(+), 24 deletions(-) diff --git a/.github/workflows/openzeppelin_test_11.yml b/.github/workflows/openzeppelin_test_11.yml index 2955e4f09..72d350396 100644 --- a/.github/workflows/openzeppelin_test_11.yml +++ b/.github/workflows/openzeppelin_test_11.yml @@ -12,12 +12,19 @@ on: required: true jobs: + # Build Axon and cache the binary + build-axon: + uses: ./.github/workflows/build.yml + openzeppelin-contracts-1: + needs: build-axon strategy: - fail-fast: false matrix: - net: ["axon"] - runs-on: ubuntu-latest + # Supported GitHub-hosted runners and hardware resources + # see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources + os: [ubuntu-22.04] + fail-fast: false + runs-on: ${{ matrix.os }} outputs: output-sha: ${{ steps.escape_multiple_lines_test_inputs.outputs.result }} steps: @@ -90,9 +97,16 @@ jobs: restore-keys: | ${{ runner.os }}-node_modules- + - name: Cache of the axon binary + uses: actions/cache@v3 + with: + path: | + target/debug/axon + target/release/axon + key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-axon-${{ github.sha }} + - name: Deploy Local Network of Axon run: | - cargo build rm -rf ./devtools/chain/data ./target/debug/axon run --config devtools/chain/config.toml --genesis devtools/chain/genesis_single_node.json > /tmp/log 2>&1 & @@ -118,6 +132,7 @@ jobs: with: name: jfoa-build-reports-${{ runner.os }} path: openzeppelin-contracts/mochawesome-report/ + finally: name: Finally needs: [ openzeppelin-contracts-1 ] diff --git a/.github/workflows/openzeppelin_test_16_19.yml b/.github/workflows/openzeppelin_test_16_19.yml index 19a0c3a0e..521adef55 100644 --- a/.github/workflows/openzeppelin_test_16_19.yml +++ b/.github/workflows/openzeppelin_test_16_19.yml @@ -12,12 +12,19 @@ on: required: true jobs: + # Build Axon and cache the binary + build-axon: + uses: ./.github/workflows/build.yml + openzeppelin-contracts-1: + needs: build-axon strategy: - fail-fast: false matrix: - net: ["axon"] - runs-on: ubuntu-latest + # Supported GitHub-hosted runners and hardware resources + # see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources + os: [ubuntu-22.04] + fail-fast: false + runs-on: ${{ matrix.os }} outputs: output-sha: ${{ steps.escape_multiple_lines_test_inputs.outputs.result }} steps: @@ -90,9 +97,16 @@ jobs: restore-keys: | ${{ runner.os }}-node_modules- + - name: Cache of the axon binary + uses: actions/cache@v3 + with: + path: | + target/debug/axon + target/release/axon + key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-axon-${{ github.sha }} + - name: Deploy Local Network of Axon run: | - cargo build rm -rf ./devtools/chain/data ./target/debug/axon run --config devtools/chain/config.toml --genesis devtools/chain/genesis_single_node.json > /tmp/log 2>&1 & @@ -133,6 +147,7 @@ jobs: with: name: jfoa-build-reports-${{ runner.os }} path: openzeppelin-contracts/mochawesome-report/ + finally: name: Finally needs: [ openzeppelin-contracts-1 ] diff --git a/.github/workflows/openzeppelin_test_6_10.yml b/.github/workflows/openzeppelin_test_6_10.yml index 7d8983331..500494fb9 100644 --- a/.github/workflows/openzeppelin_test_6_10.yml +++ b/.github/workflows/openzeppelin_test_6_10.yml @@ -12,12 +12,19 @@ on: required: true jobs: + # Build Axon and cache the binary + build-axon: + uses: ./.github/workflows/build.yml + openzeppelin-contracts-1: + needs: build-axon strategy: - fail-fast: false matrix: - net: ["axon"] - runs-on: ubuntu-latest + # Supported GitHub-hosted runners and hardware resources + # see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources + os: [ubuntu-22.04] + fail-fast: false + runs-on: ${{ matrix.os }} outputs: output-sha: ${{ steps.escape_multiple_lines_test_inputs.outputs.result }} steps: @@ -90,9 +97,16 @@ jobs: restore-keys: | ${{ runner.os }}-node_modules- + - name: Cache of the axon binary + uses: actions/cache@v3 + with: + path: | + target/debug/axon + target/release/axon + key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-axon-${{ github.sha }} + - name: Deploy Local Network of Axon run: | - cargo build rm -rf ./devtools/chain/data ./target/debug/axon run --config devtools/chain/config.toml --genesis devtools/chain/genesis_single_node.json > /tmp/log 2>&1 & - name: Run prepare @@ -138,6 +152,7 @@ jobs: with: name: jfoa-build-reports-${{ runner.os }} path: openzeppelin-contracts/mochawesome-report/ + finally: name: Finally needs: [ openzeppelin-contracts-1 ] diff --git a/.github/workflows/v3_core_test.yml b/.github/workflows/v3_core_test.yml index 395ae08de..488b22aca 100644 --- a/.github/workflows/v3_core_test.yml +++ b/.github/workflows/v3_core_test.yml @@ -12,12 +12,19 @@ on: required: true jobs: + # Build Axon and cache the binary + build-axon: + uses: ./.github/workflows/build.yml + v3-core-test: + needs: build-axon strategy: - fail-fast: false matrix: - net: ["axon"] - runs-on: ubuntu-latest + # Supported GitHub-hosted runners and hardware resources + # see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources + os: [ubuntu-22.04] + fail-fast: false + runs-on: ${{ matrix.os }} outputs: output-sha: ${{ steps.escape_multiple_lines_test_inputs.outputs.result }} steps: @@ -79,9 +86,16 @@ jobs: - id: yarn-cache run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + - name: Cache of the axon binary + uses: actions/cache@v3 + with: + path: | + target/debug/axon + target/release/axon + key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-axon-${{ github.sha }} + - name: Deploy Local Network of Axon run: | - cargo build rm -rf ./devtools/chain/data ./target/debug/axon run --config devtools/chain/config.toml --genesis devtools/chain/genesis_single_node.json > /tmp/log 2>&1 & - name: Install dependencies @@ -119,6 +133,7 @@ jobs: with: name: jfoa-build-reports-${{ runner.os }} path: v3-core/mochawesome-report/ + finally: name: Finally needs: [ v3-core-test ] diff --git a/.github/workflows/web3_compatible.yml b/.github/workflows/web3_compatible.yml index 6b67a3462..cfe41f4c4 100644 --- a/.github/workflows/web3_compatible.yml +++ b/.github/workflows/web3_compatible.yml @@ -14,13 +14,20 @@ on: required: true jobs: + # Build Axon and cache the binary + build-axon: + uses: ./.github/workflows/build.yml + dispatch-web3-compatible: + needs: build-axon strategy: - fail-fast: false matrix: - net: ["axon"] + # Supported GitHub-hosted runners and hardware resources + # see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources + os: [ubuntu-22.04] + fail-fast: false + runs-on: ${{ matrix.os }} if: contains(github.event_name, 'workflow_dispatch') - runs-on: ubuntu-latest outputs: output-sha: ${{ steps.escape_multiple_lines_test_inputs.outputs.result }} steps: @@ -91,9 +98,15 @@ jobs: key: ${{ runner.os }}-node_modules-${{ hashFiles('/home/runner/work/**/package-lock.json', '/home/runner/work/**/yarn.lock') }} restore-keys: | ${{ runner.os }}-node_modules- + - name: Cache of the axon binary + uses: actions/cache@v3 + with: + path: | + target/debug/axon + target/release/axon + key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-axon-${{ github.sha }} - name: Deploy Local Network of Axon run: | - cargo build rm -rf ./devtools/chain/data ./target/debug/axon run --config devtools/chain/config.toml --genesis devtools/chain/genesis_single_node.json > /tmp/log 2>&1 & - name: Run Test @@ -111,6 +124,7 @@ jobs: with: name: jfoa-build-reports-${{ runner.os }} path: axon-test/mochawesome-report/ + finally: name: Finally needs: [ dispatch-web3-compatible ] @@ -141,14 +155,17 @@ jobs: }) web3-compatible: + needs: build-axon strategy: - fail-fast: false matrix: - net: ["axon"] + # Supported GitHub-hosted runners and hardware resources + # see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources + os: [ubuntu-22.04] + fail-fast: false + runs-on: ${{ matrix.os }} if: | (contains(fromJson('["dependabot[bot]" ]'), github.actor) && github.event_name == 'pull_request') || (contains(github.event_name, 'push') && github.ref == 'refs/heads/main' ) - runs-on: ubuntu-latest steps: - name: Git checkout uses: actions/checkout@v3 @@ -172,9 +189,15 @@ jobs: key: ${{ runner.os }}-node_modules-${{ hashFiles('/home/runner/work/**/package-lock.json', '/home/runner/work/**/yarn.lock') }} restore-keys: | ${{ runner.os }}-node_modules- + - name: Cache of the axon binary + uses: actions/cache@v3 + with: + path: | + target/debug/axon + target/release/axon + key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-axon-${{ github.sha }} - name: Deploy Local Network of Axon run: | - cargo build rm -rf ./devtools/chain/data ./target/debug/axon run --config devtools/chain/config.toml --genesis devtools/chain/genesis_single_node.json > /tmp/log 2>&1 & - name: Run Test