230 lines
8.1 KiB
YAML
230 lines
8.1 KiB
YAML
name: (CI) Console tests
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
github-sha:
|
|
required: true
|
|
type: string
|
|
workflow_dispatch:
|
|
inputs:
|
|
console-test-branch:
|
|
type: choice
|
|
description: 'main: v0.72.14, develop: v0.73.4'
|
|
options:
|
|
- main
|
|
- develop
|
|
|
|
jobs:
|
|
create-docker-image:
|
|
name: Create docker image for console-test
|
|
runs-on: ubuntu-22.04
|
|
timeout-minutes: 20
|
|
steps:
|
|
#----------------------------------------------
|
|
# check-out frontend-monorepo
|
|
#----------------------------------------------
|
|
- name: Checkout frontend-monorepo
|
|
uses: actions/checkout@v3
|
|
with:
|
|
ref: ${{ inputs.github-sha || github.sha }}
|
|
#----------------------------------------------
|
|
# cache node modules
|
|
#----------------------------------------------
|
|
- name: setup node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version-file: '.nvmrc'
|
|
cache: yarn
|
|
|
|
- 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
|
|
#----------------------------------------------
|
|
- name: Build trading app
|
|
run: |
|
|
yarn env-cmd -f ./apps/trading/.env.stagnet1 yarn nx export trading
|
|
DIST_LOCATION=dist/apps/trading/exported
|
|
mv $DIST_LOCATION dist-result
|
|
tree dist-result
|
|
|
|
#----------------------------------------------
|
|
# export trading app docker image
|
|
#----------------------------------------------
|
|
|
|
- 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
|
|
run: |
|
|
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
|
|
|
|
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 }}
|
|
|
|
run-tests:
|
|
name: run-tests
|
|
runs-on: 8-cores
|
|
needs: [create-docker-image, console-test-branch]
|
|
timeout-minutes: 20
|
|
steps:
|
|
#----------------------------------------------
|
|
# load docker image
|
|
#----------------------------------------------
|
|
- name: Download docker image from previous job
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: console-image
|
|
path: /tmp
|
|
|
|
- name: Load Docker image
|
|
run: |
|
|
docker load --input /tmp/console-image.tar
|
|
docker image ls -a
|
|
#----------------------------------------------
|
|
# check-out frontend-monorepo
|
|
#----------------------------------------------
|
|
- name: Checkout frontend-monorepo
|
|
uses: actions/checkout@v3
|
|
with:
|
|
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
|
|
#----------------------------------------------
|
|
# ----- 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
|
|
#----------------------------------------------
|
|
- name: Install dependencies
|
|
run: poetry install --no-interaction --no-root
|
|
working-directory: apps/trading/e2e
|
|
#----------------------------------------------
|
|
# install vega binaries
|
|
#----------------------------------------------
|
|
- name: Install vega binaries
|
|
run: poetry run python -m vega_sim.tools.load_binaries --force --version ${{ env.VEGA_VERSION }}
|
|
working-directory: apps/trading/e2e
|
|
#----------------------------------------------
|
|
# install playwrightworking-directory: apps/trading/e2e
|
|
#----------------------------------------------
|
|
- name: install playwright
|
|
run: poetry run playwright install --with-deps chromium
|
|
working-directory: apps/trading/e2e
|
|
#----------------------------------------------
|
|
# run tests
|
|
#----------------------------------------------
|
|
- name: Run tests
|
|
run: CONSOLE_IMAGE_NAME=ci/trading:local poetry run pytest -v -s --numprocesses 6 --dist loadfile --durations=15
|
|
working-directory: apps/trading/e2e
|
|
#----------------------------------------------
|
|
# upload traces
|
|
#----------------------------------------------
|
|
- name: Upload Playwright Trace
|
|
uses: actions/upload-artifact@v3
|
|
if: always()
|
|
with:
|
|
name: playwright-trace
|
|
path: ./traces/
|
|
retention-days: 15
|
|
#----------------------------------------------
|
|
# ----- upload logs -----
|
|
#----------------------------------------------
|
|
- name: Upload worker logs
|
|
uses: actions/upload-artifact@v3
|
|
if: always()
|
|
with:
|
|
name: worker-logs
|
|
path: ./logs/
|
|
retention-days: 15
|