Skip to content

Commit

Permalink
feat: update e2e tests run workflow (#79)
Browse files Browse the repository at this point in the history
* feat: update e2e tests run workflow

* chore: update e2e tests workflow permissions and remove unneeded passed vars

* feat: merge avs e2e tests run job to e2e-tests workflow

* ci: fix reusable workflow invocation

* fix: fix e2e workflow inputs usage

* fix: add missing submodules pull for run-e2e-tests job

* fix: e2e repo checkout reference input

* Feat: Add step to check if custom branch name exists in e2e repository and use it instead of default if true

* ci: fix env vars reference

* ci: fix custom e2e repo branch conditional

* ci: fix wrong bash syntax using ` which where interpreted as commands

* update task finalization & completeness validations

* chore: fix formatting issue

---------

Co-authored-by: GonCer <[email protected]>
  • Loading branch information
tenequm and goncer authored Apr 3, 2024
1 parent 32e8dcc commit ee58c46
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 8,243 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ jobs:
with:
env: fungible
version: ${{ needs.init.outputs.GLOBAL_VERSION }}

run-e2e-test:
name: Run e2e tests
needs: [init, build-and-test]
uses: ./.github/workflows/reusable-e2e-tests.yml
secrets: inherit
permissions:
contents: read
actions: read
checks: write
with:
globalVersion: ${{ needs.init.outputs.GLOBAL_VERSION }}

clean-up-fungible:
name: Delete fungible environment
Expand Down
110 changes: 0 additions & 110 deletions .github/workflows/reusable-avs-tests.yml

This file was deleted.

218 changes: 105 additions & 113 deletions .github/workflows/reusable-e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -1,155 +1,147 @@
name: Run e2e
name: Run e2e tests
on:
pull_request:
types: [opened, synchronize, closed]

workflow_call:
inputs:
e2eBranch:
type: string
required: false
substrateNodeVersion:
type: string
required: false
default: 'eth-rollup-develop'
globalVersion:
type: string
required: false
default: '8dd0c81aa88b967334d001d8cae031f8799a189f'
workflow_dispatch:
inputs:
e2eBranch:
description: 'branch name for e2e tests'
required: false
default: 'eth-rollup-develop'

nodeVersion:
description: 'image tag for rollup-node'
required: false
default: 'eth-rollup-develop'

avsVersion:
description: 'image tag for avs-aggregator and avs-finalizer'
required: false
default: '8dd0c81aa88b967334d001d8cae031f8799a189f'
inputs:
e2eBranch:
type: string
required: false
substrateNodeVersion:
type: string
required: false
default: 'eth-rollup-develop'
globalVersion:
type: string
required: false
default: '8dd0c81aa88b967334d001d8cae031f8799a189f'

permissions:
contents: write
id-token: write
deployments: write
contents: read
actions: read
checks: write

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
CURRENT_BRANCH: ${{ github.head_ref || github.ref_name }}
DEFAULT_E2E_REPO_BRANCH: eth-rollup-develop
AVS_AGGREGATOR_VERSION: ${{ inputs.globalVersion }}
AVS_FINALIZER_VERSION: ${{ inputs.globalVersion }}
ROLLUP_SEQUENCER_VERSION: ${{ inputs.globalVersion }}
ROLLUP_UPDATER_VERSION: ${{ inputs.globalVersion }}
MANGATA_NODE_VERSION: ${{ inputs.substrateNodeVersion }}

jobs:
init:
name: Set global version
if: github.event.action != 'closed'
run-e2e-tests:
runs-on: ubuntu-latest
outputs:
GLOBAL_VERSION: ${{ steps.set_vars.outputs.GLOBAL_VERSION }}
NODE_VERSION: ${{ steps.set_vars.outputs.NODE_VERSION }}
AVS_VERSION: ${{ steps.set_vars.outputs.AVS_VERSION }}
steps:
- uses: actions/checkout@v4

- name: Load environment variables
uses: xom9ikk/dotenv@v2
with:
path: ./
load-mode: strict

- name: Set global version
id: set_vars
run: |
echo "GLOBAL_VERSION=${{ github.sha }}" >> $GITHUB_OUTPUT
echo "NODE_VERSION=${{ inputs.nodeVersion || env.MANGATA_NODE_VERSION }}" >> $GITHUB_OUTPUT
echo "AVS_VERSION=${{ inputs.avsVersion || '8dd0c81aa88b967334d001d8cae031f8799a189f' }}" >> $GITHUB_OUTPUT
#build-and-test:
#needs: [init]
#name: Build
#uses: ./.github/workflows/reusable-build-and-test.yml
#secrets: inherit
#with:
#version: ${{ needs.init.outputs.GLOBAL_VERSION }}

start-env:
runs-on: [ubuntu-latest]
needs: [init]
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'

#- name: build finalizer
# working-directory: avs-finalizer/
# run: cargo +stable build --release
submodules: recursive

- name: Start env
run: docker compose up -d --wait

- name: Use custom branch in e2e tests repository if it exists, otherwise use default branch
id: e2e
run: |
export AVS_AGGREGATOR_VERSION=${{ needs.init.outputs.AVS_VERSION }}
export AVS_FINALIZER_VERSION=${{ needs.init.outputs.AVS_VERSION }}
export MANGATA_NODE_VERSION=${{ needs.init.outputs.NODE_VERSION }}
docker compose build sequencer updater
docker compose up --wait
# - name: Sleep for 2 minutes
# run: sleep 120s

- name: docker ps
run: docker ps

- name: E2E- Get branch name
id: branch-name
uses: tj-actions/[email protected]

- name: E2E- Calculate if run e2e feature branch or main.
run: |
echo DEFAULT: E2E test will run with: $E2EBRANCHNAME
echo "Running on: ${{ steps.branch-name.outputs.current_branch }}"
if [ -n "$(git ls-remote --heads https://github.com/mangata-finance/mangata-e2e.git ${{ steps.branch-name.outputs.current_branch }} --force --quiet)" ]; then echo "E2EBRANCHNAME=${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_ENV; echo "MATCH - OK" ; elif [ "${{ github.base_ref }}" == "main" ]; then echo "E2EBRANCHNAME=eth-rollup-develop" >> $GITHUB_ENV; echo "MATCH - OK" ; elif [ -n "$(git ls-remote --heads https://github.com/mangata-finance/mangata-e2e.git ${{ github.base_ref }} --force --quiet)" ]; then echo "E2EBRANCHNAME=${{ github.base_ref }}" >> $GITHUB_ENV; echo "MATCH - OK" ; fi
- name: Decide if main - branch or parameter
run: echo "E2EBRANCHNAME=${{ inputs.e2eBranch || env.E2EBRANCHNAME }}" >> $GITHUB_ENV

# Implementation of this conditional action was taken from here:
# https://github.com/actions/checkout/issues/512#issuecomment-1264735491
# This condition check if the input 'e2eBranch' is empty, and if it is, it checks if the current branch name exists in 'mangata-e2e' repository
if [[ -z "${{ inputs.e2eBranch }}" ]]; then
# Checking if current branch name exists in 'mangata-e2e' repository
if git ls-remote --heads --quiet --exit-code https://github.com/mangata-finance/mangata-e2e.git ${{ env.CURRENT_BRANCH }}; then
echo "Using custom '${{ env.CURRENT_BRANCH }}' branch as it exists in 'mangata-e2e' repository"
echo "BRANCH=${{ env.CURRENT_BRANCH }}" >> $GITHUB_OUTPUT
else
echo "Custom branch '${{ env.CURRENT_BRANCH }}' does not exist in 'mangata-e2e' repository, using default '${{ env.DEFAULT_E2E_REPO_BRANCH }}' branch"
echo "BRANCH=${{ env.DEFAULT_E2E_REPO_BRANCH }}" >> $GITHUB_OUTPUT
fi
else
echo "Using '${{ inputs.e2eBranch }}' branch fo 'mangata-e2e' repository as it was provided in the input"
echo "BRANCH=${{ inputs.e2eBranch }}" >> $GITHUB_OUTPUT
fi
- name: Checkout tests
uses: actions/checkout@v4
with:
repository: mangata-finance/mangata-e2e
ref: "${{ env.E2EBRANCHNAME }}"
ref: ${{ steps.e2e.outputs.BRANCH }}
path: e2eTests

- name: Install e2e tests dependencies
working-directory: e2eTests
run: yarn install

# - name: restart sequencer
# run: docker restart rollup-sequencer-1

- name: Run tests
working-directory: e2eTests
run: "yarn test-rollup"
env:
NODE_OPTIONS: --max_old_space_size=12288
run: yarn test-rollup

- name: Get Seq logs
- name: Get sequencer logs
if: success() || failure()
run: docker logs rollup-sequencer-1


- name: Get updater logs
if: success() || failure()
run: docker logs rollup-updater-1

- name: Test Report
uses: dorny/[email protected]
continue-on-error: true
if: success() || failure() # run this step even if previous step failed
uses: dorny/[email protected]
if: success() || failure()
with:
name: E2E report test-rollup # Name of the check run which will be created
path: e2eTests/reports/*.xml # Path to test results
reporter: jest-junit # Format of test results
name: E2E report test-rollup
path: e2eTests/reports/*.xml
reporter: jest-junit

run-avs-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Stop env
if: success() || failure() # run this step even if previous step failed
- name: Start env
run: docker compose up -d --wait

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: build and copy contracts
working-directory: contracts
run: |
export AVS_AGGREGATOR_VERSION=8dd0c81aa88b967334d001d8cae031f8799a189f
export AVS_FINALIZER_VERSION=8dd0c81aa88b967334d001d8cae031f8799a189f
docker compose down -v
forge build
cp out/FinalizerTaskManager.sol/FinalizerTaskManager.json ../avs-finalizer/tests/abis/FinalizerTaskManager.json
cp out/IndexRegistryStorage.sol/IndexRegistryStorage.json ../avs-finalizer/tests/abis/IndexRegistryStorage.json
cp out/RegistryCoordinator.sol/RegistryCoordinator.json ../avs-finalizer/tests/abis/RegistryCoordinator.json
cp out/RegistryCoordinatorStorage.sol/RegistryCoordinatorStorage.json ../avs-finalizer/tests/abis/RegistryCoordinatorStorage.json
- name: FINALIZER tests - install deps
working-directory: avs-finalizer/tests/
run: yarn install

- name: FINALIZER tests - run tests
working-directory: avs-finalizer/tests/
run: yarn test

- name: Get avs-aggregator logs
if: success() || failure()
run: docker logs rollup-avs-aggregator-1

- name: Get avs-finalizer logs
if: success() || failure()
run: docker logs rollup-avs-finalizer-1



- name: Get anvil logs
if: success() || failure()
run: docker logs rollup-anvil-1

- run: docker ps
1 change: 1 addition & 0 deletions avs-finalizer/tests/DockerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class DockerUtils{
this.container = undefined;
this.containerName = "";
this.FINALIZER_IMAGE = "mangatasolutions/avs-finalizer:" + process.env.AVS_FINALIZER_VERSION || 'local';
console.info("Using image: " + this.FINALIZER_IMAGE);
}
async startContainer(image: string = this.FINALIZER_IMAGE, env = this.finalizerLocalEnvironment) {
this.containerName = image;
Expand Down
Loading

0 comments on commit ee58c46

Please sign in to comment.