From a91148291e88a41f99e290f2e8d73402f142fb6b Mon Sep 17 00:00:00 2001 From: Scott Prutton Date: Mon, 24 Jun 2024 14:46:05 -0400 Subject: [PATCH] use envs --- .github/workflows/deploy-on-main.yml | 6 ++ .github/workflows/e2e-validation.yml | 66 +++++++++---------- .../cypress/e2e/authentication/login.cy.ts | 4 ++ .../cypress/e2e/authentication/logout.cy.ts | 8 ++- .../create-component.cy.ts | 4 ++ .../delete-component.cy.ts | 18 +++-- .../value-attribute-propogation.cy.ts | 4 ++ .../e2e/web-functionality/get-summary.cy.ts | 4 ++ .../workspace-dashboard.cy.ts | 4 ++ .../support/auth-provider-commands/auth0.ts | 12 ++-- .../support/component-actions/create.ts | 2 +- 11 files changed, 81 insertions(+), 51 deletions(-) diff --git a/.github/workflows/deploy-on-main.yml b/.github/workflows/deploy-on-main.yml index 11fb9394c7..397cb37eba 100644 --- a/.github/workflows/deploy-on-main.yml +++ b/.github/workflows/deploy-on-main.yml @@ -10,3 +10,9 @@ jobs: service: all version: stable secrets: inherit + + e2e-validation: + uses: ./.github/workflows/e2e-validation.yml + with: + environment: tools + secrets: inherit diff --git a/.github/workflows/e2e-validation.yml b/.github/workflows/e2e-validation.yml index 8a7db8fe71..b586e7111d 100644 --- a/.github/workflows/e2e-validation.yml +++ b/.github/workflows/e2e-validation.yml @@ -1,21 +1,29 @@ name: Cypress E2E Tests on: - workflow_dispatch: # schedule: # - cron: '*/5 * * * *' # Runs every 5 minutes + workflow_call: inputs: environment: - description: 'Select environment' + type: string required: true - default: 'PROD' + description: "where to deploy" + default: "tools" + workflow_dispatch: + inputs: + environment: type: choice + required: true + description: "where to deploy" + default: "tools" options: - - PROD - - TOOLS + - tools + - production jobs: cypress-tests: + environment: ${{ inputs.environment }} runs-on: ubuntu-latest strategy: # don't fail the entire matrix on failure @@ -25,31 +33,13 @@ jobs: containers: [1] # , 2, 3, 4, 5, 6, 7, 8, 9, 10] - temp disabled mass steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: '18.18.2' - - name: Setup authentication for vite & other synthetic test variables - working-directory: app/web - run: | - sudo apt update - sudo apt install uuid -y - cp .env .env.local - echo "VITE_AUTH0_USERNAME=${{ secrets.VITE_AUTH0_USERNAME }}" >> .env.local - echo "VITE_AUTH0_PASSWORD=${{ secrets.VITE_AUTH0_PASSWORD }}" >> .env.local - echo "VITE_SI_CYPRESS_MULTIPLIER=${{ vars.VITE_SI_CYPRESS_MULTIPLIER }}" >> .env.local - if [ "${{ github.event.inputs.environment }}" == "PROD" ]; then - echo "VITE_SI_WORKSPACE_URL=${{ vars.VITE_PROD_SI_WORKSPACE_URL }}" >> .env.local - echo "VITE_SI_WORKSPACE_ID=${{ vars.VITE_PROD_SI_WORKSPACE_ID }}" >> .env.local - elif [ "${{ github.event.inputs.environment }}" == "TOOLS" ]; then - echo "VITE_SI_WORKSPACE_URL=${{ vars.VITE_TOOLS_SI_WORKSPACE_URL }}" >> .env.local - echo "VITE_SI_WORKSPACE_ID=${{ vars.VITE_TOOLS_SI_WORKSPACE_ID }}" >> .env.local - fi - echo "VITE_UUID=$(uuid)" >> .env.local - - name: Setup pnpm uses: pnpm/action-setup@v2 with: @@ -60,19 +50,29 @@ jobs: run: | pnpm i pnpm install cypress - + + - name: install uuid + run: | + sudo apt update + sudo apt install uuid -y + - uses: nick-fields/retry@v2 with: max_attempts: 3 timeout_minutes: 20 command: | - if [ "${{ github.event.inputs.environment }}" == "PROD" ]; then - export VITE_HOST_URL=${{ vars.VITE_PROD_SI_WORKSPACE_URL }} - elif [ "${{ github.event.inputs.environment }}" == "TOOLS" ]; then - export VITE_HOST_URL=${{ vars.VITE_TOOLS_SI_WORKSPACE_URL }} - fi cd app/web - npx cypress run --spec "cypress/e2e/**" + export VITE_AUTH0_USERNAME=${{ secrets.VITE_AUTH0_USERNAME }} + export VITE_AUTH0_PASSWORD=${{ secrets.VITE_AUTH0_PASSWORD }} + export VITE_SI_CYPRESS_MULTIPLIER=${{ vars.VITE_SI_CYPRESS_MULTIPLIER }} + export VITE_SI_WORKSPACE_URL=${{ vars.VITE_SI_WORKSPACE_URL }} + export VITE_HOST_URL=${{ vars.VITE_SI_WORKSPACE_URL }} + export VITE_SI_WORKSPACE_ID=${{ vars.VITE_SI_WORKSPACE_ID }} + export VITE_UUID=$(uuid) + export VITE_AUTH_API_URL=https://auth-api.systeminit.com + export VITE_AUTH_PORTAL_URL=https://auth.systeminit.com + + npx cypress run --spec "cypress/e2e/**" --parallel --record --key ${{ secrets.CYPRESS_RECORD_KEY }} - name: 'Upload Cypress Recordings to Github' uses: actions/upload-artifact@v4 @@ -85,4 +85,4 @@ jobs: - name: Send Slack Failure Webhook if: failure() run: | - curl -X POST -H 'Content-type: application/json' --data "{\"text\": \":si: Failed Cypress E2E Test for ${{ github.event.inputs.environment }}: \"}" ${{ secrets.SLACK_WEBHOOK_URL }} + curl -X POST -H 'Content-type: application/json' --data "{\"text\": \":si: Failed Cypress E2E Test for ${{ inputs.environment }}: \"}" ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/app/web/cypress/e2e/authentication/login.cy.ts b/app/web/cypress/e2e/authentication/login.cy.ts index c2640a095f..7aa19e6c7e 100644 --- a/app/web/cypress/e2e/authentication/login.cy.ts +++ b/app/web/cypress/e2e/authentication/login.cy.ts @@ -14,6 +14,10 @@ Cypress._.times(SI_CYPRESS_MULTIPLIER, () => { it("log_in", () => { cy.loginToAuth0(AUTH0_USERNAME, AUTH0_PASSWORD); cy.visit(AUTH_API_URL + '/workspaces/' + SI_WORKSPACE_ID + '/go'); + cy.on('uncaught:exception', (e) => { + console.log(e); + return false; + }); cy.sendPosthogEvent(Cypress.currentTest.titlePath.join("/"), "test_uuid", UUID); // check that you're on head i.e. that you were redirected correctly cy.wait(4000) diff --git a/app/web/cypress/e2e/authentication/logout.cy.ts b/app/web/cypress/e2e/authentication/logout.cy.ts index 2f5a18e8c8..2e6f42e9f6 100644 --- a/app/web/cypress/e2e/authentication/logout.cy.ts +++ b/app/web/cypress/e2e/authentication/logout.cy.ts @@ -1,6 +1,8 @@ const SI_CYPRESS_MULTIPLIER = Cypress.env('VITE_SI_CYPRESS_MULTIPLIER') || import.meta.env.VITE_SI_CYPRESS_MULTIPLIER || 1; +const SI_WORKSPACE_ID = Cypress.env('VITE_SI_WORKSPACE_ID') || import.meta.env.VITE_SI_WORKSPACE_ID; const AUTH0_USERNAME = Cypress.env('VITE_AUTH0_USERNAME') || import.meta.env.VITE_AUTH0_USERNAME; const AUTH0_PASSWORD = Cypress.env('VITE_AUTH0_PASSWORD') || import.meta.env.VITE_AUTH0_PASSWORD; +const AUTH_API_URL = Cypress.env('VITE_AUTH_API_URL') || import.meta.env.VITE_AUTH_API_URL; const AUTH_PORTAL_URL = Cypress.env('VITE_AUTH_PORTAL_URL') || import.meta.env.VITE_AUTH_PORTAL_URL; const UUID = Cypress.env('VITE_UUID') || import.meta.env.VITE_UUID || "local"; @@ -12,7 +14,11 @@ Cypress._.times(SI_CYPRESS_MULTIPLIER, () => { }); it("log_out", () => { - cy.visit("/"); + cy.visit(AUTH_API_URL + '/workspaces/' + SI_WORKSPACE_ID + '/go'); + cy.on('uncaught:exception', (e) => { + console.log(e); + return false; + }); cy.sendPosthogEvent(Cypress.currentTest.titlePath.join("/"), "test_uuid", UUID); cy.contains('Create change set', { timeout: 10000 }).should('be.visible'); cy.get('.modal-close-button').should('exist').click(); diff --git a/app/web/cypress/e2e/modelling-functionality/create-component.cy.ts b/app/web/cypress/e2e/modelling-functionality/create-component.cy.ts index 87a0589fb0..31d308ba60 100644 --- a/app/web/cypress/e2e/modelling-functionality/create-component.cy.ts +++ b/app/web/cypress/e2e/modelling-functionality/create-component.cy.ts @@ -17,6 +17,10 @@ Cypress._.times(SI_CYPRESS_MULTIPLIER, () => { it('create', () => { cy.visit(AUTH_API_URL + '/workspaces/' + SI_WORKSPACE_ID + '/go'); + cy.on('uncaught:exception', (e) => { + console.log(e); + return false; + }); cy.sendPosthogEvent(Cypress.currentTest.titlePath.join("/"), "test_uuid", UUID); cy.get('#vorm-input-3', { timeout: 30000 }).should('have.value', 'Change Set 1'); diff --git a/app/web/cypress/e2e/modelling-functionality/delete-component.cy.ts b/app/web/cypress/e2e/modelling-functionality/delete-component.cy.ts index 674063e311..13b8178f15 100644 --- a/app/web/cypress/e2e/modelling-functionality/delete-component.cy.ts +++ b/app/web/cypress/e2e/modelling-functionality/delete-component.cy.ts @@ -16,6 +16,10 @@ Cypress._.times(SI_CYPRESS_MULTIPLIER, () => { it('delete', () => { cy.visit(AUTH_API_URL + '/workspaces/' + SI_WORKSPACE_ID + '/go'); + cy.on('uncaught:exception', (e) => { + console.log(e); + return false; + }); cy.sendPosthogEvent(Cypress.currentTest.titlePath.join("/"), "test_uuid", UUID); cy.get('#vorm-input-3', { timeout: 30000 }).should('have.value', 'Change Set 1'); @@ -28,18 +32,12 @@ Cypress._.times(SI_CYPRESS_MULTIPLIER, () => { // Give time to redirect onto the new change set cy.url().should('not.include', 'head', { timeout: 10000 }); - // Find the AWS Credential - cy.get('div[class="text-sm"]', { timeout: 30000 }).contains('AWS Credential').as('awsCred'); - - // Find the canvas to get a location to drag to - cy.get('canvas').first().as('konvaStage'); - - // Drag to the canvas - cy.dragTo('@awsCred', '@konvaStage'); + // Create a region component + cy.createComponent("region"); // Check to make sure a component has been added to the outliner cy.get('[class="diagram-outline-node"]', { timeout: 30000 }) - .contains('AWS Credential', { timeout: 30000 }) + .contains('Region', { timeout: 30000 }) .should('be.visible') .rightclick(); @@ -51,7 +49,7 @@ Cypress._.times(SI_CYPRESS_MULTIPLIER, () => { .click(); // Check to make sure a component has been added to the outliner - cy.get('[class="diagram-outline-node"]', { timeout: 30000 }).contains('AWS Credential', { timeout: 30000 }).should('be.visible'); + cy.get('[class="diagram-outline-node"]', { timeout: 30000 }).contains('Region', { timeout: 30000 }).should('be.visible'); // Click the button to destroy change set cy.get('nav.navbar button.vbutton.--variant-ghost.--size-sm.--tone-action') diff --git a/app/web/cypress/e2e/modelling-functionality/value-attribute-propogation.cy.ts b/app/web/cypress/e2e/modelling-functionality/value-attribute-propogation.cy.ts index b146d995d7..4a73cd9e86 100644 --- a/app/web/cypress/e2e/modelling-functionality/value-attribute-propogation.cy.ts +++ b/app/web/cypress/e2e/modelling-functionality/value-attribute-propogation.cy.ts @@ -25,6 +25,10 @@ Cypress._.times(SI_CYPRESS_MULTIPLIER, () => { // Go to the Synthetic Workspace cy.visit(SI_WORKSPACE_URL + '/w/' + SI_WORKSPACE_ID + '/head'); + cy.on('uncaught:exception', (e) => { + console.log(e); + return false; + }); cy.sendPosthogEvent(Cypress.currentTest.titlePath.join("/"), "test_uuid", UUID); cy.get('#vorm-input-3', { timeout: 30000 }).should('have.value', 'Change Set 1'); diff --git a/app/web/cypress/e2e/web-functionality/get-summary.cy.ts b/app/web/cypress/e2e/web-functionality/get-summary.cy.ts index 459c34de64..68a05dbdef 100644 --- a/app/web/cypress/e2e/web-functionality/get-summary.cy.ts +++ b/app/web/cypress/e2e/web-functionality/get-summary.cy.ts @@ -15,6 +15,10 @@ describe('web', () => { it('get_summary', () => { // Go to the Synthetic Workspace cy.visit(SI_WORKSPACE_URL + '/w/' + SI_WORKSPACE_ID + '/head'); + cy.on('uncaught:exception', (e) => { + console.log(e); + return false; + }); cy.sendPosthogEvent(Cypress.currentTest.titlePath.join("/"), "test_uuid", UUID); cy.intercept('GET', SI_WORKSPACE_URL + '/api/qualification/get_summary?visibility_change_set_pk=00000000000000000000000000', (req) => { // Log the intercepted request URL and response status code diff --git a/app/web/cypress/e2e/workspace-management/workspace-dashboard.cy.ts b/app/web/cypress/e2e/workspace-management/workspace-dashboard.cy.ts index 720ef4e883..ad94507d40 100644 --- a/app/web/cypress/e2e/workspace-management/workspace-dashboard.cy.ts +++ b/app/web/cypress/e2e/workspace-management/workspace-dashboard.cy.ts @@ -28,6 +28,10 @@ describe("workspace", () => { .should('be.visible') .invoke('removeAttr', 'target') .click(); + cy.on('uncaught:exception', (e) => { + console.log(e); + return false; + }); cy.wait(5000); diff --git a/app/web/cypress/support/auth-provider-commands/auth0.ts b/app/web/cypress/support/auth-provider-commands/auth0.ts index e78538b25f..a0d09a0c17 100644 --- a/app/web/cypress/support/auth-provider-commands/auth0.ts +++ b/app/web/cypress/support/auth-provider-commands/auth0.ts @@ -39,12 +39,12 @@ Cypress.Commands.add("loginToAuth0", (username: string, password: string) => { cy.visit(import.meta.env.VITE_AUTH_API_URL + '/workspaces/' + import.meta.env.VITE_SI_WORKSPACE_ID + '/go'); }, - { - validate: () => { - // Validate presence of access token in localStorage. - cy.window().its("localStorage").invoke("getItem", "si-auth").should("exist"); - }, - } + // { + // validate: () => { + // // Validate presence of access token in localStorage. + // cy.window().its("localStorage").invoke("getItem", "si-auth").should("exist"); + // }, + // } ); log.snapshot("after"); diff --git a/app/web/cypress/support/component-actions/create.ts b/app/web/cypress/support/component-actions/create.ts index 1156550807..86183f4dc6 100644 --- a/app/web/cypress/support/component-actions/create.ts +++ b/app/web/cypress/support/component-actions/create.ts @@ -12,7 +12,7 @@ Cypress.Commands.add("createComponent", (componentName: string) => { log.snapshot("before"); // Find the component in the AssetPalette - cy.get('.asset-palette div[class="text-sm"]', { timeout: 30000 }).contains(componentName, { matchCase: false }).as('component'); + cy.get('.asset-palette').find('.text-sm', { timeout: 30000 }).contains(componentName, { matchCase: false }).as('component'); // Find the canvas to get a location to drag to cy.get('.modeling-diagram .konvajs-content').first().as('konvaStage');