Add capsule workflow (#278)

* begin capsule workflow

* remove workflow file we don't want to run while debugging

* vheckout all require repos

* checkout repos to a directory each

* correct branch names

* rename workflow

* fix incorrecr branch name

* begin building binaries

* typo

* remove tests we don't want running while debugging

* remove tests we don't want running while debugging

* typo

* incorrect path

* comment out frontend checkout

* don't install as not done in example script

* add required environement variables

* change paths

* comment out FEM checkout

* check binary built properly

* path stuff

* silly mistake

* use relaive path

* correct working directory

* fix all paths

* debugging

* bump go verion

* fix path

* fix all paths

* fix cannot find config error

* add back in fe stuff

* move cehckout to where it is used

* revert accidentally committed change

* try install over build

* use v3 of action

* export as per action

* debugging

* don't pass path to install

* chnage go install

* change order

* pwd

* pwd

* see what happens without dn

* don't use relative path

* build correct paths

* remove checks as working

* make epxlorer run against locla capsule

* fix incorrect env file

* fix tests

* fixing tests

* trying for green run

* trying for green run

* bump timeout

* check tm endpoints

* configure to use the second tender mint node

* ci: add logs out

* ci: change paht

* ci: set env var correctly

* ci: remove wait for blockChain request

* ci: make test value assertions more robust

* ci: make test value assertions more robust

* chore: minor typo

* ci: add back test and lint scripts

* ci: comment out unused pipeline for now

* ci: break up job into steps

* ci: run all tests and pray it works

* ci: just use local vega wallet

* ci: not building it any more, use go installed bin

* ci: derive hashes properly

* ci: move existing folow into nightly

* ci: run nightly for all tests

* ci: use install bins

* ci: add missing flag

* ci: gobin

* ci: debugging

* ci: echo gopath

* ci: wrong syntax?

* ci: one last time?

* ci: try something else

* ci: try other things

* ci: again

* ci: move var to github env

* ci: set gobin

* ci: syntax

* ci: test out nightly

* ci: switch back nightly to posix

* ci: force network bootstrap

* ci: fix stupid mistake, pass falg to command not name

* ci: put test back

* ci: run on push as well as on pr

* ci: always upload logs if possible

* ci: import config from capsule rather than testnet

* Update apps/explorer-e2e/cypress.json

* test: fix failing test now we are using binaries

* ci: correct URL
This commit is contained in:
Dexter Edwards 2022-05-25 11:05:13 +01:00 committed by GitHub
parent d601c7f653
commit 96183bea36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 345 additions and 144 deletions

View File

@ -0,0 +1,166 @@
name: Capsule tests -- nightly
# This workflow runs the frontend tests against latest develop of the core to preempt breaking changes
on:
schedule:
- cron: '0 4 * * *'
jobs:
nightly:
name: Run capsule tests -- nightly
runs-on: ubuntu-latest
env:
GO111MODULE: 'on'
GOPROXY: ${{ secrets.GO_PROXY }}
steps:
#######
## Setup langs
#######
- name: Set up Go
uses: actions/setup-go@v3
id: go
with:
go-version: 1.18
- name: Set up Node 16
uses: actions/setup-node@v2
id: npm
with:
node-version: 16
#######
## Checkout all the things
#######
# Checkout repos required to build vega capsule
- name: Checkout vega
uses: actions/checkout@v2
with:
repository: vegaprotocol/vega
ref: master
token: ${{ secrets.VEGA_CI_BOT_GITHUB_TOKEN }}
path: './vega'
- name: Checkout data node
uses: actions/checkout@v2
with:
repository: vegaprotocol/data-node
ref: main
token: ${{ secrets.VEGA_CI_BOT_GITHUB_TOKEN }}
path: './data-node'
- name: Checkout protos
uses: actions/checkout@v2
with:
repository: vegaprotocol/protos
ref: master
token: ${{ secrets.VEGA_CI_BOT_GITHUB_TOKEN }}
path: './protos'
- name: Checkout vegatools
uses: actions/checkout@v2
with:
repository: vegaprotocol/vegatools
ref: main
token: ${{ secrets.VEGA_CI_BOT_GITHUB_TOKEN }}
path: './vegatools'
- name: Checkout vega wallet
uses: actions/checkout@v2
with:
repository: vegaprotocol/vegawallet
ref: master
path: './vegawallet'
# Checkout capsule to build local network
- name: Checkout capsule
uses: actions/checkout@v2
with:
repository: vegaprotocol/vegacapsule
ref: main
token: ${{ secrets.VEGA_CI_BOT_GITHUB_TOKEN }}
path: './capsule'
#######
## Build binaries
#######
- name: Build capsule
run: go install
working-directory: capsule
- name: Build vega
run: go install ./cmd/vega/
working-directory: vega
- name: Build vegawallet
run: go install
working-directory: vegawallet
- name: Build data-node
run: go install ./cmd/data-node/
working-directory: data-node
######
## Start capsule
######
- name: Login to docker
run: echo -n ${{ secrets.VEGA_CI_BOT_GITHUB_TOKEN }} | docker login https://ghcr.io -u vega-ci-bot --password-stdin
- name: Start nomad
run: vegacapsule nomad &
- name: Bootstrap network
run: vegacapsule network bootstrap --config-path=./net_confs/config.hcl
working-directory: capsule
######
## Setup a Vega wallet for our user
######
- name: Create passphrase
run: echo "${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }}" > ./passphrase
- name: Create recovery
run: echo "${{ secrets.TRADING_TEST_VEGA_WALLET_RECOVERY }}" > ./recovery
- name: Initialize wallet
run: vegawallet init -f
- name: Import wallet
run: vegawallet import -w UI_Trading_Test --recovery-phrase-file ./recovery -p ./passphrase
- name: Import config
run: vegawallet network import --from-file ~/.vegacapsule/testnet/wallet/config/wallet-service/networks/DV.toml
- name: Create public key 2
run: vegawallet key generate -w UI_Trading_Test -p ./passphrase
- name: Start service
run: vegawallet service run --network fairground &
######
## Run some tests
######
# Checkout front ends
- name: Checkout frontend mono repo
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Install root dependencies
run: yarn install
- name: Run Cypress tests
run: yarn nx run-many --target=e2e --all --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --browser chrome
env:
CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE: ${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }}
CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }}
CYPRESS_ETH_WALLET_MNEMONIC: ${{ secrets.CYPESS_ETH_WALLET_MNEMONIC }}
######
## Upload logs
######
- name: Logs
if: ${{ always() }}
run: vegacapsule network logs > vega-capsule-logs.txt
- uses: actions/upload-artifact@v2
with:
name: logs
path: ./vega-capsule-logs.txt

