2023-07-28 05:32:07 +00:00
|
|
|
name: (CI) Console tests
|
|
|
|
|
2023-07-12 11:06:48 +00:00
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
github-sha:
|
|
|
|
required: true
|
|
|
|
type: string
|
2023-09-27 13:18:32 +00:00
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
console-test-branch:
|
|
|
|
type: choice
|
2023-11-22 09:39:40 +00:00
|
|
|
description: 'main: v0.73.5, develop: v0.73.5'
|
2023-09-27 13:18:32 +00:00
|
|
|
options:
|
|
|
|
- main
|
|
|
|
- develop
|
2023-07-28 05:32:07 +00:00
|
|
|
|
2023-07-12 11:06:48 +00:00
|
|
|
jobs:
|
2023-10-06 10:47:38 +00:00
|
|
|
create-docker-image:
|
|
|
|
name: Create docker image for console-test
|
|
|
|
runs-on: ubuntu-22.04
|
2024-01-23 14:43:51 +00:00
|
|
|
timeout-minutes: 45
|
2023-07-12 11:06:48 +00:00
|
|
|
steps:
|
2023-07-28 05:32:07 +00:00
|
|
|
#----------------------------------------------
|
|
|
|
# check-out frontend-monorepo
|
|
|
|
#----------------------------------------------
|
2023-09-27 13:18:32 +00:00
|
|
|
- name: Checkout frontend-monorepo
|
2023-07-28 05:32:07 +00:00
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
2023-09-27 13:18:32 +00:00
|
|
|
ref: ${{ inputs.github-sha || github.sha }}
|
2023-07-28 05:32:07 +00:00
|
|
|
#----------------------------------------------
|
|
|
|
# cache node modules
|
|
|
|
#----------------------------------------------
|
2023-09-28 09:26:15 +00:00
|
|
|
- name: setup node
|
2023-11-14 14:25:29 +00:00
|
|
|
uses: actions/setup-node@v4
|
2023-09-28 09:26:15 +00:00
|
|
|
with:
|
2023-11-14 14:25:29 +00:00
|
|
|
node-version-file: '.nvmrc'
|
2023-09-28 09:26:15 +00:00
|
|
|
cache: yarn
|
|
|
|
|
2023-07-28 05:32:07 +00:00
|
|
|
- name: Cache node modules
|
|
|
|
id: cache
|
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: node_modules
|
|
|
|
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('yarn.lock') }}
|
|
|
|
# comment out "restore-keys" if you need to rebuild yarn from 0
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-cache-node-modules-
|
|
|
|
#----------------------------------------------
|
|
|
|
# install deps if cache missing
|
|
|
|
#----------------------------------------------
|
|
|
|
- name: yarn install
|
|
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
|
|
|
run: yarn install --pure-lockfile
|
|
|
|
#----------------------------------------------
|
|
|
|
# build trading
|
|
|
|
#----------------------------------------------
|
2023-10-06 10:47:38 +00:00
|
|
|
- name: Build trading app
|
2023-07-28 05:32:07 +00:00
|
|
|
run: |
|
|
|
|
yarn env-cmd -f ./apps/trading/.env.stagnet1 yarn nx export trading
|
2023-10-06 10:47:38 +00:00
|
|
|
DIST_LOCATION=dist/apps/trading/exported
|
|
|
|
mv $DIST_LOCATION dist-result
|
|
|
|
tree dist-result
|
|
|
|
|
2023-07-28 05:32:07 +00:00
|
|
|
#----------------------------------------------
|
2023-10-06 10:47:38 +00:00
|
|
|
# export trading app docker image
|
2023-07-28 05:32:07 +00:00
|
|
|
#----------------------------------------------
|
2023-10-06 10:47:38 +00:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
|
|
|
|
- name: Build and export to local Docker
|
|
|
|
id: docker_build
|
|
|
|
uses: docker/build-push-action@v5
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
file: docker/node-outside-docker.Dockerfile
|
|
|
|
load: true
|
|
|
|
build-args: |
|
|
|
|
APP=trading
|
|
|
|
ENV_NAME=stagnet1
|
|
|
|
tags: ci/trading:local
|
|
|
|
outputs: type=docker,dest=/tmp/console-image.tar
|
|
|
|
|
|
|
|
- name: Verify docker image created
|
2023-07-28 05:32:07 +00:00
|
|
|
run: |
|
2023-10-06 10:47:38 +00:00
|
|
|
echo ${{ steps.docker_build.outputs.digest }}
|
|
|
|
echo ${{ steps.docker_build.outputs.imageid }}
|
|
|
|
|
|
|
|
- name: Upload docker image for console-test usage
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: console-image
|
|
|
|
path: /tmp/console-image.tar
|
|
|
|
|
2023-10-06 14:12:13 +00:00
|
|
|
console-test-branch:
|
|
|
|
name: Choose console-test branch to run on
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
timeout-minutes: 5
|
|
|
|
outputs:
|
|
|
|
console-branch: ${{ steps.output-step.outputs.branch }}
|
|
|
|
steps:
|
|
|
|
- name: Workflow dispatch input
|
|
|
|
id: dispatch-step
|
|
|
|
if: github.event_name == 'workflow_dispatch'
|
|
|
|
run: echo "branch=${{ inputs.console-test-branch }}" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
- name: Print Workflow dispatch input
|
|
|
|
if: github.event_name == 'workflow_dispatch'
|
|
|
|
run: echo ${{ steps.dispatch-step.outputs.branch }}
|
|
|
|
|
|
|
|
- name: Workflow_call input
|
|
|
|
id: workflow_call-step
|
|
|
|
if: github.event_name != 'workflow_dispatch'
|
|
|
|
run: |
|
|
|
|
if [[ "${{ github.base_ref }}" == "main" ]]; then
|
|
|
|
echo "branch=main" >> $GITHUB_OUTPUT
|
|
|
|
elif [[ "${{ github.base_ref }}" == "develop" && "${{ github.ref_name }}" == "main" ]]; then
|
|
|
|
echo "branch=main" >> $GITHUB_OUTPUT
|
|
|
|
elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref_name }}" == *"release/mainnet"* ]]; then
|
|
|
|
echo "branch=main" >> $GITHUB_OUTPUT
|
|
|
|
else
|
|
|
|
echo "branch=develop" >> $GITHUB_OUTPUT
|
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Print Workflow_call input
|
|
|
|
if: github.event_name != 'workflow_dispatch'
|
|
|
|
run: echo ${{ steps.workflow_call-step.outputs.branch }}
|
|
|
|
|
|
|
|
- name: Set output
|
|
|
|
id: output-step
|
|
|
|
run: echo "branch=${{ steps.dispatch-step.outputs.branch || steps.workflow_call-step.outputs.branch }}" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
- name: Print final output
|
|
|
|
run: echo ${{ steps.output-step.outputs.branch }}
|
|
|
|
|
2023-10-06 10:47:38 +00:00
|
|
|
run-tests:
|
|
|
|
name: run-tests
|
|
|
|
runs-on: 8-cores
|
2023-10-06 14:12:13 +00:00
|
|
|
needs: [create-docker-image, console-test-branch]
|
2024-01-23 14:43:51 +00:00
|
|
|
timeout-minutes: 45
|
2023-10-06 10:47:38 +00:00
|
|
|
steps:
|
2023-07-28 05:32:07 +00:00
|
|
|
#----------------------------------------------
|
2023-10-06 10:47:38 +00:00
|
|
|
# load docker image
|
2023-07-28 05:32:07 +00:00
|
|
|
#----------------------------------------------
|
2023-10-06 10:47:38 +00:00
|
|
|
- name: Download docker image from previous job
|
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: console-image
|
|
|
|
path: /tmp
|
|
|
|
|
|
|
|
- name: Load Docker image
|
2023-07-28 05:32:07 +00:00
|
|
|
run: |
|
2023-10-06 10:47:38 +00:00
|
|
|
docker load --input /tmp/console-image.tar
|
|
|
|
docker image ls -a
|
2023-07-28 05:32:07 +00:00
|
|
|
#----------------------------------------------
|
2023-11-14 18:05:07 +00:00
|
|
|
# check-out frontend-monorepo
|
2023-07-28 05:32:07 +00:00
|
|
|
#----------------------------------------------
|
2023-11-14 18:05:07 +00:00
|
|
|
- name: Checkout frontend-monorepo
|
2023-07-12 11:06:48 +00:00
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
2023-11-14 18:05:07 +00:00
|
|
|
ref: ${{ inputs.github-sha || github.sha }}
|
|
|
|
#----------------------------------------------
|
|
|
|
# get vega version
|
|
|
|
#----------------------------------------------
|
|
|
|
- name: Set VEGA_VERSION from .env
|
|
|
|
id: set_vega_version
|
|
|
|
run: echo "VEGA_VERSION=$(grep VEGA_VERSION apps/trading/e2e/.env | cut -d '=' -f2)" >> $GITHUB_ENV
|
2023-07-28 05:32:07 +00:00
|
|
|
#----------------------------------------------
|
2023-10-06 10:47:38 +00:00
|
|
|
# ----- Setup python -----
|
|
|
|
#----------------------------------------------
|
|
|
|
- name: Setup Python
|
|
|
|
uses: actions/setup-python@v4
|
|
|
|
with:
|
|
|
|
python-version: '3.10'
|
|
|
|
#----------------------------------------------
|
|
|
|
# ----- install & configure poetry -----
|
|
|
|
#----------------------------------------------
|
|
|
|
- name: Install Poetry
|
|
|
|
uses: snok/install-poetry@v1
|
|
|
|
with:
|
|
|
|
virtualenvs-create: true
|
|
|
|
virtualenvs-in-project: true
|
|
|
|
virtualenvs-path: .venv
|
|
|
|
|
|
|
|
#----------------------------------------------
|
|
|
|
# install python dependencies
|
2023-07-28 05:32:07 +00:00
|
|
|
#----------------------------------------------
|
2023-07-12 11:06:48 +00:00
|
|
|
- name: Install dependencies
|
2023-07-28 05:32:07 +00:00
|
|
|
run: poetry install --no-interaction --no-root
|
2023-11-14 18:05:07 +00:00
|
|
|
working-directory: apps/trading/e2e
|
2023-07-28 05:32:07 +00:00
|
|
|
#----------------------------------------------
|
|
|
|
# install vega binaries
|
|
|
|
#----------------------------------------------
|
|
|
|
- name: Install vega binaries
|
2023-09-27 13:18:32 +00:00
|
|
|
run: poetry run python -m vega_sim.tools.load_binaries --force --version ${{ env.VEGA_VERSION }}
|
2023-11-14 18:05:07 +00:00
|
|
|
working-directory: apps/trading/e2e
|
2023-07-28 05:32:07 +00:00
|
|
|
#----------------------------------------------
|
2023-11-14 18:05:07 +00:00
|
|
|
# install playwrightworking-directory: apps/trading/e2e
|
2023-07-28 05:32:07 +00:00
|
|
|
#----------------------------------------------
|
2023-07-12 11:06:48 +00:00
|
|
|
- name: install playwright
|
2023-09-27 13:18:32 +00:00
|
|
|
run: poetry run playwright install --with-deps chromium
|
2023-11-14 18:05:07 +00:00
|
|
|
working-directory: apps/trading/e2e
|
2023-07-28 05:32:07 +00:00
|
|
|
#----------------------------------------------
|
|
|
|
# run tests
|
|
|
|
#----------------------------------------------
|
|
|
|
- name: Run tests
|
2024-01-23 14:43:51 +00:00
|
|
|
run: CONSOLE_IMAGE_NAME=ci/trading:local poetry run pytest -v -s --numprocesses 1 --dist loadfile --durations=45
|
2023-11-14 18:05:07 +00:00
|
|
|
working-directory: apps/trading/e2e
|
2023-07-28 05:32:07 +00:00
|
|
|
#----------------------------------------------
|
|
|
|
# upload traces
|
|
|
|
#----------------------------------------------
|
2023-07-12 11:06:48 +00:00
|
|
|
- name: Upload Playwright Trace
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
if: always()
|
|
|
|
with:
|
|
|
|
name: playwright-trace
|
2023-11-22 15:52:59 +00:00
|
|
|
path: apps/trading/e2e/traces/
|
2023-07-12 11:06:48 +00:00
|
|
|
retention-days: 15
|
2023-09-27 13:18:32 +00:00
|
|
|
#----------------------------------------------
|
|
|
|
# ----- upload logs -----
|
|
|
|
#----------------------------------------------
|
|
|
|
- name: Upload worker logs
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
if: always()
|
|
|
|
with:
|
|
|
|
name: worker-logs
|
|
|
|
path: ./logs/
|
|
|
|
retention-days: 15
|
2024-01-15 20:56:52 +00:00
|
|
|
#----------------------------------------------
|
|
|
|
# ----- upload market-sim logs -----
|
|
|
|
#----------------------------------------------
|
2024-01-17 12:19:52 +00:00
|
|
|
- name: Prepare and Zip market-sim-logs
|
|
|
|
if: always()
|
2024-01-15 20:56:52 +00:00
|
|
|
run: |
|
2024-01-17 12:19:52 +00:00
|
|
|
parent_dir="/tmp/market-sim-logs"
|
|
|
|
echo "Creating parent directory at $parent_dir"
|
|
|
|
mkdir -p "$parent_dir"
|
|
|
|
|
|
|
|
echo "Waiting for vega-sim-* folders to be created..."
|
|
|
|
sleep 10 # Waits 10 seconds to ensure all folders are created
|
|
|
|
|
|
|
|
echo "Before searching for vega-sim-* folders in /tmp..."
|
|
|
|
folders=$(find /tmp -mindepth 1 -type d -name 'vega-sim-*' -print) || echo "Find command failed with exit code $?"
|
|
|
|
|
|
|
|
echo "After searching for vega-sim-* folders in /tmp..."
|
|
|
|
|
|
|
|
if [ -z "$folders" ]; then
|
|
|
|
echo "No vega-sim-* folders found."
|
|
|
|
exit 0
|
2024-01-15 20:56:52 +00:00
|
|
|
fi
|
|
|
|
|
2024-01-17 12:19:52 +00:00
|
|
|
echo "Moving vega-sim-* folders to $parent_dir"
|
|
|
|
echo "$folders" | xargs -I {} mv {} "$parent_dir/"
|
2024-01-15 20:56:52 +00:00
|
|
|
|
2024-01-17 12:19:52 +00:00
|
|
|
echo "Checking if $parent_dir is not empty..."
|
|
|
|
if [ "$(ls -A $parent_dir)" ]; then
|
|
|
|
echo "Zipping the parent directory..."
|
|
|
|
zip -r market-sim-logs.zip "$parent_dir" && echo "Zip file created successfully."
|
|
|
|
else
|
|
|
|
echo "$parent_dir is empty. No zip file created."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
shell: /usr/bin/bash -e {0}
|
|
|
|
|
|
|
|
- name: Upload market-sim-logs
|
2024-01-15 20:56:52 +00:00
|
|
|
uses: actions/upload-artifact@v3
|
2024-01-17 12:19:52 +00:00
|
|
|
if: always()
|
2024-01-15 20:56:52 +00:00
|
|
|
with:
|
|
|
|
name: market-sim-logs
|
2024-01-17 12:19:52 +00:00
|
|
|
path: market-sim-logs.zip
|
2024-01-15 20:56:52 +00:00
|
|
|
retention-days: 15
|