diff --git a/.github/workflows/capsule-cypress-manual-trigger.yml b/.github/workflows/capsule-cypress-manual-trigger.yml new file mode 100644 index 000000000..fce68a98f --- /dev/null +++ b/.github/workflows/capsule-cypress-manual-trigger.yml @@ -0,0 +1,138 @@ +name: Capsule tests -- manual trigger + +# This workflow runs the frontend tests against chosen branch + +on: + workflow_dispatch: + inputs: + project: + description: 'Project' + required: true + type: choice + options: + - explorer + - simple-trading-app + - stats + - token + - trading + includeFlows: + description: 'Include long flows (if any)?' + required: true + type: boolean + default: true + +jobs: + manual: + name: Run capsule tests -- manual trigger + 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 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 --home ~/.vegacapsule/testnet/wallet + - name: Import wallet + run: vegawallet import -w UI_Trading_Test --recovery-phrase-file ./recovery -p ./passphrase --home ~/.vegacapsule/testnet/wallet + - name: Create public key 2 + run: vegawallet key generate -w UI_Trading_Test -p ./passphrase --home ~/.vegacapsule/testnet/wallet + - name: Start service + run: vegawallet service run --network DV --automatic-consent --home ~/.vegacapsule/testnet/wallet & + + ###### + ## 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 --project=${{inputs.project}} --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 }} + CYPRESS_INCLUDE_FLOWS: ${{inputs.includeFlows}} + + ###### + ## 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 diff --git a/.github/workflows/capsule-cypress-nightly.yml b/.github/workflows/capsule-cypress-nightly.yml index d0be1106d..cbac25a77 100644 --- a/.github/workflows/capsule-cypress-nightly.yml +++ b/.github/workflows/capsule-cypress-nightly.yml @@ -28,49 +28,9 @@ jobs: node-version: 16 ####### - ## Checkout all the things + ## Checkout capsule ####### - # 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 @@ -87,28 +47,26 @@ jobs: run: go install working-directory: capsule - - name: Build vega - run: go install ./cmd/vega/ - working-directory: vega + - name: Set GOBIN + run: echo GOBIN=$(go env GOPATH)/bin >> $GITHUB_ENV - - name: Build vegawallet - run: go install - working-directory: vegawallet - - - name: Build data-node - run: go install ./cmd/data-node/ - working-directory: data-node + - 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 + run: vegacapsule network bootstrap --config-path=./net_confs/config.hcl --force working-directory: capsule ###### @@ -149,6 +107,7 @@ jobs: CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }} CYPRESS_ETH_WALLET_MNEMONIC: ${{ secrets.CYPESS_ETH_WALLET_MNEMONIC }} CYPRESS_NIGHTLY_RUN: true + CYPRESS_INCLUDE_FLOWS: true ###### ## Upload logs diff --git a/.github/workflows/capsule-cypress.yml b/.github/workflows/capsule-cypress.yml index f269f718b..91c10796c 100644 --- a/.github/workflows/capsule-cypress.yml +++ b/.github/workflows/capsule-cypress.yml @@ -113,6 +113,7 @@ jobs: 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 }} + CYPRESS_INCLUDE_FLOWS: false ###### ## Upload logs diff --git a/apps/token-e2e/.env b/apps/token-e2e/.env index d3bc490f1..6d3d52c1f 100644 --- a/apps/token-e2e/.env +++ b/apps/token-e2e/.env @@ -15,3 +15,4 @@ NX_LOCAL_PROVIDER_URL=http://localhost:8545/ #Test configuration variables CYPRESS_FAIRGROUND=false +CYPRESS_INCLUDE_FLOWS=true \ No newline at end of file diff --git a/apps/token-e2e/cypress.config.js b/apps/token-e2e/cypress.config.js index 59465a683..9e307e379 100644 --- a/apps/token-e2e/cypress.config.js +++ b/apps/token-e2e/cypress.config.js @@ -6,13 +6,18 @@ module.exports = defineConfig({ baseUrl: 'http://localhost:4210', fileServerFolder: '.', fixturesFolder: false, - specPattern: '**/*.cy.{js,jsx,ts,tsx}', + specPattern: [ + './src/integration/view/**/*.cy.{js,jsx,ts,tsx}', + process.env.CYPRESS_INCLUDE_FLOWS + ? './src/integration/flow/**/*.cy.{js,jsx,ts,tsx}' + : '', + ], modifyObstructiveCode: false, supportFile: './src/support/index.ts', video: true, videoUploadOnPasses: false, - videosFolder: '../../dist/cypress/apps/explorer-e2e/videos', - screenshotsFolder: '../../dist/cypress/apps/explorer-e2e/screenshots', + videosFolder: '../../dist/cypress/apps/token-e2e/videos', + screenshotsFolder: '../../dist/cypress/apps/token-e2e/screenshots', chromeWebSecurity: false, viewportWidth: 1440, viewportHeight: 900, diff --git a/apps/token-e2e/src/integration/app.cy.js b/apps/token-e2e/src/integration/app.cy.js deleted file mode 100644 index d4ba0c282..000000000 --- a/apps/token-e2e/src/integration/app.cy.js +++ /dev/null @@ -1,12 +0,0 @@ -const fairgroundSet = Cypress.env('FAIRGROUND'); - -describe('token', () => { - beforeEach(() => cy.visit('/')); - - it('should always have a header title based on environment', () => { - cy.get('[data-testid="header-title"]', { timeout: 8000 }).should( - 'have.text', - `${fairgroundSet ? 'Fairground token' : 'VEGA TOKEN'}` - ); - }); -}); diff --git a/apps/token-e2e/src/integration/governance.cy.js b/apps/token-e2e/src/integration/view/governance.cy.js similarity index 100% rename from apps/token-e2e/src/integration/governance.cy.js rename to apps/token-e2e/src/integration/view/governance.cy.js diff --git a/apps/token-e2e/src/integration/home.cy.js b/apps/token-e2e/src/integration/view/home.cy.js similarity index 100% rename from apps/token-e2e/src/integration/home.cy.js rename to apps/token-e2e/src/integration/view/home.cy.js diff --git a/apps/token-e2e/src/integration/rewards.cy.js b/apps/token-e2e/src/integration/view/rewards.cy.js similarity index 100% rename from apps/token-e2e/src/integration/rewards.cy.js rename to apps/token-e2e/src/integration/view/rewards.cy.js diff --git a/apps/token-e2e/src/integration/staking.cy.js b/apps/token-e2e/src/integration/view/staking.cy.js similarity index 100% rename from apps/token-e2e/src/integration/staking.cy.js rename to apps/token-e2e/src/integration/view/staking.cy.js diff --git a/apps/token-e2e/src/integration/vesting.cy.js b/apps/token-e2e/src/integration/view/vesting.cy.js similarity index 100% rename from apps/token-e2e/src/integration/vesting.cy.js rename to apps/token-e2e/src/integration/view/vesting.cy.js diff --git a/apps/token-e2e/src/integration/wallet-eth.cy.js b/apps/token-e2e/src/integration/view/wallet-eth.cy.js similarity index 100% rename from apps/token-e2e/src/integration/wallet-eth.cy.js rename to apps/token-e2e/src/integration/view/wallet-eth.cy.js diff --git a/apps/token-e2e/src/integration/withdraw.cy.js b/apps/token-e2e/src/integration/view/withdraw.cy.js similarity index 100% rename from apps/token-e2e/src/integration/withdraw.cy.js rename to apps/token-e2e/src/integration/view/withdraw.cy.js