132
.github/workflows/capsule-cypress.yml vendored Normal file
View File

@ -0,0 +1,132 @@
name: Capsule tests
on:
push:
branches:
- master
- develop
pull_request:
jobs:
pr:
name: Run capsule tests - PR
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
env:
GO111MODULE: 'on'
GOPROXY: ${{ secrets.GO_PROXY }}
steps:
#######
## Setup langs
#######
- name: Set up Go
uses: actions/setup-go@v3
id: go
with:
go-version: 1.18
- name: Set up Node 16
uses: actions/setup-node@v2
id: npm
with:
node-version: 16
#######
## Checkout capsule
#######
# Checkout capsule to build local network
- name: Checkout capsule
uses: actions/checkout@v2
with:
repository: vegaprotocol/vegacapsule
ref: main
token: ${{ secrets.VEGA_CI_BOT_GITHUB_TOKEN }}
path: './capsule'
#######
## Build binaries
#######
- name: Build capsule
run: go install
working-directory: capsule
- name: Set GOBIN
run: echo GOBIN=$(go env GOPATH)/bin >> $GITHUB_ENV
- name: Install binaries
run: vegacapsule install-bins
env:
GITHUB_TOKEN: ${{ secrets.VEGA_CI_BOT_GITHUB_TOKEN }}
GOBIN: ${{ env.GOBIN }}
######
## Start capsule
######
- name: Login to docker
run: echo -n ${{ secrets.VEGA_CI_BOT_GITHUB_TOKEN }} | docker login https://ghcr.io -u vega-ci-bot --password-stdin
- name: Start nomad
run: vegacapsule nomad &
- name: Bootstrap network
run: vegacapsule network bootstrap --config-path=./net_confs/config.hcl --force
working-directory: capsule
######
## Setup a Vega wallet for our user
######
- name: Create passphrase
run: echo "${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }}" > ./passphrase
- name: Create recovery
run: echo "${{ secrets.TRADING_TEST_VEGA_WALLET_RECOVERY }}" > ./recovery
- name: Initialize wallet
run: vegawallet init -f
- name: Import wallet
run: vegawallet import -w UI_Trading_Test --recovery-phrase-file ./recovery -p ./passphrase
- name: Import config
run: vegawallet network import --from-file ~/.vegacapsule/testnet/wallet/config/wallet-service/networks/DV.toml
- name: Create public key 2
run: vegawallet key generate -w UI_Trading_Test -p ./passphrase
- name: Start service
run: vegawallet service run --network fairground &
######
## Run some tests
######
# Checkout front ends
- name: Checkout frontend mono repo
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2
with:
main-branch-name: master
- name: Install root dependencies
run: yarn install
- name: Run Cypress tests
run: npx nx affected:e2e --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --browser chrome
env:
CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE: ${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }}
CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }}
CYPRESS_ETH_WALLET_MNEMONIC: ${{ secrets.CYPESS_ETH_WALLET_MNEMONIC }}
######
## Upload logs
######
- name: Logs
if: ${{ always() }}
run: vegacapsule network logs > vega-capsule-logs.txt
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: logs
path: ./vega-capsule-logs.txt

