From 9c858074fd049c997382d86aaeff0a9e8ab927ad Mon Sep 17 00:00:00 2001 From: Igor Sikachyna Date: Thu, 14 Nov 2024 07:14:57 -0500 Subject: [PATCH] BLOCK-2590 - Added PR test workflow --- .github/workflows/pr.yml | 178 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 .github/workflows/pr.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 00000000..b28b17de --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,178 @@ +name: "Validate build and run tests" +on: + pull_request: + types: + - opened + - synchronize + - reopened + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + start-runner: + name: Start Runner + runs-on: ubuntu-latest + steps: + - name: Get Token + id: application_token + uses: peter-murray/workflow-application-token-action@v2 + with: + application_id: ${{ secrets.APPLICATION_ID }} + application_private_key: ${{ secrets.APPLICATION_PRIVATE_KEY }} + + - name: Trigger start-runner job + uses: convictional/trigger-workflow-and-wait@v1.6.5 + with: + owner: ultraio + repo: blockchain-manager + github_token: ${{ steps.application_token.outputs.token }} + workflow_file_name: start-runner.yml + job-cleanup: + needs: start-runner + name: "Cleanup" + timeout-minutes: 5 + runs-on: "self-hosted" + steps: + - name: "Cleanup Previous Run" + run: | + sudo rm -rf ./* || true + sudo rm -rf ./.??* || true + sudo rm -rf $GITHUB_WORKSPACE || true + mkdir $GITHUB_WORKSPACE + build-contracts: + needs: [start-runner, job-cleanup] + name: "Build contracts" + timeout-minutes: 10 + runs-on: "self-hosted" + container: + # This repository can be found / pushed to in: ultraio/eosio-docker-starter + image: quay.io/ultra.io/eosio-docker-starter:5.0.0 + options: >- + --init + --cpus 8 + permissions: + contents: 'read' + id-token: 'write' + steps: + - name: Get Token + id: application_token + uses: peter-murray/workflow-application-token-action@v2 + with: + application_id: ${{ secrets.APPLICATION_ID }} + application_private_key: ${{ secrets.APPLICATION_PRIVATE_KEY }} + + - name: "Set env vars" + run: | + echo "JOBS=8" >> $GITHUB_ENV + echo "ULTRA_PATH=/__w/eos-evm-contract/eos-evm-contract/ultra/" >> $GITHUB_ENV + + # Update dependencies + - name: 'Update dependencies' + run: | + apt-get update -y \ + && apt-get install tree clang jq xxd -y + + - name: Checkout Repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: 'recursive' + + # Download latest version of CDT from releases + - uses: robinraju/release-downloader@v1.8 + with: + repository: "ultraio/eosio.cdt" + latest: true + fileName: "*.deb" + out-file-path: "./ultra/cdt" + token: '${{ steps.application_token.outputs.token }}' + + # Install EOSIO.CDT Debian Image + - name: Install EOSIO.CDT Debian Image + run: apt install ./ultra/cdt/*.deb -y + + - name: Build EOS EVM Contract + run: .github/workflows/build-contract.sh + env: + DWITH_TEST_ACTIONS: true + + # Clone `eosio.contracts` repo + - uses: actions/checkout@v3 + name: "Clone eosio.contracts" + with: + repository: 'ultraio/eosio.contracts' + token: '${{ steps.application_token.outputs.token }}' + path: './ultra/eosio.contracts' + submodules: 'recursive' + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref }} + + # Download latest `eosio.contracts` release + - uses: robinraju/release-downloader@v1.8 + with: + repository: "ultraio/eosio.contracts" + latest: true + fileName: "*.tar.gz" + out-file-path: "./ultra/eosio.contracts" + token: '${{ steps.application_token.outputs.token }}' + + - name: Extract eosio.contracts.tar.gz + run: | + ls -l + ls -l ./ultra/eosio.contracts + mkdir -p ./ultra/eosio.contracts/build + tar -xf ./ultra/eosio.contracts/eosio-contracts-*.tar.gz -C ./ultra/eosio.contracts/build + ls -l ./ultra/eosio.contracts/build + + # Download latest eosio + - name: Download latest eosio + uses: dsaltares/fetch-gh-release-asset@master + with: + repo: 'ultraio/eosio' + regex: true + # match eosio-***.deb + # don't match eosio-***-ubuntu20.deb + file: eosio-.*\.deb(?> $GITHUB_OUTPUT + id: extract_branch + + - name: "Clone Ultratest2 with main" + uses: actions/checkout@v3 + with: + repository: "ultraio/ultratest2" + token: "${{ steps.application_token.outputs.token }}" + path: "./ultra/ultratest2" + fetch-depth: 0 + ref: "main" + + - name: "Check if ultratest2 has branch with the same name" + continue-on-error: true + run: cd ./ultra/ultratest2 && git checkout ${{ steps.extract_branch.outputs.branch }} + + - name: Install ultratest2 + working-directory: ./ultra/ultratest2 + run: | + npm install + npm link --force + + - name: Run eosio.contracts ultratests2 + if: always() && !cancelled() + working-directory: ./ + shell: bash + run: ultratest2 --contracts-dir-path=$ULTRA_PATH/eosio.contracts/build/contracts