From fe1a87d1a5965d8bc3f4fb8a7cca9cc1cce033c9 Mon Sep 17 00:00:00 2001 From: canonbrother Date: Thu, 21 Mar 2024 17:17:41 +0800 Subject: [PATCH] Run Jellyfish Tests in parallel (#2865) * extend timeout * matrix * revert timeout * reflow jf ci * docker build from bin on the fly * move artifact to build * package * global env.TARGET --- .github/workflows/tests-jellyfish.yml | 95 +++++++++++++++++++++++---- 1 file changed, 83 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests-jellyfish.yml b/.github/workflows/tests-jellyfish.yml index a4735abd5a8..9f396c70faa 100644 --- a/.github/workflows/tests-jellyfish.yml +++ b/.github/workflows/tests-jellyfish.yml @@ -11,36 +11,107 @@ concurrency: cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: - BUILD_VERSION: latest # Computed + BUILD_VERSION: latest + TARGET: x86_64-pc-linux-gnu + MAKE_DEBUG: 0 + GIT_VERSION: 1 jobs: + build: + runs-on: ubuntu-latest + container: defi/ain-builder:latest + env: + CARGO_INCREMENTAL: 0 + steps: + - uses: actions/checkout@v4 + - run: git config --global --add safe.directory '*' + + - name: Populate environment + run: ./make.sh ci-export-vars + + - name: Setup dependencies + run: ./make.sh ci-setup-deps + + - name: Setup user dependencies + run: ./make.sh ci-setup-user-deps + + - name: Restore cpp build cache + id: cpp-cache-restore + uses: actions/cache/restore@v3 + with: + path: | + ./build/depends + ./build/src + ~/.ccache + key: cpp-${{ env.TARGET }}-${{ env.BUILD_TYPE }} + + - name: Rust build cache + uses: Swatinem/rust-cache@v2 + id: rust-cache-restore + with: + workspaces: lib -> ../build/lib/target + save-if: ${{ github.ref == 'refs/heads/master' }} + shared-key: ${{ env.TARGET }} + + - name: Build binaries + run: ./make.sh build + + - name: Pack binaries + run: ./make.sh deploy && ./make.sh package + + - name: Upload binaries + uses: actions/upload-artifact@v3 + with: + name: defi-bins + path: ./build/defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}.${{ env.PKG_TYPE }} + test: name: Test runs-on: ubuntu-latest + needs: [build] + strategy: + fail-fast: false + matrix: + instance: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] + + env: + GH_INSTANCE_TOTAL: 10 steps: - uses: actions/checkout@v4 + + - name: Populate environment + run: ./make.sh ci-export-vars + + - name: Download binaries + uses: actions/download-artifact@v3 with: - repository: JellyfishSDK/jellyfish - ref: 'main' + name: defi-bins + path: ./build/ + + - name: Unpack binaries + run: tar -xvzf ./build/defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}.${{ env.PKG_TYPE }} -C ./build/ + + - name: Build defi image + run: rm .dockerignore && ./make.sh docker-build-from-binaries - uses: actions/checkout@v4 with: - path: defichain + repository: JellyfishSDK/jellyfish + ref: 'main' + path: jellyfish - uses: actions/setup-node@v3 with: node-version: '18' - - name: Populate environment - run: cd defichain && GIT_VERSION=1 ./make.sh ci-export-vars - - - name: Build and setup - run: "cd defichain && docker build -t test-build-container - -f ./contrib/dockerfiles/x86_64-pc-linux-gnu.dockerfile ." - - name: Run tests run: | + cd jellyfish npm ci npm run compile - DEFICHAIN_DOCKER_IMAGE=test-build-container npm run ci:test -- --testTimeout=600000 + set -e; ver=${{ env.BUILD_VERSION }} + DEFICHAIN_DOCKER_IMAGE=defichain-${{ env.TARGET }}:${ver} npm run ci:test -- --testTimeout=600000 + env: + GH_INSTANCE_INDEX: ${{ matrix.instance }} +