View File

@ -1,114 +0,0 @@
name: Cypress tests
on:
push:
branches:
- master
- develop
pull_request:
jobs:
master:
name: Run end-to-end tests - main
runs-on: ubuntu-latest
strategy:
matrix:
vegawallet-version:
- '0.13.2'
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2
with:
main-branch-name: master
- name: Use Node.js 16
id: Node
uses: actions/setup-node@v2
with:
node-version: 16.14.0
- name: Install root dependencies
run: yarn install
- name: Download and unzip wallet
run: curl -L https://github.com/vegaprotocol/vegawallet/releases/download/v${{ matrix.vegawallet-version }}/vegawallet-linux-amd64.zip -O
- name: Unzip wallet
run: unzip ./vegawallet-linux-amd64.zip
- name: Create passphrase
run: echo "${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }}" > ./passphrase
- name: Create recovery
run: echo "${{ secrets.TRADING_TEST_VEGA_WALLET_RECOVERY }}" > ./recovery
- name: Initialize wallet
run: ./vegawallet init -f
- name: Import wallet
run: ./vegawallet import -w UI_Trading_Test --recovery-phrase-file ./recovery -p ./passphrase
- name: Import config
run: ./vegawallet network import --from-url https://raw.githubusercontent.com/vegaprotocol/networks/master/fairground/fairground.toml
- name: Create public key 2
run: ./vegawallet key generate -w UI_Trading_Test -p ./passphrase
- name: Start service
run: ./vegawallet service run --network fairground &
- name: Run Cypress tests
env:
CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE: ${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }}
CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }}
CYPRESS_ETH_WALLET_MNEMONIC: ${{ secrets.CYPESS_ETH_WALLET_MNEMONIC }}
run: npx nx affected:e2e --parallel=5 --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --browser chrome
pr:
name: Run end-to-end tests - PR
runs-on: ubuntu-latest
strategy:
matrix:
vegawallet-version:
- '0.13.2'
if: ${{ github.event_name == 'pull_request' }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2
with:
main-branch-name: master
- name: Use Node.js 16
id: Node
uses: actions/setup-node@v2
with:
node-version: 16.14.0
- name: Install root dependencies
run: yarn install
- name: Download and unzip wallet
run: curl -L https://github.com/vegaprotocol/vegawallet/releases/download/v${{ matrix.vegawallet-version }}/vegawallet-linux-amd64.zip -O
- name: Unzip wallet
run: unzip ./vegawallet-linux-amd64.zip
- name: Create passphrase
run: echo "${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }}" > ./passphrase
- name: Create recovery
run: echo "${{ secrets.TRADING_TEST_VEGA_WALLET_RECOVERY }}" > ./recovery
- name: Initialize wallet
run: ./vegawallet init -f
- name: Import wallet
run: ./vegawallet import -w UI_Trading_Test --recovery-phrase-file ./recovery -p ./passphrase
- name: Import config
run: ./vegawallet network import --from-url https://raw.githubusercontent.com/vegaprotocol/networks/master/fairground/fairground.toml
- name: Create public key 2
run: ./vegawallet key generate -w UI_Trading_Test -p ./passphrase
- name: Start service
run: ./vegawallet service run --network fairground &
- name: Run Cypress tests
env:
CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE: ${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }}
CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }}
CYPRESS_ETH_WALLET_MNEMONIC: ${{ secrets.CYPESS_ETH_WALLET_MNEMONIC }}
run: npx nx affected:e2e --parallel=5 --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --browser chrome

