Run live tests on pending multisig #162
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run live tests on pending multisig | |
on: | |
workflow_dispatch: | |
inputs: | |
api: | |
description: "Safe API endpoint" | |
required: false | |
type: string | |
default: "https://safe-transaction-mainnet.safe.global" | |
tx: | |
description: "Multisig transaction safe tx hash" | |
required: true | |
type: string | |
callback: | |
description: "URL to trigger when run starts and finishes" | |
required: false | |
default: "https://risk.gearbox.foundation/api/ci/store" | |
type: string | |
multisig: | |
description: "Multisig contract address" | |
default: "0xA7D5DDc1b8557914F158076b228AA91eF613f1D5" | |
required: false | |
type: string | |
env: | |
CI: true | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
# This env variable will be modified by multicig script, but in case of early failure, pass value as-is to FAIL callback | |
- name: Set default output | |
run: | | |
echo "EXECUTED_TRANSACTIONS=${{ inputs.tx }}" >> "$GITHUB_ENV" | |
- name: Trigger callback on start | |
if: github.event.inputs.callback != '' | |
run: | | |
curl \ | |
-H "Authorization: Bearer ${{ secrets.RISK_API_TOKEN }}" \ | |
-X GET \ | |
"${{ inputs.callback }}?run_id=${{ github.run_id }}&tx=${{ env.EXECUTED_TRANSACTIONS }}&status=RUN" | |
- name: Install Foundry | |
uses: foundry-rs/foundry-toolchain@v1 | |
with: | |
version: nightly | |
- name: Checkout runner script (this repo) | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
path: runner | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
cache: "yarn" | |
node-version-file: "runner/.nvmrc" | |
cache-dependency-path: "runner/yarn.lock" | |
- name: Install node dependencies in runner | |
run: | | |
yarn install --frozen-lockfile | |
working-directory: runner | |
- name: Checkout integrations-v3 | |
uses: actions/checkout@v3 | |
with: | |
repository: Gearbox-protocol/integrations-v3 | |
ref: legacy | |
# ${{ github.token }} is scoped to the current repository | |
token: ${{ secrets.PEER_REPO_GH_TOKEN }} | |
path: integrations-v3 | |
- name: Install node dependencies in integrations-v3 | |
run: | | |
yarn install --frozen-lockfile | |
working-directory: integrations-v3 | |
- name: Checkout router | |
uses: actions/checkout@v3 | |
with: | |
repository: Gearbox-protocol/router | |
# ${{ github.token }} is scoped to the current repository | |
token: ${{ secrets.PEER_REPO_GH_TOKEN }} | |
path: router | |
- name: Install node dependencies in router | |
# TODO: install latest integrations-v3 as a temporary workaround | |
run: | | |
yarn install --frozen-lockfile | |
yarn add @gearbox-protocol/integrations-v3@legacy | |
working-directory: router | |
- name: Run detached anvil fork | |
# "&" in the end makes it detached | |
# chain id is also important | |
run: | | |
anvil -f ${{ secrets.MAINNET_TESTS_FORK }} --chain-id 1 & | |
- name: Apply multisig tx | |
id: multisig | |
run: | | |
yarn start | |
env: | |
SAFE_API: ${{ inputs.api }} | |
MULTISIG: ${{ inputs.multisig }} | |
RUN_ID: ${{ github.run_id }} | |
working-directory: runner | |
timeout-minutes: 40 | |
- name: Run live forge tests in integrations-v3 | |
# TODO: wstETH is temporary removed | |
run: | | |
for u in DAI_0 USDC_0 WETH_0 WETH_1 WBTC_0 FRAX_0 ; | |
do | |
export ETH_FORK_TESTED_CM_ASSET=${u%_*} | |
export ETH_FORK_TESTED_CM_INDEX=${u#*_} | |
echo "Running tests for $ETH_FORK_TESTED_CM_ASSET index $ETH_FORK_TESTED_CM_INDEX" | |
forge t -vvvv --match-test _live_ --chain-id 1337 --fork-url http://localhost:8545 | |
done | |
timeout-minutes: 20 | |
working-directory: integrations-v3 | |
- name: Run live forge tests in router | |
run: | | |
for u in DAI_0 USDC_0 WETH_0 WETH_1 WBTC_0 FRAX_0 ; | |
do | |
export ETH_FORK_USE_EXISTING=true | |
export ETH_FORK_USE_EXISTING_PATHFINDER=true | |
export ETH_FORK_TESTED_CM_ASSET=${u%_*} | |
export ETH_FORK_TESTED_CM_INDEX=${u#*_} | |
echo "Running tests for $ETH_FORK_TESTED_CM_ASSET index $ETH_FORK_TESTED_CM_INDEX" | |
forge t --match-test _live_ --chain-id 1337 --fork-url http://localhost:8545 | |
done | |
timeout-minutes: 100 | |
working-directory: router | |
- name: The job has succeeded | |
if: ${{ success() && github.event.inputs.callback != '' }} | |
run: | | |
curl \ | |
-H "Authorization: Bearer ${{ secrets.RISK_API_TOKEN }}" \ | |
-X GET \ | |
"${{ inputs.callback }}?run_id=${{ github.run_id }}&tx=${{ env.EXECUTED_TRANSACTIONS }}&status=PASS" | |
- name: The job has failed | |
if: ${{ failure() && github.event.inputs.callback != '' }} | |
run: | | |
curl \ | |
-H "Authorization: Bearer ${{ secrets.RISK_API_TOKEN }}" \ | |
-X GET \ | |
"${{ inputs.callback }}?run_id=${{ github.run_id }}&tx=${{ env.EXECUTED_TRANSACTIONS }}&status=FAIL" |