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
|
|
|
|
description: 'main: v0.72.14, develop: v0.73.0-preview7'
|
|
|
|
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
|
2023-08-09 13:18:24 +00:00
|
|
|
timeout-minutes: 20
|
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
|
|
|
|
uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
node-version: '16'
|
|
|
|
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
|
|
|
|
|
|
|
|
run-tests:
|
|
|
|
name: run-tests
|
|
|
|
runs-on: 8-cores
|
|
|
|
needs: create-docker-image
|
|
|
|
timeout-minutes: 20
|
|
|
|
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: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
|
|
|
|
- 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
|
|
|
#----------------------------------------------
|
|
|
|
# check-out tests repo
|
|
|
|
#----------------------------------------------
|
2023-07-12 11:06:48 +00:00
|
|
|
- name: Checkout console test repo
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
repository: vegaprotocol/console-test
|
2023-09-27 13:18:32 +00:00
|
|
|
ref: ${{ inputs.console-test-branch }}
|
|
|
|
|
|
|
|
- name: Load console test envs
|
|
|
|
id: console-test-env
|
|
|
|
uses: falti/dotenv-action@v1.0.4
|
|
|
|
with:
|
2023-10-06 10:47:38 +00:00
|
|
|
path: '.env.${{ inputs.console-test-branch }}'
|
2023-09-27 13:18:32 +00:00
|
|
|
export-variables: true
|
|
|
|
keys-case: upper
|
|
|
|
log-variables: true
|
|
|
|
|
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
|
|
|
|
#----------------------------------------------
|
|
|
|
# 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-07-28 05:32:07 +00:00
|
|
|
#----------------------------------------------
|
|
|
|
# install playwright
|
|
|
|
#----------------------------------------------
|
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-07-28 05:32:07 +00:00
|
|
|
#----------------------------------------------
|
|
|
|
# run tests
|
|
|
|
#----------------------------------------------
|
|
|
|
- name: Run tests
|
2023-10-06 10:47:38 +00:00
|
|
|
run: CONSOLE_IMAGE_NAME=ci/trading:local poetry run pytest -v -s --numprocesses 4 --dist loadfile --durations=15
|
|
|
|
|
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
|
|
|
|
path: ./traces/
|
|
|
|
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
|