View File

@ -1,4 +1,4 @@
name: Cypress tests
name: Unit tests & build
on:
push:

View File

@ -1,11 +1,11 @@
NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-explorer-api"
NX_TENDERMINT_URL="https://lb.testnet.vega.xyz/tm"
NX_TENDERMINT_WEBSOCKET_URL="wss://lb.testnet.vega.xyz/tm/websocket"
NX_VEGA_URL="https://lb.testnet.vega.xyz/query"
NX_VEGA_ENV='TESTNET'
NX_VEGA_REST='https://lb.testnet.vega.xyz/datanode/rest'
NX_TENDERMINT_URL = 'http://localhost:26617'
NX_TENDERMINT_WEBSOCKET_URL = 'wss://localhost:26617/websocket'
NX_VEGA_URL = "http://localhost:3028/query"
NX_VEGA_ENV = 'LOCAL'
NX_VEGA_REST = 'http://localhost:3029'
CYPRESS_VEGA_TENDERMINT_URL='https://lb.testnet.vega.xyz/tm'
CYPRESS_VEGA_TENDERMINT_URL='http://localhost:26617'
NX_EXPLORER_ASSETS=1
NX_EXPLORER_GENESIS=1

View File

@ -14,7 +14,7 @@
"screenshotsFolder": "../../dist/cypress/apps/explorer-e2e/screenshots",
"chromeWebSecurity": false,
"env": {
"environment": "testnet",
"environment": "local",
"tsConfig": "tsconfig.json",
"TAGS": "not @todo and not @ignore and not @manual"
}

View File

@ -1,10 +1,13 @@
@todo
Feature: Markets Page
@todo - Needs markets in capsule state
Scenario: Navigate to markets page
Given I am on the homepage
When I navigate to the markets page
Then markets page is correctly displayed
@todo
Scenario: Navigate to markets page using mobile
Given I am on mobile and open the toggle menu
When I navigate to the markets page

View File

@ -19,9 +19,6 @@ export default class BasePage {
}
navigateToBlocks() {
const base = Cypress.env('VEGA_TENDERMINT_URL');
const url = new URL('/tm/blockchain*', base).toString();
cy.intercept(url).as('blockChain');
cy.get(`a[href='${this.blocksUrl}']`).click();
}

View File

@ -16,7 +16,6 @@ export default class BlocksPage extends BasePage {
jumpToBlockSubmit = 'go-submit';
private waitForBlocksResponse() {
cy.wait('@blockChain');
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(1000);
}

View File

@ -1,9 +1,9 @@
import BasePage from './base-page';
export default class GenesisPage extends BasePage {
GenesisHeader = 'genesis-header';
genesisHeader = 'genesis-header';
genesisFieldsDisplayed() {
this.validateBlockDataDisplayed(this.GenesisHeader);
this.validateBlockDataDisplayed(this.genesisHeader);
}
}

View File

@ -34,6 +34,10 @@ export default class HomePage extends BasePage {
'Chain ID',
];
cy.getByTestId(this.statsTitle).then(($list) => {
cy.wrap($list).should('have.length', 18);
});
cy.getByTestId(this.statsTitle)
.each(($title, index) => {
cy.wrap($title).should('have.text', statTitles[index]);
@ -43,19 +47,34 @@ export default class HomePage extends BasePage {
});
}
verifyStatsValuesdisplayed() {
verifyStatsValuesDisplayed() {
cy.getByTestId(this.statsValue).eq(0).should('have.text', 'CONNECTED');
cy.getByTestId(this.statsValue).eq(1).should('not.be.empty');
cy.getByTestId(this.statsValue).eq(2).should('have.text', '2');
cy.getByTestId(this.statsValue)
.each(($value, index) => {
cy.wrap($value).should('not.be.empty');
if (index == 6) {
// Total staked value
const totalStakedRegex = /^\d{1,3}(,\d{3})*(\.\d{1,2})?$/;
cy.wrap($value).invoke('text').should('match', totalStakedRegex); // Check that value is number with 2dp
}
})
.then(($list) => {
cy.wrap($list).should('have.length', 18);
});
.eq(3)
.invoke('text')
.should('match', /\d+d \d+h \d+m \d+s/i);
cy.getByTestId(this.statsValue).eq(4).should('have.text', '2');
cy.getByTestId(this.statsValue).eq(5).should('have.text', '0');
cy.getByTestId(this.statsValue).eq(6).should('have.text', '0.00');
cy.getByTestId(this.statsValue).eq(7).should('have.text', '0');
cy.getByTestId(this.statsValue).eq(8).should('have.text', '0');
cy.getByTestId(this.statsValue).eq(9).should('have.text', '0');
cy.getByTestId(this.statsValue).eq(10).should('have.text', '0');
cy.getByTestId(this.statsValue).eq(11).should('not.be.empty');
cy.getByTestId(this.statsValue).eq(12).should('not.be.empty');
cy.getByTestId(this.statsValue).eq(13).should('not.be.empty');
cy.getByTestId(this.statsValue)
.eq(14)
.invoke('text')
.should('match', /v\d+\.\d+\.\d+/i);
cy.getByTestId(this.statsValue)
.eq(15)
.invoke('text')
.should('match', /\d+\.\d+\.\d+/i);
cy.getByTestId(this.statsValue).eq(16).should('not.be.empty');
cy.getByTestId(this.statsValue).eq(17).should('not.be.empty');
}
verifyStatsBlockHeightUpdating() {

View File

@ -6,6 +6,6 @@ const homePage = new HomePage();
Then('the stats for deployed environment are correctly displayed', () => {
homePage.verifyStatsEnvironment();
homePage.verifyStatsTitlesDisplayed();
homePage.verifyStatsValuesdisplayed();
homePage.verifyStatsValuesDisplayed();
homePage.verifyStatsBlockHeightUpdating();
});

View File

@ -149,12 +149,11 @@ const MARKETS_QUERY = gql`
const Markets = () => {
const { data } = useQuery<MarketsQuery>(MARKETS_QUERY);
if (!data || !data.markets) return null;
return (
<section>
<RouteTitle data-testid="markets-heading">{t('Markets')}</RouteTitle>
{data
{data?.markets
? data.markets.map((m) => (
<React.Fragment key={m.id}>
<SubHeading data-testid="markets-header">{m.name}</SubHeading>