From 5afcc0b411a5658c2acb485bf67ba665088399da Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Tue, 23 Jul 2024 09:53:24 +0100 Subject: [PATCH 01/46] saving WIP --- .../extensions-compatibility-tests.yaml | 111 ++++++++++++++++++ package.json | 2 +- scripts/e2e-docker-start | 45 +++++-- 3 files changed, 145 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/extensions-compatibility-tests.yaml diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml new file mode 100644 index 00000000000..e35c2895bc7 --- /dev/null +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -0,0 +1,111 @@ +name: Extensions Compatibility Tests +on: + schedule: + - cron: "0 0 * * *" # runs at midnight every day + # TODO: DELETE THIS!!!! JUST FOR TESTING PURPOSES! + pull_request: + branches: + - master + +# on: +# push: +# branches: +# - master +# - 'release-*' +# pull_request: +# branches: +# - master +# - 'release-*' +# workflow_dispatch: +# inputs: +# environment: +# description: 'Environment to run tests against' +# type: environment +# required: true + +env: + TEST_USERNAME: admin + TEST_PASSWORD: password + CATTLE_BOOTSTRAP_PASSWORD: password + TEST_BASE_URL: https://127.0.0.1:8005 + API: https://127.0.0.1 + TEST_PROJECT_ID: rancher-dashboard + CYPRESS_API_URL: http://139.59.134.103:1234/ + TEST_RUN_ID: ${{github.run_number}}-${{github.run_attempt}}-Extensions-Compatibility-Tests + # Build the dashboard to use in tests. When set to false it will grab `latest` from CDN (useful for running e2e tests quickly) + BUILD_DASHBOARD: true + + E2E_BUILD_DIST_NAME: dist + E2E_BUILD_DIST_DIR: dist + E2E_BUILD_DIST_EMBER_NAME: dist_ember + E2E_BUILD_DIST_EMBER_DIR: dist_ember + +jobs: + e2e-test: + if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" + strategy: + fail-fast: false + matrix: + role: [ + { username: 'admin', tag: '@adminUser' }, + # { username: 'standard_user', tag: '@standardUser' } + ] + features: [ + ['@elemental'], + ['@kubewarden'], + ['@neuvector'] + ] + rancherEnv: [ + ['v2.7-head'], + ['v2.8-head'], + ['v2.9-head'], + ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + - name: Setup env + uses: ./.github/actions/setup + # - name: Download e2e build + # uses: actions/download-artifact@v4 + # with: + # name: ${{ env.E2E_BUILD_DIST_NAME }} + # path: ${{ env.E2E_BUILD_DIST_DIR }} + # - name: Download e2e build ember + # uses: actions/download-artifact@v4 + # with: + # name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} + # path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }} + + # this is where docker is set up with the enviroment... + - name: Run Rancher + run: yarn e2e:docker # runs scripts/e2e-docker-start + env: + RANCHER-VERSION-E2E: ${{ matrix.rancherEnv[0] }} + + ## this is just setting up rancher and user... + - name: Setup Rancher and user + run: | + yarn e2e:prod + env: + GREP_TAGS: ${{ matrix.role.tag }}Setup+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}Setup+${{ matrix.features[1] || matrix.features[0] }} --@jenkins + TEST_USERNAME: ${{ matrix.role.username }} + TEST_ONLY: setup + + # This is the actual test runs!!!! + - name: Run user tests + run: | + yarn e2e:prod + [ "$BUILD_DASHBOARD" != "false" ] || exit 0 + env: + TEST_SKIP: setup + GREP_TAGS: ${{ matrix.role.tag }}+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}+${{ matrix.features[1] || matrix.features[0] }} --@jenkins + TEST_USERNAME: ${{ matrix.role.username }} + + - name: Upload screenshots + uses: actions/upload-artifact@v3 + if: ${{ failure() }} + with: + name: ${{github.run_number}}-${{github.run_attempt}}-screenshots-${{ matrix.role.tag }}+${{ matrix.features[0] }} + path: cypress/screenshots \ No newline at end of file diff --git a/package.json b/package.json index 24f4c3f0c7d..7f89edec327 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "e2e:pre-dev": "yarn docker:local:stop && yarn docker:local:start && NODE_ENV=dev TEST_INSTRUMENT=true yarn build", "e2e:dev": "START_SERVER_AND_TEST_INSECURE=1 server-test start:dev https-get://localhost:8005 cy:run:sorry", "e2e:build": "mkdir dist && TEST_INSTRUMENT=true ./scripts/build-e2e", - "e2e:docker": "yarn docker:local:stop && ./scripts/e2e-docker-start ", + "e2e:docker": "yarn docker:local:stop && ./scripts/e2e-docker-start $RANCHER-VERSION-E2E", "e2e:prod": "BUILD_DASHBOARD=$BUILD_DASHBOARD GREP_TAGS=$GREP_TAGS TEST_USERNAME=$TEST_USERNAME TEST_BASE_URL=https://127.0.0.1/dashboard yarn cy:run:sorry", "coverage": "npx nyc merge coverage coverage/coverage.json", "storybook": "cd storybook && yarn install && yarn storybook", diff --git a/scripts/e2e-docker-start b/scripts/e2e-docker-start index 13944eedfe7..01aa61de6e3 100755 --- a/scripts/e2e-docker-start +++ b/scripts/e2e-docker-start @@ -5,19 +5,40 @@ DIR=$(cd $(dirname $0)/..; pwd) # See `script/build-e2e` DASHBOARD_DIST=${DIR}/dist EMBER_DIST=${DIR}/dist_ember +IS_HEAD_VERSION="true" +USER_DEFINED_RANCHER_VERSION="false" -# Image version -RANCHER_IMG_VERSION=v2.9-head - -docker run -d --restart=unless-stopped -p 80:80 -p 443:443 \ - -v ${DASHBOARD_DIST}:/usr/share/rancher/ui-dashboard/dashboard \ - -v ${EMBER_DIST}:/usr/share/rancher/ui \ - -e CATTLE_UI_OFFLINE_PREFERRED=true \ - -e CATTLE_BOOTSTRAP_PASSWORD=password \ - -e CATTLE_PASSWORD_MIN_LENGTH=3 \ - --name cypress \ - --privileged \ - rancher/rancher:${RANCHER_IMG_VERSION} +if [ $# -eq 1 ] then + IS_HEAD_VERSION="false" + USER_DEFINED_RANCHER_VERSION=$1 +fi + +if [ "$IS_HEAD_VERSION" == "true" ]; then + # Image version + RANCHER_IMG_VERSION=v2.9-head + + docker run -d --restart=unless-stopped -p 80:80 -p 443:443 \ + -v ${DASHBOARD_DIST}:/usr/share/rancher/ui-dashboard/dashboard \ + -v ${EMBER_DIST}:/usr/share/rancher/ui \ + -e CATTLE_UI_OFFLINE_PREFERRED=true \ + -e CATTLE_BOOTSTRAP_PASSWORD=password \ + -e CATTLE_PASSWORD_MIN_LENGTH=3 \ + --name cypress \ + --privileged \ + rancher/rancher:${RANCHER_IMG_VERSION} +else + # We will only hit this scenario for the extensions-compatibility-tests workflow... + + docker run -d --restart=unless-stopped -p 80:80 -p 443:443 \ + # -v ${DASHBOARD_DIST}:/usr/share/rancher/ui-dashboard/dashboard \ + # -v ${EMBER_DIST}:/usr/share/rancher/ui \ + -e CATTLE_UI_OFFLINE_PREFERRED=true \ + -e CATTLE_BOOTSTRAP_PASSWORD=password \ + -e CATTLE_PASSWORD_MIN_LENGTH=3 \ + --name cypress \ + --privileged \ + rancher/rancher:${USER_DEFINED_RANCHER_VERSION} +fi docker ps From 1f35c4b5efce242e6b02169098498d8914270c41 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Wed, 24 Jul 2024 16:04:54 +0100 Subject: [PATCH 02/46] testing workflow for the first time --- .../extensions-compatibility-tests.yaml | 38 +- .../elemental.spec.ts | 418 ++++++++++++++++++ scripts/e2e-docker-start | 19 +- 3 files changed, 443 insertions(+), 32 deletions(-) create mode 100644 cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index e35c2895bc7..03e1fecbcad 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -35,13 +35,13 @@ env: # Build the dashboard to use in tests. When set to false it will grab `latest` from CDN (useful for running e2e tests quickly) BUILD_DASHBOARD: true - E2E_BUILD_DIST_NAME: dist - E2E_BUILD_DIST_DIR: dist - E2E_BUILD_DIST_EMBER_NAME: dist_ember - E2E_BUILD_DIST_EMBER_DIR: dist_ember + # E2E_BUILD_DIST_NAME: dist + # E2E_BUILD_DIST_DIR: dist + # E2E_BUILD_DIST_EMBER_NAME: dist_ember + # E2E_BUILD_DIST_EMBER_DIR: dist_ember jobs: - e2e-test: + e2e-test-rancher-2-dot-8: if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" strategy: fail-fast: false @@ -52,14 +52,14 @@ jobs: ] features: [ ['@elemental'], - ['@kubewarden'], - ['@neuvector'] - ] - rancherEnv: [ - ['v2.7-head'], - ['v2.8-head'], - ['v2.9-head'], + # ['@kubewarden'], + # ['@neuvector'] ] + # rancherEnv: [ + # ['v2.7-head'], + # ['v2.8-head'], + # ['v2.9-head'], + # ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -67,22 +67,12 @@ jobs: fetch-depth: 1 - name: Setup env uses: ./.github/actions/setup - # - name: Download e2e build - # uses: actions/download-artifact@v4 - # with: - # name: ${{ env.E2E_BUILD_DIST_NAME }} - # path: ${{ env.E2E_BUILD_DIST_DIR }} - # - name: Download e2e build ember - # uses: actions/download-artifact@v4 - # with: - # name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} - # path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }} # this is where docker is set up with the enviroment... - - name: Run Rancher + - name: Run Rancher 2.8 run: yarn e2e:docker # runs scripts/e2e-docker-start env: - RANCHER-VERSION-E2E: ${{ matrix.rancherEnv[0] }} + RANCHER-VERSION-E2E: v2.8-head ## this is just setting up rancher and user... - name: Setup Rancher and user diff --git a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts new file mode 100644 index 00000000000..9880a52748c --- /dev/null +++ b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts @@ -0,0 +1,418 @@ +import ExtensionsPagePo from '@/cypress/e2e/po/pages/extensions.po'; +// import RepositoriesPagePo from '@/cypress/e2e/po/pages/chart-repositories.po'; +// import PromptRemove from '@/cypress/e2e/po/prompts/promptRemove.po'; +// import BurgerMenuPo from '@/cypress/e2e/po/side-bars/burger-side-menu.po'; +// import { LoginPagePo } from '@/cypress/e2e/po/pages/login-page.po'; + +import HomePagePo from '@/cypress/e2e/po/pages/home.po'; +import AboutPagePo from '@/cypress/e2e/po/pages/about.po'; + +// const DISABLED_CACHE_EXTENSION_NAME = 'large-extension'; +// const DISABLED_CACHE_EXTENSION_MENU_LABEL = 'Large-extension'; +// const DISABLED_CACHE_EXTENSION_TITLE = 'Large extension demo (> 20mb) - cache testing'; +// const UNAUTHENTICATED_EXTENSION_NAME = 'uk-locale'; +const EXTENSION_NAME = 'elemental'; +// const UI_PLUGINS_PARTNERS_REPO_URL = 'https://github.com/rancher/partner-extensions'; +// const UI_PLUGINS_PARTNERS_REPO_NAME = 'partner-extensions'; + +describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] }, () => { + beforeEach(() => { + cy.login(); + }); + + // it('add repository', () => { + // // This should be in a `before` however is flaky. Move it to an `it` to let cypress retry + // const extensionsPo = new ExtensionsPagePo(); + + // extensionsPo.goTo(); + // extensionsPo.waitForPage(); + // extensionsPo.extensionTabInstalledClick(); // Avoid nav guard failures that probably auto move user to this tab + + // // install the rancher plugin examples + // extensionsPo.addExtensionsRepository('https://github.com/rancher/ui-plugin-examples', 'main', 'rancher-plugin-examples'); + // }); + + // it('has the correct title', () => { + // const extensionsPo = new ExtensionsPagePo(); + + // extensionsPo.goTo(); + + // cy.title().should('eq', 'Rancher - Extensions'); + // }); + + // it('Should check the feature flag', () => { + // const extensionsPo = new ExtensionsPagePo(); + + // extensionsPo.goTo(); + + // cy.intercept('GET', '/v1/management.cattle.io.features?*', { + // type: 'collection', + // resourceType: 'management.cattle.io.feature', + // data: [ + // { + // id: 'uiextension', + // type: 'management.cattle.io.feature', + // kind: 'Feature', + // spec: { value: true }, + // status: { + // default: true, + // description: 'Enable UI Extensions when starting Rancher', + // dynamic: false, + // lockedValue: null + // } + // } + // ] + // }).as('getFeatureFlag'); + + // extensionsPo.waitForPage(); + // extensionsPo.waitForTitle(); + + // cy.wait('@getFeatureFlag').then(() => { + // extensionsPo.extensionTabs.checkVisible(); + // }); + // }); + + // it('using "Add Rancher Repositories" should add a new repository (Partners repo)', () => { + // const extensionsPo = new ExtensionsPagePo(); + + // extensionsPo.goTo(); + + // // check if burguer menu nav is highlighted correctly for extensions + // // https://github.com/rancher/dashboard/issues/10010 + // BurgerMenuPo.checkIfMenuItemLinkIsHighlighted('Extensions'); + + // // catching regression https://github.com/rancher/dashboard/issues/10576 + // BurgerMenuPo.checkIfClusterMenuLinkIsHighlighted('local', false); + + // // go to "add rancher repositories" + // extensionsPo.extensionMenuToggle(); + // extensionsPo.addRepositoriesClick(); + + // // add the partners repo + // extensionsPo.addReposModalAddClick(); + // extensionsPo.addReposModal().should('not.exist'); + + // // go to repos list page + // const appRepoList = new RepositoriesPagePo('local', 'apps'); + + // appRepoList.goTo(); + // appRepoList.waitForPage(); + // appRepoList.sortableTable().rowElementWithName(UI_PLUGINS_PARTNERS_REPO_URL).should('exist'); + // }); + + // it('New repos banner should only appear once (after dismiss should NOT appear again)', () => { + // cy.getRancherResource('v3', 'setting', 'display-add-extension-repos-banner', null).then((resp: Cypress.Response) => { + // const notFound = resp.status === 404; + // const requiredValue = resp.body?.value === 'true'; + + // if (notFound || requiredValue) { + // cy.log('Good test state', '/v3/setting/display-add-extension-repos-banner', resp.status, JSON.stringify(resp?.body || {})); + // } else { + // cy.log('Bad test state', '/v3/setting/display-add-extension-repos-banner', resp.status, JSON.stringify(resp?.body || {})); + + // return cy.setRancherResource('v3', 'setting', 'display-add-extension-repos-banner', { + // ...resp.body, + // value: 'true' + // }); + // } + // }); + + // const appRepoList = new RepositoriesPagePo('local', 'apps'); + + // // Ensure that the banner should be shown (by confirming that a required repo isn't there) + // appRepoList.goTo(); + // appRepoList.waitForPage(); + // appRepoList.sortableTable().noRowsShouldNotExist(); + // appRepoList.sortableTable().rowNames().then((names) => { + // if (names.includes(UI_PLUGINS_PARTNERS_REPO_NAME)) { + // appRepoList.list().actionMenu(UI_PLUGINS_PARTNERS_REPO_NAME).getMenuItem('Delete').click(); + // const promptRemove = new PromptRemove(); + + // return promptRemove.remove(); + // } + // }); + + // // Now go to extensions (by nav, not page load....) + // appRepoList.navToMenuEntry('Extensions'); + + // const extensionsPo = new ExtensionsPagePo(); + + // extensionsPo.waitForPage(); + // extensionsPo.loading().should('not.exist'); + + // extensionsPo.repoBanner().checkVisible(); + // extensionsPo.repoBanner().self().find('[data-testid="extensions-new-repos-banner-action-btn"]').click(); + // extensionsPo.repoBanner().checkNotExists(); + + // // let's refresh the page to make sure it doesn't appear again... + // extensionsPo.goTo(); + // extensionsPo.waitForPage(); + // extensionsPo.waitForTitle(); + // extensionsPo.loading().should('not.exist'); + // extensionsPo.repoBanner().checkNotExists(); + // }); + + // it('Should toggle the extension details', () => { + // const extensionsPo = new ExtensionsPagePo(); + + // extensionsPo.goTo(); + + // extensionsPo.extensionTabAvailableClick(); + + // // we should be on the extensions page + // extensionsPo.waitForTitle(); + + // // show extension details + // extensionsPo.extensionCardClick(EXTENSION_NAME); + + // // after card click, we should get the info slide in panel + // extensionsPo.extensionDetails().should('be.visible'); + // extensionsPo.extensionDetailsTitle().should('contain', EXTENSION_NAME); + + // // close the details on the cross icon X + // extensionsPo.extensionDetailsCloseClick(); + // extensionsPo.extensionDetails().should('not.be.visible'); + + // // show extension details again... + // extensionsPo.extensionCardClick(EXTENSION_NAME); + // extensionsPo.extensionDetails().should('be.visible'); + + // // clicking outside the details tab should also close it + // extensionsPo.extensionDetailsBgClick(); + // extensionsPo.extensionDetails().should('not.be.visible'); + // }); + + it('can navigate to About page', () => { + const aboutPage = new AboutPagePo(); + + HomePagePo.goToAndWaitForGet(); + AboutPagePo.navTo(); + aboutPage.waitForPage(); + cy.wait(10000); // eslint-disable-line cypress/no-unnecessary-waiting + // just enough to render the page on sorry-cypress + }); + + it('Should install an extension', () => { + const extensionsPo = new ExtensionsPagePo(); + + extensionsPo.goTo(); + + extensionsPo.extensionTabAvailableClick(); + + // click on install button on card + extensionsPo.extensionCardInstallClick(EXTENSION_NAME); + extensionsPo.extensionInstallModal().should('be.visible'); + + // select version and click install + extensionsPo.installModalSelectVersionClick(2); + extensionsPo.installModalInstallClick(); + + // let's check the extension reload banner and reload the page + extensionsPo.extensionReloadBanner().should('be.visible'); + extensionsPo.extensionReloadClick(); + + // make sure extension card is in the installed tab + extensionsPo.extensionTabInstalledClick(); + extensionsPo.extensionCardClick(EXTENSION_NAME); + extensionsPo.extensionDetailsTitle().should('contain', EXTENSION_NAME); + extensionsPo.extensionDetailsCloseClick(); + }); + + it('Should not display installed extensions within the available tab', () => { + const extensionsPo = new ExtensionsPagePo(); + + extensionsPo.goTo(); + + // check for installed extension in "installed" tab + extensionsPo.extensionTabInstalledClick(); + extensionsPo.extensionCard(EXTENSION_NAME).should('be.visible'); + + // check for installed extension in "available" tab + extensionsPo.extensionTabAvailableClick(); + extensionsPo.extensionCard(EXTENSION_NAME).should('not.exist'); + }); + + it('Should update an extension version', () => { + const extensionsPo = new ExtensionsPagePo(); + + extensionsPo.goTo(); + + extensionsPo.extensionTabInstalledClick(); + + // click on update button on card + extensionsPo.extensionCardUpdateClick(EXTENSION_NAME); + extensionsPo.installModalInstallClick(); + + // let's check the extension reload banner and reload the page + extensionsPo.extensionReloadBanner().should('be.visible'); + extensionsPo.extensionReloadClick(); + + // make sure extension card is not available anymore on the updates tab + // since we installed the latest version + extensionsPo.extensionTabUpdatesClick(); + extensionsPo.extensionCard(EXTENSION_NAME).should('not.exist'); + }); + + it('Should rollback an extension version', () => { + const extensionsPo = new ExtensionsPagePo(); + + extensionsPo.goTo(); + + extensionsPo.extensionTabInstalledClick(); + + // click on the rollback button on card + // this will rollback to the immediate previous version + extensionsPo.extensionCardRollbackClick(EXTENSION_NAME); + extensionsPo.installModalInstallClick(); + + // let's check the extension reload banner and reload the page + extensionsPo.extensionReloadBanner().should('be.visible'); + extensionsPo.extensionReloadClick(); + + // make sure extension card is on the updates tab + extensionsPo.extensionTabUpdatesClick(); + extensionsPo.extensionCard(EXTENSION_NAME).should('be.visible'); + }); + + // it('An extension larger than 20mb, which will trigger chacheState disabled, should install and work fine', () => { + // const extensionsPo = new ExtensionsPagePo(); + + // extensionsPo.goTo(); + + // extensionsPo.extensionTabAvailableClick(); + + // // click on install button on card + // extensionsPo.extensionCardInstallClick(DISABLED_CACHE_EXTENSION_NAME); + // extensionsPo.extensionInstallModal().should('be.visible'); + + // // click install + // extensionsPo.installModalInstallClick(); + + // // let's check the extension reload banner and reload the page + // extensionsPo.extensionReloadBanner().should('be.visible'); + // extensionsPo.extensionReloadClick(); + + // // make sure extension card is in the installed tab + // extensionsPo.extensionTabInstalledClick(); + // extensionsPo.extensionCardClick(DISABLED_CACHE_EXTENSION_NAME); + // extensionsPo.extensionDetailsTitle().should('contain', DISABLED_CACHE_EXTENSION_NAME); + // extensionsPo.extensionDetailsCloseClick(); + + // // check if extension is working fine + // BurgerMenuPo.burgerMenuNavToMenubyLabel(DISABLED_CACHE_EXTENSION_MENU_LABEL); + // cy.get('h1').should('have.text', DISABLED_CACHE_EXTENSION_TITLE); + // }); + + // it('Should respect authentication when importing extension scripts', () => { + // const extensionsPo = new ExtensionsPagePo(); + + // extensionsPo.goTo(); + + // extensionsPo.extensionTabAvailableClick(); + + // // Install unauthenticated extension + // extensionsPo.extensionCardInstallClick(UNAUTHENTICATED_EXTENSION_NAME); + // extensionsPo.extensionInstallModal().should('be.visible'); + // extensionsPo.installModalInstallClick(); + + // // let's check the extension reload banner and reload the page + // extensionsPo.extensionReloadBanner().should('be.visible'); + // extensionsPo.extensionReloadClick(); + + // // make sure both extensions have been imported + // extensionsPo.extensionScriptImport(UNAUTHENTICATED_EXTENSION_NAME).should('exist'); + // extensionsPo.extensionScriptImport(EXTENSION_NAME).should('exist'); + + // cy.logout(); + + // // make sure only the unauthenticated extension has been imported after logout + // const loginPage = new LoginPagePo(); + + // loginPage.goTo(); + // loginPage.waitForPage(); + // loginPage.extensionScriptImport(UNAUTHENTICATED_EXTENSION_NAME).should('exist'); + // loginPage.extensionScriptImport(EXTENSION_NAME).should('not.exist'); + + // // make sure both extensions have been imported after logging in again + // cy.login(undefined, undefined, false); + // extensionsPo.goTo(); + // extensionsPo.waitForPage(); + // extensionsPo.waitForTitle(); + // extensionsPo.extensionScriptImport(UNAUTHENTICATED_EXTENSION_NAME).should('exist'); + // extensionsPo.extensionScriptImport(EXTENSION_NAME).should('exist'); + // }); + + it('Should uninstall extensions', () => { + // Because we logged out in the previous test this one will also have to use an uncached login + cy.login(undefined, undefined, false); + const extensionsPo = new ExtensionsPagePo(); + + extensionsPo.goTo(); + + extensionsPo.extensionTabInstalledClick(); + + // click on uninstall button on card + extensionsPo.extensionCardUninstallClick(EXTENSION_NAME); + extensionsPo.extensionUninstallModal().should('be.visible'); + extensionsPo.uninstallModaluninstallClick(); + extensionsPo.extensionReloadBanner().should('be.visible'); + + // let's check the extension reload banner and reload the page + extensionsPo.extensionReloadBanner().should('be.visible'); + extensionsPo.extensionReloadClick(); + + // make sure extension card is in the available tab + extensionsPo.extensionTabAvailableClick(); + extensionsPo.extensionCardClick(EXTENSION_NAME); + extensionsPo.extensionDetailsTitle().should('contain', EXTENSION_NAME); + }); + + // it('Should uninstall unathenticated extensions', () => { + // // Because we logged out in the previous test this one will also have to use an uncached login + // cy.login(undefined, undefined, false); + // const extensionsPo = new ExtensionsPagePo(); + + // extensionsPo.goTo(); + + // extensionsPo.extensionTabInstalledClick(); + + // // click on uninstall button on card + // extensionsPo.extensionCardUninstallClick(UNAUTHENTICATED_EXTENSION_NAME); + // extensionsPo.extensionUninstallModal().should('be.visible'); + // extensionsPo.uninstallModaluninstallClick(); + // extensionsPo.extensionReloadBanner().should('be.visible'); + + // // let's check the extension reload banner and reload the page + // extensionsPo.extensionReloadBanner().should('be.visible'); + // extensionsPo.extensionReloadClick(); + + // // make sure extension card is in the available tab + // extensionsPo.extensionTabAvailableClick(); + // extensionsPo.extensionCardClick(UNAUTHENTICATED_EXTENSION_NAME); + // extensionsPo.extensionDetailsTitle().should('contain', UNAUTHENTICATED_EXTENSION_NAME); + // }); + + // it('Should uninstall un-cached extensions', () => { + // // Because we logged out in the previous test this one will also have to use an uncached login + // cy.login(undefined, undefined, false); + // const extensionsPo = new ExtensionsPagePo(); + + // extensionsPo.goTo(); + + // extensionsPo.extensionTabInstalledClick(); + + // // click on uninstall button on card + // extensionsPo.extensionCardUninstallClick(DISABLED_CACHE_EXTENSION_NAME); + // extensionsPo.extensionUninstallModal().should('be.visible'); + // extensionsPo.uninstallModaluninstallClick(); + + // // let's check the extension reload banner and reload the page + // extensionsPo.extensionReloadBanner().should('be.visible'); + // extensionsPo.extensionReloadClick(); + + // // make sure extension card is in the available tab + // extensionsPo.extensionTabAvailableClick(); + // extensionsPo.extensionCardClick(DISABLED_CACHE_EXTENSION_NAME); + // extensionsPo.extensionDetailsTitle().should('contain', DISABLED_CACHE_EXTENSION_NAME); + // }); +}); diff --git a/scripts/e2e-docker-start b/scripts/e2e-docker-start index 01aa61de6e3..9d1607526f5 100755 --- a/scripts/e2e-docker-start +++ b/scripts/e2e-docker-start @@ -5,12 +5,18 @@ DIR=$(cd $(dirname $0)/..; pwd) # See `script/build-e2e` DASHBOARD_DIST=${DIR}/dist EMBER_DIST=${DIR}/dist_ember + +RANCHER_IMG_VERSION=v2.9-head IS_HEAD_VERSION="true" -USER_DEFINED_RANCHER_VERSION="false" +# check if script invoke contains any argument... if [ $# -eq 1 ] then - IS_HEAD_VERSION="false" - USER_DEFINED_RANCHER_VERSION=$1 + if [[ $string =~ "-head" ]] then + RANCHER_IMG_VERSION=$1 + else + IS_HEAD_VERSION="false" + RANCHER_IMG_VERSION=$1 + fi fi if [ "$IS_HEAD_VERSION" == "true" ]; then @@ -27,17 +33,14 @@ if [ "$IS_HEAD_VERSION" == "true" ]; then --privileged \ rancher/rancher:${RANCHER_IMG_VERSION} else - # We will only hit this scenario for the extensions-compatibility-tests workflow... - + # We will only hit this scenario for the extensions-compatibility-tests workflow and if it's not a -head version docker run -d --restart=unless-stopped -p 80:80 -p 443:443 \ - # -v ${DASHBOARD_DIST}:/usr/share/rancher/ui-dashboard/dashboard \ - # -v ${EMBER_DIST}:/usr/share/rancher/ui \ -e CATTLE_UI_OFFLINE_PREFERRED=true \ -e CATTLE_BOOTSTRAP_PASSWORD=password \ -e CATTLE_PASSWORD_MIN_LENGTH=3 \ --name cypress \ --privileged \ - rancher/rancher:${USER_DEFINED_RANCHER_VERSION} + rancher/rancher:${RANCHER_IMG_VERSION} fi docker ps From 27fd742e809a44ee116964d7981cfe676e84a8c4 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Wed, 24 Jul 2024 16:23:47 +0100 Subject: [PATCH 03/46] fix bash script + prevent a lot of e2e tests from running --- .github/workflows/test.yaml | 16 ++++++++-------- scripts/e2e-docker-start | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 80ebb206a44..baff34e678a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -71,15 +71,15 @@ jobs: { username: 'standard_user', tag: '@standardUser' } ] features: [ - ['@navigation', '@extensions'], - ['@charts'], + # ['@navigation', '@extensions'], + # ['@charts'], ['@explorer'], - ['@fleet'], - ['@generic', '@globalSettings'], - ['@manager'], - ['@userMenu', '@usersAndAuths'], - ['@components'], - ['@vai'] + # ['@fleet'], + # ['@generic', '@globalSettings'], + # ['@manager'], + # ['@userMenu', '@usersAndAuths'], + # ['@components'], + # ['@vai'] ] runs-on: ubuntu-latest steps: diff --git a/scripts/e2e-docker-start b/scripts/e2e-docker-start index 9d1607526f5..30515ebfcf2 100755 --- a/scripts/e2e-docker-start +++ b/scripts/e2e-docker-start @@ -10,8 +10,8 @@ RANCHER_IMG_VERSION=v2.9-head IS_HEAD_VERSION="true" # check if script invoke contains any argument... -if [ $# -eq 1 ] then - if [[ $string =~ "-head" ]] then +if [ $# -eq 1 ]; then + if [[ $1 =~ "-head" ]]; then RANCHER_IMG_VERSION=$1 else IS_HEAD_VERSION="false" From 2ea6d3c3ea5338edf3b7aa8ec8983697cdf5c231 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Wed, 24 Jul 2024 16:45:59 +0100 Subject: [PATCH 04/46] script adjustment --- scripts/e2e-docker-start | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/scripts/e2e-docker-start b/scripts/e2e-docker-start index 30515ebfcf2..a110c0043d6 100755 --- a/scripts/e2e-docker-start +++ b/scripts/e2e-docker-start @@ -6,21 +6,16 @@ DIR=$(cd $(dirname $0)/..; pwd) DASHBOARD_DIST=${DIR}/dist EMBER_DIST=${DIR}/dist_ember +# Image version RANCHER_IMG_VERSION=v2.9-head -IS_HEAD_VERSION="true" +HAS_ARGS="false" # check if script invoke contains any argument... if [ $# -eq 1 ]; then - if [[ $1 =~ "-head" ]]; then - RANCHER_IMG_VERSION=$1 - else - IS_HEAD_VERSION="false" - RANCHER_IMG_VERSION=$1 - fi + RANCHER_IMG_VERSION=$1 fi -if [ "$IS_HEAD_VERSION" == "true" ]; then - # Image version +if [ "$HAS_ARGS" == "false" ]; then RANCHER_IMG_VERSION=v2.9-head docker run -d --restart=unless-stopped -p 80:80 -p 443:443 \ From 96360852542a4b9b9914eedb90311ebf15cbbef3 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Wed, 24 Jul 2024 16:47:09 +0100 Subject: [PATCH 05/46] script adjustment --- scripts/e2e-docker-start | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/e2e-docker-start b/scripts/e2e-docker-start index a110c0043d6..77e3edd50fa 100755 --- a/scripts/e2e-docker-start +++ b/scripts/e2e-docker-start @@ -18,6 +18,8 @@ fi if [ "$HAS_ARGS" == "false" ]; then RANCHER_IMG_VERSION=v2.9-head + echo "normal flow without args... RANCHER_IMG_VERSION=${RANCHER_IMG_VERSION}" + docker run -d --restart=unless-stopped -p 80:80 -p 443:443 \ -v ${DASHBOARD_DIST}:/usr/share/rancher/ui-dashboard/dashboard \ -v ${EMBER_DIST}:/usr/share/rancher/ui \ @@ -29,6 +31,8 @@ if [ "$HAS_ARGS" == "false" ]; then rancher/rancher:${RANCHER_IMG_VERSION} else # We will only hit this scenario for the extensions-compatibility-tests workflow and if it's not a -head version + echo "special flow with version arg... RANCHER_IMG_VERSION=${RANCHER_IMG_VERSION}" + docker run -d --restart=unless-stopped -p 80:80 -p 443:443 \ -e CATTLE_UI_OFFLINE_PREFERRED=true \ -e CATTLE_BOOTSTRAP_PASSWORD=password \ From 5c55b13811d467af84687da510924d8d706acfe5 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Wed, 24 Jul 2024 16:48:47 +0100 Subject: [PATCH 06/46] script adjustment --- scripts/e2e-docker-start | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/e2e-docker-start b/scripts/e2e-docker-start index 77e3edd50fa..6f0b593e940 100755 --- a/scripts/e2e-docker-start +++ b/scripts/e2e-docker-start @@ -13,6 +13,7 @@ HAS_ARGS="false" # check if script invoke contains any argument... if [ $# -eq 1 ]; then RANCHER_IMG_VERSION=$1 + HAS_ARGS="true" fi if [ "$HAS_ARGS" == "false" ]; then From 1dcffc4daf9751d59bc74686378aec8ee1ac52bc Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 25 Jul 2024 10:32:45 +0100 Subject: [PATCH 07/46] script adjustment/fix --- .github/workflows/extensions-compatibility-tests.yaml | 6 +++--- package.json | 2 +- scripts/e2e-docker-start | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index 03e1fecbcad..4187e632741 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -70,9 +70,9 @@ jobs: # this is where docker is set up with the enviroment... - name: Run Rancher 2.8 - run: yarn e2e:docker # runs scripts/e2e-docker-start - env: - RANCHER-VERSION-E2E: v2.8-head + run: export RANCHER_VERSION_E2E=v2.8-head; yarn e2e:docker # runs scripts/e2e-docker-start + # env: + # RANCHER_VERSION_E2E: v2.8-head ## this is just setting up rancher and user... - name: Setup Rancher and user diff --git a/package.json b/package.json index 7f89edec327..153726eb3b9 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "e2e:pre-dev": "yarn docker:local:stop && yarn docker:local:start && NODE_ENV=dev TEST_INSTRUMENT=true yarn build", "e2e:dev": "START_SERVER_AND_TEST_INSECURE=1 server-test start:dev https-get://localhost:8005 cy:run:sorry", "e2e:build": "mkdir dist && TEST_INSTRUMENT=true ./scripts/build-e2e", - "e2e:docker": "yarn docker:local:stop && ./scripts/e2e-docker-start $RANCHER-VERSION-E2E", + "e2e:docker": "yarn docker:local:stop && ./scripts/e2e-docker-start", "e2e:prod": "BUILD_DASHBOARD=$BUILD_DASHBOARD GREP_TAGS=$GREP_TAGS TEST_USERNAME=$TEST_USERNAME TEST_BASE_URL=https://127.0.0.1/dashboard yarn cy:run:sorry", "coverage": "npx nyc merge coverage coverage/coverage.json", "storybook": "cd storybook && yarn install && yarn storybook", diff --git a/scripts/e2e-docker-start b/scripts/e2e-docker-start index 6f0b593e940..bc66ab8018b 100755 --- a/scripts/e2e-docker-start +++ b/scripts/e2e-docker-start @@ -11,7 +11,8 @@ RANCHER_IMG_VERSION=v2.9-head HAS_ARGS="false" # check if script invoke contains any argument... -if [ $# -eq 1 ]; then +# if [ $# -eq 1 ]; then +if [ -z "$RANCHER_VERSION_E2E" ]; then RANCHER_IMG_VERSION=$1 HAS_ARGS="true" fi From 5d2f62b3774a0fdf0a92a25f94a039d144474de4 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 25 Jul 2024 11:07:33 +0100 Subject: [PATCH 08/46] script adjustment/fix --- .../workflows/build-and-upload-branch.yaml | 22 ---- .github/workflows/build-test.yaml | 37 ------ .github/workflows/fossa.yaml | 44 ------- .github/workflows/port-issue.yaml | 103 --------------- .github/workflows/port-pr.yaml | 117 ------------------ .github/workflows/test.yaml | 10 +- package.json | 2 +- scripts/e2e-docker-start | 3 + 8 files changed, 5 insertions(+), 333 deletions(-) delete mode 100644 .github/workflows/build-and-upload-branch.yaml delete mode 100644 .github/workflows/build-test.yaml delete mode 100644 .github/workflows/fossa.yaml delete mode 100644 .github/workflows/port-issue.yaml delete mode 100644 .github/workflows/port-pr.yaml diff --git a/.github/workflows/build-and-upload-branch.yaml b/.github/workflows/build-and-upload-branch.yaml deleted file mode 100644 index 4604de6d0e7..00000000000 --- a/.github/workflows/build-and-upload-branch.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: Build Dashboard (Branch) -on: - push: - branches: - - master - - 'release-*' - - '*-dev' - -jobs: - build-validation: - name: Build Test - uses: ./.github/workflows/build-test.yaml - build: - name: Build and Upload - uses: ./.github/workflows/build-and-upload.yaml - needs: - - build-validation - permissions: - contents: 'read' - id-token: 'write' - with: - CI_BRANCH: ${{github.ref_name}} diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml deleted file mode 100644 index b8ba454680f..00000000000 --- a/.github/workflows/build-test.yaml +++ /dev/null @@ -1,37 +0,0 @@ -# Validation steps required before a build occurs. Not designed to replace the CI test workflow -name: Build Test - -on: - # This tells GH that the workflow is reusable - workflow_call: - -jobs: - unit-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - - name: Run tests - uses: ./.github/actions/unit-tests - - i18n: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - - name: Run i18n lint - uses: ./.github/actions/i18n-lint - - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - - name: Run lint - uses: ./.github/actions/lint diff --git a/.github/workflows/fossa.yaml b/.github/workflows/fossa.yaml deleted file mode 100644 index 9b01c6d418b..00000000000 --- a/.github/workflows/fossa.yaml +++ /dev/null @@ -1,44 +0,0 @@ -name: FOSSA Scanning - -on: - # List the branches that must be scanned when a push event happens. - push: - branches: ["master", "release-*"] - # For manual scans. - workflow_dispatch: - -permissions: - # Basic read access needed. - contents: read - # Required to authenticate in EIO's Vault. - id-token: write - -jobs: - fossa-scanning: - # For when running in EIO's provided runners. More details are available in - # https://github.com/rancherlabs/eio/wiki/GitHub-Actions-Runners . - runs-on: org-${{ github.repository_owner_id }}-amd64-k8s - # Use the BCI Node.js container when running in EIO's provided runners, - # because the Node.js runtime is needed. If using public GH provided runners, - # a container isn't necessary, because they already provide the runtime, but - # the BCI image can still be used anyway. - container: registry.suse.com/bci/nodejs:20 - steps: - - name: Checkout - uses: actions/checkout@v4 - - # The FOSSA token is shared between all repos in Rancher's GH org. It can - # be used directly and there is no need to request specific access to EIO. - - name: Read FOSSA token - uses: rancher-eio/read-vault-secrets@main - with: - secrets: | - secret/data/github/org/rancher/fossa/push token | FOSSA_API_KEY_PUSH_ONLY - - - name: FOSSA scan - uses: fossas/fossa-action@main - with: - api-key: ${{ env.FOSSA_API_KEY_PUSH_ONLY }} - # Only runs the scan and do not provide/returns any results back to the - # pipeline. - run-tests: false \ No newline at end of file diff --git a/.github/workflows/port-issue.yaml b/.github/workflows/port-issue.yaml deleted file mode 100644 index 2c59dc61195..00000000000 --- a/.github/workflows/port-issue.yaml +++ /dev/null @@ -1,103 +0,0 @@ -# create a backport/forwardport of an issue when "/backport " is commented -name: Port issue -run-name: "Port issue ${{ github.event.issue.number }}: ${{ github.event.issue.title }}" - -on: - issue_comment: - types: - - created - -jobs: - port-issue: - runs-on: ubuntu-latest - if: contains(github.event.comment.body, '/backport') || contains(github.event.comment.body, '/forwardport') - steps: - - name: Check org membership - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - if gh api orgs/${GITHUB_REPOSITORY_OWNER}/members --paginate | jq -e --arg GITHUB_ACTOR "$GITHUB_ACTOR" '.[] | select(.login == $GITHUB_ACTOR)' > /dev/null; then - echo "${GITHUB_ACTOR} is a member" - echo "is_member=true" >> $GITHUB_ENV - else - echo "${GITHUB_ACTOR} is not a member of ${GITHUB_REPOSITORY_OWNER}" >> $GITHUB_STEP_SUMMARY - echo "is_member=false" >> $GITHUB_ENV - fi - - name: Check milestone - if: env.is_member == 'true' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ORIGINAL_ISSUE_NUMBER: ${{ github.event.issue.number }} - COMMENT_BODY: ${{ github.event.comment.body }} - run: | - BODY_MILESTONE=$(echo "${COMMENT_BODY}" | awk '{ print $2 }') - echo "BODY_MILESTONE '${BODY_MILESTONE}'" - - # Sanitize input - MILESTONE=${BODY_MILESTONE//[^a-zA-Z0-9\-\.]/} - echo "MILESTONE '${MILESTONE}'" - - if gh api repos/${GITHUB_REPOSITORY}/milestones --paginate | jq -e --arg MILESTONE "$MILESTONE" '.[] | select(.title == $MILESTONE)' > /dev/null; then - echo "Milestone '${MILESTONE}' exists" - echo "milestone_exists=true" >> $GITHUB_ENV - else - echo "Milestone '${MILESTONE}' does not exist" >> $GITHUB_STEP_SUMMARY - gh issue comment -R ${GITHUB_REPOSITORY} ${ORIGINAL_ISSUE_NUMBER} --body "Not creating port issue, milestone ${MILESTONE} does not exist or is not an open milestone" - echo "milestone_exists=false" >> $GITHUB_ENV - fi - - name: Port issue - if: | - env.is_member == 'true' && - env.milestone_exists == 'true' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ORIGINAL_ISSUE_NUMBER: ${{ github.event.issue.number }} - COMMENT_BODY: ${{ github.event.comment.body }} - run: | - declare -a additional_cmd - BODY=$(mktemp) - ORIGINAL_ISSUE=$(gh issue view -R ${GITHUB_REPOSITORY} ${ORIGINAL_ISSUE_NUMBER} --json title,body,assignees) - ORIGINAL_TITLE=$(echo "${ORIGINAL_ISSUE}" | jq -r .title) - TYPE=$(echo "${COMMENT_BODY}" | awk '{ print $1 }' | sed -e 's_/__') - MILESTONE=$(echo "${COMMENT_BODY}" | awk '{ print $2 }') - NEW_TITLE="[${TYPE}] ${ORIGINAL_TITLE}" - if [[ $MILESTONE =~ (v[0-9]\.[0-9]+) ]]; then - NEW_TITLE="[${TYPE} ${MILESTONE}] ${ORIGINAL_TITLE}" - fi - additional_cmd+=("--label") - additional_cmd+=("QA/None") - ORIGINAL_LABELS=$(gh issue view -R ${GITHUB_REPOSITORY} ${ORIGINAL_ISSUE_NUMBER} --json labels --jq '.labels[].name' | grep -v '^\[zube\]:' | paste -sd "," -) - if [ -n "$ORIGINAL_LABELS" ]; then - additional_cmd+=("--label") - additional_cmd+=("${ORIGINAL_LABELS}") - fi - ORIGINAL_PROJECT=$(gh issue view -R ${GITHUB_REPOSITORY} ${ORIGINAL_ISSUE_NUMBER} --json projectItems --jq '.projectItems[].title') - if [ -n "$ORIGINAL_PROJECT" ]; then - additional_cmd+=("--project") - additional_cmd+=("${ORIGINAL_PROJECT}") - fi - ASSIGNEES=$(echo "${ORIGINAL_ISSUE}" | jq -r .assignees[].login) - if [ -n "$ASSIGNEES" ]; then - echo "Checking if assignee is member before assigning" - DELIMITER="" - NEW_ASSIGNEES="" - for ASSIGNEE in $ASSIGNEES; do - if gh api orgs/${GITHUB_REPOSITORY_OWNER}/members --paginate | jq -e --arg GITHUB_ACTOR "$GITHUB_ACTOR" '.[] | select(.login == $GITHUB_ACTOR)' > /dev/null; then - echo "${ASSIGNEE} is a member, adding to assignees" - NEW_ASSIGNEES="${NEW_ASSIGNEES}${DELIMITER}${ASSIGNEE}" - DELIMITER="," - fi - done - if [ -n "$NEW_ASSIGNEES" ]; then - echo "Assignees for new issue: ${NEW_ASSIGNEES}" - additional_cmd+=("--assignee") - additional_cmd+=("${NEW_ASSIGNEES}") - fi - fi - if [ -n "$MILESTONE" ]; then - echo -e "This is a ${TYPE} issue for #${ORIGINAL_ISSUE_NUMBER}, automatically created via [GitHub Actions workflow]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) initiated by @${GITHUB_ACTOR}\n" > $BODY - echo -e "\nOriginal issue body:\n" >> $BODY - echo "${ORIGINAL_ISSUE}" | jq -r '.body[0:65536]' >> $BODY - NEW_ISSUE=$(gh issue create -R "${GITHUB_REPOSITORY}" --title "${NEW_TITLE}" --body-file "${BODY}" -m "${MILESTONE}" "${additional_cmd[@]}") - echo "Port issue created: ${NEW_ISSUE}" >> $GITHUB_STEP_SUMMARY - fi \ No newline at end of file diff --git a/.github/workflows/port-pr.yaml b/.github/workflows/port-pr.yaml deleted file mode 100644 index 597647307ca..00000000000 --- a/.github/workflows/port-pr.yaml +++ /dev/null @@ -1,117 +0,0 @@ -name: Port PR - -on: - issue_comment: - types: - - created - -jobs: - port-pr: - runs-on: ubuntu-latest - if: (startsWith(github.event.comment.body, '/backport') || startsWith(github.event.comment.body, '/forwardport')) && github.event.issue.pull_request - steps: - - name: Check org membership - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - if gh api orgs/${GITHUB_REPOSITORY_OWNER}/members --paginate | jq -e --arg GITHUB_ACTOR "$GITHUB_ACTOR" '.[] | select(.login == $GITHUB_ACTOR)' > /dev/null; then - echo "${GITHUB_ACTOR} is a member" - echo "is_member=true" >> $GITHUB_ENV - else - echo "${GITHUB_ACTOR} is not a member" >> $GITHUB_STEP_SUMMARY - echo "is_member=false" >> $GITHUB_ENV - fi - - name: Check milestone - if: ${{ env.is_member == 'true' }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ORIGINAL_ISSUE_NUMBER: ${{ github.event.issue.number }} - COMMENT_BODY: ${{ github.event.comment.body }} - run: | - BODY_MILESTONE=$(echo "${COMMENT_BODY}" | awk '{ print $2 }') - # Sanitize input - MILESTONE=${BODY_MILESTONE//[^a-zA-Z0-9\-\.]/} - if gh api repos/${GITHUB_REPOSITORY}/milestones --paginate | jq -e --arg MILESTONE "$MILESTONE" '.[] | select(.title == $MILESTONE)' > /dev/null; then - echo "Milestone exists" - echo "milestone_exists=true" >> $GITHUB_ENV - echo "milestone=${MILESTONE}" >> $GITHUB_ENV - else - echo "Milestone ${MILESTONE} does not exist" >> $GITHUB_STEP_SUMMARY - gh issue comment -R ${GITHUB_REPOSITORY} ${ORIGINAL_ISSUE_NUMBER} --body "Not creating port issue, milestone ${MILESTONE} does not exist or is not an open milestone" - echo "milestone_exists=false" >> $GITHUB_ENV - fi - - name: Get target branch - if: ${{ env.is_member == 'true' }} && ${{ env.milestone_exists == 'true' }} - env: - COMMENT_BODY: ${{ github.event.comment.body }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - TYPE=$(echo "${COMMENT_BODY}" | awk '{ print $1 }' | sed -e 's_/__') - echo "Type: ${TYPE}" >> $GITHUB_STEP_SUMMARY - echo "type=${TYPE}" >> $GITHUB_ENV - TARGET_BRANCH=$(echo "${COMMENT_BODY}" | awk '{ print $3 }') - echo "Target brach: ${TARGET_BRANCH}" >> $GITHUB_STEP_SUMMARY - echo "target_branch=${TARGET_BRANCH}" >> $GITHUB_ENV - if gh api repos/${GITHUB_REPOSITORY}/branches --paginate | jq -e --arg TARGET_BRANCH "$TARGET_BRANCH" '.[] | select(.name == $TARGET_BRANCH)' > /dev/null; then - echo "target_branch_exists=true" >> $GITHUB_ENV - else - echo "target_branch_exists=false" >> $GITHUB_ENV - fi - - name: Checkout - if: ${{ env.is_member == 'true' }} && ${{ env.milestone_exists == 'true' }} && ${{ env.target_branch_exists == 'true' }} - uses: actions/checkout@v4 - with: - ref: ${{ env.target_branch }} - fetch-depth: '0' - token: ${{ secrets.GITHUB_TOKEN }} - - name: Port PR - if: ${{ env.is_member == 'true' }} && ${{ env.milestone_exists == 'true' }} && ${{ env.target_branch_exists == 'true' }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ORIGINAL_ISSUE_NUMBER: ${{ github.event.issue.number }} - TYPE: ${{ env.type }} - TARGET_BRANCH: ${{ env.target_branch }} - MILESTONE: ${{ env.milestone }} - run: | - PATCH_FILE=$(mktemp) - gh pr diff $ORIGINAL_ISSUE_NUMBER --patch > $PATCH_FILE - BRANCH="gha-portpr-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" - echo "branch=${BRANCH}" >> $GITHUB_ENV - git config --global user.email "rancherdashboardportbot@suse.com" - git config --global user.name "Rancher Dashboard Port Bot" - git checkout -b $BRANCH - - if ! git am -3 "$PATCH_FILE" > error.log 2>&1; then - ERROR_MESSAGE=$(cat error.log) - FORMATTED_ERROR_MESSAGE=$(printf "\n\`\`\`\n%s\n\`\`\`" "$ERROR_MESSAGE") - gh issue comment ${ORIGINAL_ISSUE_NUMBER} --body "Not creating port PR, there was an error running git am -3: $FORMATTED_ERROR_MESSAGE" - else - git push origin $BRANCH - ORIGINAL_PR=$(gh pr view ${ORIGINAL_ISSUE_NUMBER} --json title,body,assignees) - ORIGINAL_TITLE=$(echo "${ORIGINAL_PR}" | jq -r .title) - ORIGINAL_ASSIGNEE=$(echo "${ORIGINAL_PR}" | jq -r '.assignee.login // empty') - BODY=$(mktemp) - echo -e "This is an automated request to port PR #${ORIGINAL_ISSUE_NUMBER} by @${GITHUB_ACTOR}\n\n" > $BODY - echo -e "Original PR body:\n\n" >> $BODY - echo "${ORIGINAL_PR}" | jq -r .body >> $BODY - ASSIGNEES=$(echo "${ORIGINAL_PR}" | jq -r .assignees[].login) - if [ -n "$ASSIGNEES" ]; then - echo "Checking if assignee is member before assigning" - DELIMITER="" - NEW_ASSIGNEES="" - for ASSIGNEE in $ASSIGNEES; do - if gh api orgs/${GITHUB_REPOSITORY_OWNER}/members --paginate | jq -e --arg GITHUB_ACTOR "$GITHUB_ACTOR" '.[] | select(.login == $GITHUB_ACTOR)' > /dev/null; then - echo "${ASSIGNEE} is a member, adding to assignees" - NEW_ASSIGNEES="${NEW_ASSIGNEES}${DELIMITER}${ASSIGNEE}" - DELIMITER="," - fi - done - if [ -n "$NEW_ASSIGNEES" ]; then - echo "Assignees for new issue: ${NEW_ASSIGNEES}" - additional_cmd+=("--assignee") - additional_cmd+=("${NEW_ASSIGNEES}") - fi - fi - NEW_PR=$(gh pr create --title="[${TYPE} ${MILESTONE}] ${ORIGINAL_TITLE}" --body-file="${BODY}" --head "${BRANCH}" --base "${TARGET_BRANCH}" --milestone "${MILESTONE}" "${additional_cmd[@]}") - echo "Port PR created: ${NEW_PR}" >> $GITHUB_STEP_SUMMARY - fi diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index baff34e678a..4d6d17e3588 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -71,15 +71,7 @@ jobs: { username: 'standard_user', tag: '@standardUser' } ] features: [ - # ['@navigation', '@extensions'], - # ['@charts'], - ['@explorer'], - # ['@fleet'], - # ['@generic', '@globalSettings'], - # ['@manager'], - # ['@userMenu', '@usersAndAuths'], - # ['@components'], - # ['@vai'] + ['@explorer'] ] runs-on: ubuntu-latest steps: diff --git a/package.json b/package.json index 153726eb3b9..4c69139d5ea 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "e2e:pre-dev": "yarn docker:local:stop && yarn docker:local:start && NODE_ENV=dev TEST_INSTRUMENT=true yarn build", "e2e:dev": "START_SERVER_AND_TEST_INSECURE=1 server-test start:dev https-get://localhost:8005 cy:run:sorry", "e2e:build": "mkdir dist && TEST_INSTRUMENT=true ./scripts/build-e2e", - "e2e:docker": "yarn docker:local:stop && ./scripts/e2e-docker-start", + "e2e:docker": 'yarn docker:local:stop && echo "before script" && echo "RANCHER_VERSION_E2E=${RANCHER_VERSION_E2E}" && ./scripts/e2e-docker-start', "e2e:prod": "BUILD_DASHBOARD=$BUILD_DASHBOARD GREP_TAGS=$GREP_TAGS TEST_USERNAME=$TEST_USERNAME TEST_BASE_URL=https://127.0.0.1/dashboard yarn cy:run:sorry", "coverage": "npx nyc merge coverage coverage/coverage.json", "storybook": "cd storybook && yarn install && yarn storybook", diff --git a/scripts/e2e-docker-start b/scripts/e2e-docker-start index bc66ab8018b..61f96ea53ce 100755 --- a/scripts/e2e-docker-start +++ b/scripts/e2e-docker-start @@ -10,6 +10,9 @@ EMBER_DIST=${DIR}/dist_ember RANCHER_IMG_VERSION=v2.9-head HAS_ARGS="false" +echo "on my sript" +echo "RANCHER_VERSION_E2E=${RANCHER_VERSION_E2E}" + # check if script invoke contains any argument... # if [ $# -eq 1 ]; then if [ -z "$RANCHER_VERSION_E2E" ]; then From 2faed31ac38661974c0ebedf1ec0d6de3c5ccfe8 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 25 Jul 2024 11:09:06 +0100 Subject: [PATCH 09/46] Revert "script adjustment/fix" This reverts commit 48a13ef3554da045850f88b43ace5edfee99e03d. --- .github/workflows/add-issue-labels.yaml | 6 + .../workflows/build-and-upload-branch.yaml | 22 ++++ .../workflows/build-and-upload-release.yaml | 4 + .github/workflows/build-and-upload.yaml | 12 ++ .github/workflows/build-extension-catalog.yml | 12 ++ .github/workflows/build-extension-charts.yml | 12 ++ .github/workflows/build-test.yaml | 37 ++++++ .github/workflows/check-plugins.yaml | 4 + .github/workflows/docusaurus.yaml | 6 + .github/workflows/fossa.yaml | 44 +++++++ .github/workflows/port-issue.yaml | 103 +++++++++++++++ .github/workflows/port-pr.yaml | 117 ++++++++++++++++++ .github/workflows/pr-gh-project.yaml | 6 + .github/workflows/rancher-components.yaml | 12 ++ .../workflows/release-rancher-components.yml | 6 + .github/workflows/release-rancher-desktop.yml | 58 +++++++++ .github/workflows/release-shell-pkg.yaml | 12 ++ .github/workflows/storybook.yaml | 4 + .github/workflows/test.yaml | 10 +- package.json | 2 +- scripts/e2e-docker-start | 3 - 21 files changed, 487 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/build-and-upload-branch.yaml create mode 100644 .github/workflows/build-test.yaml create mode 100644 .github/workflows/fossa.yaml create mode 100644 .github/workflows/port-issue.yaml create mode 100644 .github/workflows/port-pr.yaml create mode 100644 .github/workflows/release-rancher-desktop.yml diff --git a/.github/workflows/add-issue-labels.yaml b/.github/workflows/add-issue-labels.yaml index 8db01a51cc0..075ac5d99fa 100644 --- a/.github/workflows/add-issue-labels.yaml +++ b/.github/workflows/add-issue-labels.yaml @@ -11,9 +11,15 @@ jobs: steps: - uses: actions/checkout@v2 - name: Use Node.js +<<<<<<< HEAD uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' +======= + uses: actions/setup-node@v1 + with: + node-version: '16.x' +>>>>>>> b7384b5fad (Revert "script adjustment/fix") - name: script env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/build-and-upload-branch.yaml b/.github/workflows/build-and-upload-branch.yaml new file mode 100644 index 00000000000..4604de6d0e7 --- /dev/null +++ b/.github/workflows/build-and-upload-branch.yaml @@ -0,0 +1,22 @@ +name: Build Dashboard (Branch) +on: + push: + branches: + - master + - 'release-*' + - '*-dev' + +jobs: + build-validation: + name: Build Test + uses: ./.github/workflows/build-test.yaml + build: + name: Build and Upload + uses: ./.github/workflows/build-and-upload.yaml + needs: + - build-validation + permissions: + contents: 'read' + id-token: 'write' + with: + CI_BRANCH: ${{github.ref_name}} diff --git a/.github/workflows/build-and-upload-release.yaml b/.github/workflows/build-and-upload-release.yaml index 7f514d00fda..d9b3f1f7f5e 100644 --- a/.github/workflows/build-and-upload-release.yaml +++ b/.github/workflows/build-and-upload-release.yaml @@ -2,7 +2,11 @@ name: Build Dashboard (Release) on: push: tags: +<<<<<<< HEAD - v2.* +======= + - v2.9.* +>>>>>>> b7384b5fad (Revert "script adjustment/fix") jobs: build-validation: diff --git a/.github/workflows/build-and-upload.yaml b/.github/workflows/build-and-upload.yaml index 434ca3bef7a..3ca35d98bd2 100644 --- a/.github/workflows/build-and-upload.yaml +++ b/.github/workflows/build-and-upload.yaml @@ -27,9 +27,15 @@ jobs: fetch-depth: 1 # Note - Cannot use the setup action here as it uses a different yarn install arg +<<<<<<< HEAD - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' +======= + - uses: actions/setup-node@v3 + with: + node-version: '14.x' +>>>>>>> b7384b5fad (Revert "script adjustment/fix") cache: 'yarn' # Build a directory containing the dashboard that can be used with ui-dashboard-index @@ -74,9 +80,15 @@ jobs: fetch-depth: 1 # Note - Cannot use the setup action here as it uses a different yarn install arg +<<<<<<< HEAD - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' +======= + - uses: actions/setup-node@v3 + with: + node-version: '14.x' +>>>>>>> b7384b5fad (Revert "script adjustment/fix") cache: 'yarn' # Build a tar that will be picked up by rancher builds and embedded into it diff --git a/.github/workflows/build-extension-catalog.yml b/.github/workflows/build-extension-catalog.yml index bbd6bbd6ed7..18698a41c86 100644 --- a/.github/workflows/build-extension-catalog.yml +++ b/.github/workflows/build-extension-catalog.yml @@ -48,17 +48,29 @@ jobs: version: v3.8.0 - name: Setup Nodejs and npm +<<<<<<< HEAD uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' +======= + uses: actions/setup-node@v3 + with: + node-version: '16' +>>>>>>> b7384b5fad (Revert "script adjustment/fix") - name: Setup yarn run: npm install -g yarn - name: Setup Nodejs with yarn caching +<<<<<<< HEAD uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' +======= + uses: actions/setup-node@v3 + with: + node-version: '16' +>>>>>>> b7384b5fad (Revert "script adjustment/fix") cache: yarn - name: Install dependencies diff --git a/.github/workflows/build-extension-charts.yml b/.github/workflows/build-extension-charts.yml index a1ffe2d6212..72fb2cc762b 100644 --- a/.github/workflows/build-extension-charts.yml +++ b/.github/workflows/build-extension-charts.yml @@ -43,17 +43,29 @@ jobs: version: v3.8.0 - name: Setup Nodejs and npm +<<<<<<< HEAD uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' +======= + uses: actions/setup-node@v3 + with: + node-version: '16' +>>>>>>> b7384b5fad (Revert "script adjustment/fix") - name: Setup yarn run: npm install -g yarn - name: Setup Nodejs with yarn caching +<<<<<<< HEAD uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' +======= + uses: actions/setup-node@v3 + with: + node-version: '16' +>>>>>>> b7384b5fad (Revert "script adjustment/fix") cache: yarn - name: Install dependencies diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml new file mode 100644 index 00000000000..b8ba454680f --- /dev/null +++ b/.github/workflows/build-test.yaml @@ -0,0 +1,37 @@ +# Validation steps required before a build occurs. Not designed to replace the CI test workflow +name: Build Test + +on: + # This tells GH that the workflow is reusable + workflow_call: + +jobs: + unit-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Run tests + uses: ./.github/actions/unit-tests + + i18n: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Run i18n lint + uses: ./.github/actions/i18n-lint + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Run lint + uses: ./.github/actions/lint diff --git a/.github/workflows/check-plugins.yaml b/.github/workflows/check-plugins.yaml index 75fd2a2a923..1dc63495047 100644 --- a/.github/workflows/check-plugins.yaml +++ b/.github/workflows/check-plugins.yaml @@ -14,7 +14,11 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: +<<<<<<< HEAD node-version-file: '.nvmrc' +======= + node-version: '16.20.2' +>>>>>>> b7384b5fad (Revert "script adjustment/fix") - name: Validate Plugin build system run: ./shell/scripts/test-plugins-build.sh shell: bash diff --git a/.github/workflows/docusaurus.yaml b/.github/workflows/docusaurus.yaml index 8204dc40fb5..7ce8ee1956c 100644 --- a/.github/workflows/docusaurus.yaml +++ b/.github/workflows/docusaurus.yaml @@ -13,9 +13,15 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 +<<<<<<< HEAD - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' +======= + - uses: actions/setup-node@v3 + with: + node-version: 16.x +>>>>>>> b7384b5fad (Revert "script adjustment/fix") cache: yarn - name: Install dependencies diff --git a/.github/workflows/fossa.yaml b/.github/workflows/fossa.yaml new file mode 100644 index 00000000000..9b01c6d418b --- /dev/null +++ b/.github/workflows/fossa.yaml @@ -0,0 +1,44 @@ +name: FOSSA Scanning + +on: + # List the branches that must be scanned when a push event happens. + push: + branches: ["master", "release-*"] + # For manual scans. + workflow_dispatch: + +permissions: + # Basic read access needed. + contents: read + # Required to authenticate in EIO's Vault. + id-token: write + +jobs: + fossa-scanning: + # For when running in EIO's provided runners. More details are available in + # https://github.com/rancherlabs/eio/wiki/GitHub-Actions-Runners . + runs-on: org-${{ github.repository_owner_id }}-amd64-k8s + # Use the BCI Node.js container when running in EIO's provided runners, + # because the Node.js runtime is needed. If using public GH provided runners, + # a container isn't necessary, because they already provide the runtime, but + # the BCI image can still be used anyway. + container: registry.suse.com/bci/nodejs:20 + steps: + - name: Checkout + uses: actions/checkout@v4 + + # The FOSSA token is shared between all repos in Rancher's GH org. It can + # be used directly and there is no need to request specific access to EIO. + - name: Read FOSSA token + uses: rancher-eio/read-vault-secrets@main + with: + secrets: | + secret/data/github/org/rancher/fossa/push token | FOSSA_API_KEY_PUSH_ONLY + + - name: FOSSA scan + uses: fossas/fossa-action@main + with: + api-key: ${{ env.FOSSA_API_KEY_PUSH_ONLY }} + # Only runs the scan and do not provide/returns any results back to the + # pipeline. + run-tests: false \ No newline at end of file diff --git a/.github/workflows/port-issue.yaml b/.github/workflows/port-issue.yaml new file mode 100644 index 00000000000..2c59dc61195 --- /dev/null +++ b/.github/workflows/port-issue.yaml @@ -0,0 +1,103 @@ +# create a backport/forwardport of an issue when "/backport " is commented +name: Port issue +run-name: "Port issue ${{ github.event.issue.number }}: ${{ github.event.issue.title }}" + +on: + issue_comment: + types: + - created + +jobs: + port-issue: + runs-on: ubuntu-latest + if: contains(github.event.comment.body, '/backport') || contains(github.event.comment.body, '/forwardport') + steps: + - name: Check org membership + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if gh api orgs/${GITHUB_REPOSITORY_OWNER}/members --paginate | jq -e --arg GITHUB_ACTOR "$GITHUB_ACTOR" '.[] | select(.login == $GITHUB_ACTOR)' > /dev/null; then + echo "${GITHUB_ACTOR} is a member" + echo "is_member=true" >> $GITHUB_ENV + else + echo "${GITHUB_ACTOR} is not a member of ${GITHUB_REPOSITORY_OWNER}" >> $GITHUB_STEP_SUMMARY + echo "is_member=false" >> $GITHUB_ENV + fi + - name: Check milestone + if: env.is_member == 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ORIGINAL_ISSUE_NUMBER: ${{ github.event.issue.number }} + COMMENT_BODY: ${{ github.event.comment.body }} + run: | + BODY_MILESTONE=$(echo "${COMMENT_BODY}" | awk '{ print $2 }') + echo "BODY_MILESTONE '${BODY_MILESTONE}'" + + # Sanitize input + MILESTONE=${BODY_MILESTONE//[^a-zA-Z0-9\-\.]/} + echo "MILESTONE '${MILESTONE}'" + + if gh api repos/${GITHUB_REPOSITORY}/milestones --paginate | jq -e --arg MILESTONE "$MILESTONE" '.[] | select(.title == $MILESTONE)' > /dev/null; then + echo "Milestone '${MILESTONE}' exists" + echo "milestone_exists=true" >> $GITHUB_ENV + else + echo "Milestone '${MILESTONE}' does not exist" >> $GITHUB_STEP_SUMMARY + gh issue comment -R ${GITHUB_REPOSITORY} ${ORIGINAL_ISSUE_NUMBER} --body "Not creating port issue, milestone ${MILESTONE} does not exist or is not an open milestone" + echo "milestone_exists=false" >> $GITHUB_ENV + fi + - name: Port issue + if: | + env.is_member == 'true' && + env.milestone_exists == 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ORIGINAL_ISSUE_NUMBER: ${{ github.event.issue.number }} + COMMENT_BODY: ${{ github.event.comment.body }} + run: | + declare -a additional_cmd + BODY=$(mktemp) + ORIGINAL_ISSUE=$(gh issue view -R ${GITHUB_REPOSITORY} ${ORIGINAL_ISSUE_NUMBER} --json title,body,assignees) + ORIGINAL_TITLE=$(echo "${ORIGINAL_ISSUE}" | jq -r .title) + TYPE=$(echo "${COMMENT_BODY}" | awk '{ print $1 }' | sed -e 's_/__') + MILESTONE=$(echo "${COMMENT_BODY}" | awk '{ print $2 }') + NEW_TITLE="[${TYPE}] ${ORIGINAL_TITLE}" + if [[ $MILESTONE =~ (v[0-9]\.[0-9]+) ]]; then + NEW_TITLE="[${TYPE} ${MILESTONE}] ${ORIGINAL_TITLE}" + fi + additional_cmd+=("--label") + additional_cmd+=("QA/None") + ORIGINAL_LABELS=$(gh issue view -R ${GITHUB_REPOSITORY} ${ORIGINAL_ISSUE_NUMBER} --json labels --jq '.labels[].name' | grep -v '^\[zube\]:' | paste -sd "," -) + if [ -n "$ORIGINAL_LABELS" ]; then + additional_cmd+=("--label") + additional_cmd+=("${ORIGINAL_LABELS}") + fi + ORIGINAL_PROJECT=$(gh issue view -R ${GITHUB_REPOSITORY} ${ORIGINAL_ISSUE_NUMBER} --json projectItems --jq '.projectItems[].title') + if [ -n "$ORIGINAL_PROJECT" ]; then + additional_cmd+=("--project") + additional_cmd+=("${ORIGINAL_PROJECT}") + fi + ASSIGNEES=$(echo "${ORIGINAL_ISSUE}" | jq -r .assignees[].login) + if [ -n "$ASSIGNEES" ]; then + echo "Checking if assignee is member before assigning" + DELIMITER="" + NEW_ASSIGNEES="" + for ASSIGNEE in $ASSIGNEES; do + if gh api orgs/${GITHUB_REPOSITORY_OWNER}/members --paginate | jq -e --arg GITHUB_ACTOR "$GITHUB_ACTOR" '.[] | select(.login == $GITHUB_ACTOR)' > /dev/null; then + echo "${ASSIGNEE} is a member, adding to assignees" + NEW_ASSIGNEES="${NEW_ASSIGNEES}${DELIMITER}${ASSIGNEE}" + DELIMITER="," + fi + done + if [ -n "$NEW_ASSIGNEES" ]; then + echo "Assignees for new issue: ${NEW_ASSIGNEES}" + additional_cmd+=("--assignee") + additional_cmd+=("${NEW_ASSIGNEES}") + fi + fi + if [ -n "$MILESTONE" ]; then + echo -e "This is a ${TYPE} issue for #${ORIGINAL_ISSUE_NUMBER}, automatically created via [GitHub Actions workflow]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) initiated by @${GITHUB_ACTOR}\n" > $BODY + echo -e "\nOriginal issue body:\n" >> $BODY + echo "${ORIGINAL_ISSUE}" | jq -r '.body[0:65536]' >> $BODY + NEW_ISSUE=$(gh issue create -R "${GITHUB_REPOSITORY}" --title "${NEW_TITLE}" --body-file "${BODY}" -m "${MILESTONE}" "${additional_cmd[@]}") + echo "Port issue created: ${NEW_ISSUE}" >> $GITHUB_STEP_SUMMARY + fi \ No newline at end of file diff --git a/.github/workflows/port-pr.yaml b/.github/workflows/port-pr.yaml new file mode 100644 index 00000000000..597647307ca --- /dev/null +++ b/.github/workflows/port-pr.yaml @@ -0,0 +1,117 @@ +name: Port PR + +on: + issue_comment: + types: + - created + +jobs: + port-pr: + runs-on: ubuntu-latest + if: (startsWith(github.event.comment.body, '/backport') || startsWith(github.event.comment.body, '/forwardport')) && github.event.issue.pull_request + steps: + - name: Check org membership + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if gh api orgs/${GITHUB_REPOSITORY_OWNER}/members --paginate | jq -e --arg GITHUB_ACTOR "$GITHUB_ACTOR" '.[] | select(.login == $GITHUB_ACTOR)' > /dev/null; then + echo "${GITHUB_ACTOR} is a member" + echo "is_member=true" >> $GITHUB_ENV + else + echo "${GITHUB_ACTOR} is not a member" >> $GITHUB_STEP_SUMMARY + echo "is_member=false" >> $GITHUB_ENV + fi + - name: Check milestone + if: ${{ env.is_member == 'true' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ORIGINAL_ISSUE_NUMBER: ${{ github.event.issue.number }} + COMMENT_BODY: ${{ github.event.comment.body }} + run: | + BODY_MILESTONE=$(echo "${COMMENT_BODY}" | awk '{ print $2 }') + # Sanitize input + MILESTONE=${BODY_MILESTONE//[^a-zA-Z0-9\-\.]/} + if gh api repos/${GITHUB_REPOSITORY}/milestones --paginate | jq -e --arg MILESTONE "$MILESTONE" '.[] | select(.title == $MILESTONE)' > /dev/null; then + echo "Milestone exists" + echo "milestone_exists=true" >> $GITHUB_ENV + echo "milestone=${MILESTONE}" >> $GITHUB_ENV + else + echo "Milestone ${MILESTONE} does not exist" >> $GITHUB_STEP_SUMMARY + gh issue comment -R ${GITHUB_REPOSITORY} ${ORIGINAL_ISSUE_NUMBER} --body "Not creating port issue, milestone ${MILESTONE} does not exist or is not an open milestone" + echo "milestone_exists=false" >> $GITHUB_ENV + fi + - name: Get target branch + if: ${{ env.is_member == 'true' }} && ${{ env.milestone_exists == 'true' }} + env: + COMMENT_BODY: ${{ github.event.comment.body }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + TYPE=$(echo "${COMMENT_BODY}" | awk '{ print $1 }' | sed -e 's_/__') + echo "Type: ${TYPE}" >> $GITHUB_STEP_SUMMARY + echo "type=${TYPE}" >> $GITHUB_ENV + TARGET_BRANCH=$(echo "${COMMENT_BODY}" | awk '{ print $3 }') + echo "Target brach: ${TARGET_BRANCH}" >> $GITHUB_STEP_SUMMARY + echo "target_branch=${TARGET_BRANCH}" >> $GITHUB_ENV + if gh api repos/${GITHUB_REPOSITORY}/branches --paginate | jq -e --arg TARGET_BRANCH "$TARGET_BRANCH" '.[] | select(.name == $TARGET_BRANCH)' > /dev/null; then + echo "target_branch_exists=true" >> $GITHUB_ENV + else + echo "target_branch_exists=false" >> $GITHUB_ENV + fi + - name: Checkout + if: ${{ env.is_member == 'true' }} && ${{ env.milestone_exists == 'true' }} && ${{ env.target_branch_exists == 'true' }} + uses: actions/checkout@v4 + with: + ref: ${{ env.target_branch }} + fetch-depth: '0' + token: ${{ secrets.GITHUB_TOKEN }} + - name: Port PR + if: ${{ env.is_member == 'true' }} && ${{ env.milestone_exists == 'true' }} && ${{ env.target_branch_exists == 'true' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ORIGINAL_ISSUE_NUMBER: ${{ github.event.issue.number }} + TYPE: ${{ env.type }} + TARGET_BRANCH: ${{ env.target_branch }} + MILESTONE: ${{ env.milestone }} + run: | + PATCH_FILE=$(mktemp) + gh pr diff $ORIGINAL_ISSUE_NUMBER --patch > $PATCH_FILE + BRANCH="gha-portpr-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" + echo "branch=${BRANCH}" >> $GITHUB_ENV + git config --global user.email "rancherdashboardportbot@suse.com" + git config --global user.name "Rancher Dashboard Port Bot" + git checkout -b $BRANCH + + if ! git am -3 "$PATCH_FILE" > error.log 2>&1; then + ERROR_MESSAGE=$(cat error.log) + FORMATTED_ERROR_MESSAGE=$(printf "\n\`\`\`\n%s\n\`\`\`" "$ERROR_MESSAGE") + gh issue comment ${ORIGINAL_ISSUE_NUMBER} --body "Not creating port PR, there was an error running git am -3: $FORMATTED_ERROR_MESSAGE" + else + git push origin $BRANCH + ORIGINAL_PR=$(gh pr view ${ORIGINAL_ISSUE_NUMBER} --json title,body,assignees) + ORIGINAL_TITLE=$(echo "${ORIGINAL_PR}" | jq -r .title) + ORIGINAL_ASSIGNEE=$(echo "${ORIGINAL_PR}" | jq -r '.assignee.login // empty') + BODY=$(mktemp) + echo -e "This is an automated request to port PR #${ORIGINAL_ISSUE_NUMBER} by @${GITHUB_ACTOR}\n\n" > $BODY + echo -e "Original PR body:\n\n" >> $BODY + echo "${ORIGINAL_PR}" | jq -r .body >> $BODY + ASSIGNEES=$(echo "${ORIGINAL_PR}" | jq -r .assignees[].login) + if [ -n "$ASSIGNEES" ]; then + echo "Checking if assignee is member before assigning" + DELIMITER="" + NEW_ASSIGNEES="" + for ASSIGNEE in $ASSIGNEES; do + if gh api orgs/${GITHUB_REPOSITORY_OWNER}/members --paginate | jq -e --arg GITHUB_ACTOR "$GITHUB_ACTOR" '.[] | select(.login == $GITHUB_ACTOR)' > /dev/null; then + echo "${ASSIGNEE} is a member, adding to assignees" + NEW_ASSIGNEES="${NEW_ASSIGNEES}${DELIMITER}${ASSIGNEE}" + DELIMITER="," + fi + done + if [ -n "$NEW_ASSIGNEES" ]; then + echo "Assignees for new issue: ${NEW_ASSIGNEES}" + additional_cmd+=("--assignee") + additional_cmd+=("${NEW_ASSIGNEES}") + fi + fi + NEW_PR=$(gh pr create --title="[${TYPE} ${MILESTONE}] ${ORIGINAL_TITLE}" --body-file="${BODY}" --head "${BRANCH}" --base "${TARGET_BRANCH}" --milestone "${MILESTONE}" "${additional_cmd[@]}") + echo "Port PR created: ${NEW_PR}" >> $GITHUB_STEP_SUMMARY + fi diff --git a/.github/workflows/pr-gh-project.yaml b/.github/workflows/pr-gh-project.yaml index 971dc8c265a..3d8627d8847 100644 --- a/.github/workflows/pr-gh-project.yaml +++ b/.github/workflows/pr-gh-project.yaml @@ -14,9 +14,15 @@ jobs: steps: - uses: actions/checkout@v2 - name: Use Node.js +<<<<<<< HEAD uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' +======= + uses: actions/setup-node@v1 + with: + node-version: '16.x' +>>>>>>> b7384b5fad (Revert "script adjustment/fix") - name: Read secrets uses: rancher-eio/read-vault-secrets@main with: diff --git a/.github/workflows/rancher-components.yaml b/.github/workflows/rancher-components.yaml index 5f20eb5aedf..ade60ebac7b 100644 --- a/.github/workflows/rancher-components.yaml +++ b/.github/workflows/rancher-components.yaml @@ -13,9 +13,15 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 1 +<<<<<<< HEAD - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' +======= + - uses: actions/setup-node@v3 + with: + node-version: '14.x' +>>>>>>> b7384b5fad (Revert "script adjustment/fix") - name: Install packages run: yarn install @@ -29,9 +35,15 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 1 +<<<<<<< HEAD - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' +======= + - uses: actions/setup-node@v3 + with: + node-version: '14.x' +>>>>>>> b7384b5fad (Revert "script adjustment/fix") - name: Install packages run: yarn install diff --git a/.github/workflows/release-rancher-components.yml b/.github/workflows/release-rancher-components.yml index 28313b443b7..a06afff717b 100644 --- a/.github/workflows/release-rancher-components.yml +++ b/.github/workflows/release-rancher-components.yml @@ -17,9 +17,15 @@ jobs: fetch-depth: 0 persist-credentials: false +<<<<<<< HEAD - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' +======= + - uses: actions/setup-node@v3 + with: + node-version: '16.x' +>>>>>>> b7384b5fad (Revert "script adjustment/fix") registry-url: 'https://registry.npmjs.org' scope: '@rancher' diff --git a/.github/workflows/release-rancher-desktop.yml b/.github/workflows/release-rancher-desktop.yml new file mode 100644 index 00000000000..4b6e149222b --- /dev/null +++ b/.github/workflows/release-rancher-desktop.yml @@ -0,0 +1,58 @@ +name: Build and Release Rancher Dashboard - Rancher Desktop Embed + +on: + push: + tags: + - 'desktop-v*' + +env: + OUTPUT_DIR: dist + RELEASE_DIR: release + ARTIFACT_NAME: rancher-dashboard-desktop-embed + API: "https://127.0.0.1:9443" + RESOURCE_BASE: "https://127.0.0.1:9443" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + persist-credentials: false + + - uses: actions/setup-node@v2 + with: + node-version: '12.x' + + - name: Install & Build + run: + ROUTER_BASE="/dashboard" RANCHER_ENV=desktop ./.github/workflows/scripts/build-dashboard.sh + + - name: Upload Build + uses: actions/upload-artifact@v2 + with: + path: ${{ env.RELEASE_DIR}}/${{ env.ARTIFACT_NAME }}* + name: ${{ env.ARTIFACT_NAME }} + if-no-files-found: error + + release: + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + persist-credentials: false + - name: Download build + uses: actions/download-artifact@v2 + with: + name: ${{ env.ARTIFACT_NAME }} + path: build + - name: Set env + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Upload Release Assets + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload ${{ env.RELEASE_VERSION }} build/${{ env.ARTIFACT_NAME }}.tar.gz build/${{ env.ARTIFACT_NAME }}.tar.gz.sha512sum diff --git a/.github/workflows/release-shell-pkg.yaml b/.github/workflows/release-shell-pkg.yaml index 12e50b6ef20..6ed0543e9d5 100644 --- a/.github/workflows/release-shell-pkg.yaml +++ b/.github/workflows/release-shell-pkg.yaml @@ -17,9 +17,15 @@ jobs: fetch-depth: 0 persist-credentials: false +<<<<<<< HEAD - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' +======= + - uses: actions/setup-node@v3 + with: + node-version: '16.x' +>>>>>>> b7384b5fad (Revert "script adjustment/fix") - name: Validate Plugin build system run: ./shell/scripts/test-plugins-build.sh @@ -35,9 +41,15 @@ jobs: echo $YARN_REGISTRY cat ./shell/package.json +<<<<<<< HEAD - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' +======= + - uses: actions/setup-node@v3 + with: + node-version: '16.x' +>>>>>>> b7384b5fad (Revert "script adjustment/fix") registry-url: 'https://registry.npmjs.org' scope: '@rancher' diff --git a/.github/workflows/storybook.yaml b/.github/workflows/storybook.yaml index b71bc7a58c8..deb66b19bec 100644 --- a/.github/workflows/storybook.yaml +++ b/.github/workflows/storybook.yaml @@ -16,7 +16,11 @@ jobs: - name: Use Node.js uses: actions/setup-node@v4 with: +<<<<<<< HEAD node-version-file: '.nvmrc' +======= + node-version: '16.20.2' +>>>>>>> b7384b5fad (Revert "script adjustment/fix") - name: Install packages run: yarn install - name: Build Storybook diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4d6d17e3588..baff34e678a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -71,7 +71,15 @@ jobs: { username: 'standard_user', tag: '@standardUser' } ] features: [ - ['@explorer'] + # ['@navigation', '@extensions'], + # ['@charts'], + ['@explorer'], + # ['@fleet'], + # ['@generic', '@globalSettings'], + # ['@manager'], + # ['@userMenu', '@usersAndAuths'], + # ['@components'], + # ['@vai'] ] runs-on: ubuntu-latest steps: diff --git a/package.json b/package.json index 4c69139d5ea..153726eb3b9 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "e2e:pre-dev": "yarn docker:local:stop && yarn docker:local:start && NODE_ENV=dev TEST_INSTRUMENT=true yarn build", "e2e:dev": "START_SERVER_AND_TEST_INSECURE=1 server-test start:dev https-get://localhost:8005 cy:run:sorry", "e2e:build": "mkdir dist && TEST_INSTRUMENT=true ./scripts/build-e2e", - "e2e:docker": 'yarn docker:local:stop && echo "before script" && echo "RANCHER_VERSION_E2E=${RANCHER_VERSION_E2E}" && ./scripts/e2e-docker-start', + "e2e:docker": "yarn docker:local:stop && ./scripts/e2e-docker-start", "e2e:prod": "BUILD_DASHBOARD=$BUILD_DASHBOARD GREP_TAGS=$GREP_TAGS TEST_USERNAME=$TEST_USERNAME TEST_BASE_URL=https://127.0.0.1/dashboard yarn cy:run:sorry", "coverage": "npx nyc merge coverage coverage/coverage.json", "storybook": "cd storybook && yarn install && yarn storybook", diff --git a/scripts/e2e-docker-start b/scripts/e2e-docker-start index 61f96ea53ce..bc66ab8018b 100755 --- a/scripts/e2e-docker-start +++ b/scripts/e2e-docker-start @@ -10,9 +10,6 @@ EMBER_DIST=${DIR}/dist_ember RANCHER_IMG_VERSION=v2.9-head HAS_ARGS="false" -echo "on my sript" -echo "RANCHER_VERSION_E2E=${RANCHER_VERSION_E2E}" - # check if script invoke contains any argument... # if [ $# -eq 1 ]; then if [ -z "$RANCHER_VERSION_E2E" ]; then From 890f9756f342c33015503341d526a7f64d38104b Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 25 Jul 2024 11:11:07 +0100 Subject: [PATCH 10/46] script adjustment/fix --- .github/workflows/extensions-compatibility-tests.yaml | 2 +- scripts/e2e-docker-start | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index 4187e632741..c841b696d3b 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -70,7 +70,7 @@ jobs: # this is where docker is set up with the enviroment... - name: Run Rancher 2.8 - run: export RANCHER_VERSION_E2E=v2.8-head; yarn e2e:docker # runs scripts/e2e-docker-start + run: export RANCHER_VERSION_E2E="v2.8-head" && yarn e2e:docker # runs scripts/e2e-docker-start # env: # RANCHER_VERSION_E2E: v2.8-head diff --git a/scripts/e2e-docker-start b/scripts/e2e-docker-start index bc66ab8018b..1269f8afcfd 100755 --- a/scripts/e2e-docker-start +++ b/scripts/e2e-docker-start @@ -10,8 +10,9 @@ EMBER_DIST=${DIR}/dist_ember RANCHER_IMG_VERSION=v2.9-head HAS_ARGS="false" -# check if script invoke contains any argument... -# if [ $# -eq 1 ]; then +echo "on my script" +echo "RANCHER_VERSION_E2E=${RANCHER_VERSION_E2E}" + if [ -z "$RANCHER_VERSION_E2E" ]; then RANCHER_IMG_VERSION=$1 HAS_ARGS="true" From 4ce5f3029a9852c13c5a2a6b40344d21ec4bf05e Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 25 Jul 2024 11:34:49 +0100 Subject: [PATCH 11/46] script adjustment/fix --- package.json | 2 +- scripts/e2e-docker-start | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 153726eb3b9..c7d09fcc7ed 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "e2e:pre-dev": "yarn docker:local:stop && yarn docker:local:start && NODE_ENV=dev TEST_INSTRUMENT=true yarn build", "e2e:dev": "START_SERVER_AND_TEST_INSECURE=1 server-test start:dev https-get://localhost:8005 cy:run:sorry", "e2e:build": "mkdir dist && TEST_INSTRUMENT=true ./scripts/build-e2e", - "e2e:docker": "yarn docker:local:stop && ./scripts/e2e-docker-start", + "e2e:docker": "yarn docker:local:stop && echo 'I am here!!!' && echo $RANCHER_VERSION_E2E && ./scripts/e2e-docker-start $RANCHER_VERSION_E2E", "e2e:prod": "BUILD_DASHBOARD=$BUILD_DASHBOARD GREP_TAGS=$GREP_TAGS TEST_USERNAME=$TEST_USERNAME TEST_BASE_URL=https://127.0.0.1/dashboard yarn cy:run:sorry", "coverage": "npx nyc merge coverage coverage/coverage.json", "storybook": "cd storybook && yarn install && yarn storybook", diff --git a/scripts/e2e-docker-start b/scripts/e2e-docker-start index 1269f8afcfd..0002cb96d9f 100755 --- a/scripts/e2e-docker-start +++ b/scripts/e2e-docker-start @@ -13,7 +13,9 @@ HAS_ARGS="false" echo "on my script" echo "RANCHER_VERSION_E2E=${RANCHER_VERSION_E2E}" -if [ -z "$RANCHER_VERSION_E2E" ]; then +# check if script invoke contains any argument... +# if [ -z "$RANCHER_VERSION_E2E" ]; then +if [ $# -eq 1 ]; then RANCHER_IMG_VERSION=$1 HAS_ARGS="true" fi From 0d9820581ac737d6f750089d8877c4c97db9717a Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 25 Jul 2024 11:51:44 +0100 Subject: [PATCH 12/46] test matrix for multiple envs --- .../extensions-compatibility-tests.yaml | 44 +++++-------------- package.json | 2 +- scripts/e2e-docker-start | 11 ++--- 3 files changed, 14 insertions(+), 43 deletions(-) diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index c841b696d3b..dc4709c68e8 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -7,22 +7,6 @@ on: branches: - master -# on: -# push: -# branches: -# - master -# - 'release-*' -# pull_request: -# branches: -# - master -# - 'release-*' -# workflow_dispatch: -# inputs: -# environment: -# description: 'Environment to run tests against' -# type: environment -# required: true - env: TEST_USERNAME: admin TEST_PASSWORD: password @@ -35,13 +19,8 @@ env: # Build the dashboard to use in tests. When set to false it will grab `latest` from CDN (useful for running e2e tests quickly) BUILD_DASHBOARD: true - # E2E_BUILD_DIST_NAME: dist - # E2E_BUILD_DIST_DIR: dist - # E2E_BUILD_DIST_EMBER_NAME: dist_ember - # E2E_BUILD_DIST_EMBER_DIR: dist_ember - jobs: - e2e-test-rancher-2-dot-8: + e2e-test-extensions-compatibility: if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" strategy: fail-fast: false @@ -55,11 +34,10 @@ jobs: # ['@kubewarden'], # ['@neuvector'] ] - # rancherEnv: [ - # ['v2.7-head'], - # ['v2.8-head'], - # ['v2.9-head'], - # ] + rancherEnv: [ + 'v2.8-head', + 'v2.9-head', + ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -68,13 +46,11 @@ jobs: - name: Setup env uses: ./.github/actions/setup - # this is where docker is set up with the enviroment... - - name: Run Rancher 2.8 - run: export RANCHER_VERSION_E2E="v2.8-head" && yarn e2e:docker # runs scripts/e2e-docker-start - # env: - # RANCHER_VERSION_E2E: v2.8-head + # this is where docker is set up with the enviroment + - name: Run Rancher ${{ matrix.rancherEnv }} + run: export RANCHER_VERSION_E2E=${{ matrix.rancherEnv }} && yarn e2e:docker - ## this is just setting up rancher and user... + ## this is just setting up rancher and user - name: Setup Rancher and user run: | yarn e2e:prod @@ -83,7 +59,7 @@ jobs: TEST_USERNAME: ${{ matrix.role.username }} TEST_ONLY: setup - # This is the actual test runs!!!! + # This is the actual triggering of the e2e test specs - name: Run user tests run: | yarn e2e:prod diff --git a/package.json b/package.json index c7d09fcc7ed..489e2ea7e93 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "e2e:pre-dev": "yarn docker:local:stop && yarn docker:local:start && NODE_ENV=dev TEST_INSTRUMENT=true yarn build", "e2e:dev": "START_SERVER_AND_TEST_INSECURE=1 server-test start:dev https-get://localhost:8005 cy:run:sorry", "e2e:build": "mkdir dist && TEST_INSTRUMENT=true ./scripts/build-e2e", - "e2e:docker": "yarn docker:local:stop && echo 'I am here!!!' && echo $RANCHER_VERSION_E2E && ./scripts/e2e-docker-start $RANCHER_VERSION_E2E", + "e2e:docker": "yarn docker:local:stop && ./scripts/e2e-docker-start $RANCHER_VERSION_E2E", "e2e:prod": "BUILD_DASHBOARD=$BUILD_DASHBOARD GREP_TAGS=$GREP_TAGS TEST_USERNAME=$TEST_USERNAME TEST_BASE_URL=https://127.0.0.1/dashboard yarn cy:run:sorry", "coverage": "npx nyc merge coverage coverage/coverage.json", "storybook": "cd storybook && yarn install && yarn storybook", diff --git a/scripts/e2e-docker-start b/scripts/e2e-docker-start index 0002cb96d9f..21a03a07bef 100755 --- a/scripts/e2e-docker-start +++ b/scripts/e2e-docker-start @@ -10,20 +10,15 @@ EMBER_DIST=${DIR}/dist_ember RANCHER_IMG_VERSION=v2.9-head HAS_ARGS="false" -echo "on my script" -echo "RANCHER_VERSION_E2E=${RANCHER_VERSION_E2E}" - -# check if script invoke contains any argument... -# if [ -z "$RANCHER_VERSION_E2E" ]; then +# check if script invoke contains any argument. If so, adjust RANCHER_IMG_VERSION if [ $# -eq 1 ]; then RANCHER_IMG_VERSION=$1 HAS_ARGS="true" fi if [ "$HAS_ARGS" == "false" ]; then - RANCHER_IMG_VERSION=v2.9-head - - echo "normal flow without args... RANCHER_IMG_VERSION=${RANCHER_IMG_VERSION}" + # this flow is what test.yaml is expected to to be following + echo "normal flow without args. Defaults to v2.9-head" docker run -d --restart=unless-stopped -p 80:80 -p 443:443 \ -v ${DASHBOARD_DIST}:/usr/share/rancher/ui-dashboard/dashboard \ From 991e9241eceed570912853fde3b8e15c776ce5b7 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 25 Jul 2024 12:32:27 +0100 Subject: [PATCH 13/46] bind to only v2.9 to check if tests pass + comment other workflows --- .../extensions-compatibility-tests.yaml | 5 +- .github/workflows/test.yaml | 375 ++++++++++-------- 2 files changed, 203 insertions(+), 177 deletions(-) diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index dc4709c68e8..352287c2a23 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -15,7 +15,7 @@ env: API: https://127.0.0.1 TEST_PROJECT_ID: rancher-dashboard CYPRESS_API_URL: http://139.59.134.103:1234/ - TEST_RUN_ID: ${{github.run_number}}-${{github.run_attempt}}-Extensions-Compatibility-Tests + TEST_RUN_ID: ${{github.run_number}}-${{github.run_attempt}}-extensions-compatibility-tests # Build the dashboard to use in tests. When set to false it will grab `latest` from CDN (useful for running e2e tests quickly) BUILD_DASHBOARD: true @@ -35,7 +35,6 @@ jobs: # ['@neuvector'] ] rancherEnv: [ - 'v2.8-head', 'v2.9-head', ] runs-on: ubuntu-latest @@ -73,5 +72,5 @@ jobs: uses: actions/upload-artifact@v3 if: ${{ failure() }} with: - name: ${{github.run_number}}-${{github.run_attempt}}-screenshots-${{ matrix.role.tag }}+${{ matrix.features[0] }} + name: ${{github.run_number}}-${{github.run_attempt}}-extensions-compatibility-Tests-screenshots-${{ matrix.role.tag }}+${{ matrix.features[t] }} path: cypress/screenshots \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index baff34e678a..ba44a020764 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,173 +1,174 @@ -name: Tests -on: - push: - branches: - - master - - 'release-*' - pull_request: - branches: - - master - - 'release-*' - workflow_dispatch: - inputs: - environment: - description: 'Environment to run tests against' - type: environment - required: true - -env: - TEST_USERNAME: admin - TEST_PASSWORD: password - CATTLE_BOOTSTRAP_PASSWORD: password - TEST_BASE_URL: https://127.0.0.1:8005 - API: https://127.0.0.1 - TEST_PROJECT_ID: rancher-dashboard - CYPRESS_API_URL: http://139.59.134.103:1234/ - TEST_RUN_ID: ${{github.run_number}}-${{github.run_attempt}}-${{github.event.pull_request.title || github.event.head_commit.message}} - # Build the dashboard to use in tests. When set to false it will grab `latest` from CDN (useful for running e2e tests quickly) - BUILD_DASHBOARD: true - - E2E_BUILD_DIST_NAME: dist - E2E_BUILD_DIST_DIR: dist - E2E_BUILD_DIST_EMBER_NAME: dist_ember - E2E_BUILD_DIST_EMBER_DIR: dist_ember - -jobs: - e2e-ui-build: - if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - name: Setup env - uses: ./.github/actions/setup - - name: Build e2e - run: yarn e2e:build - - name: Upload e2e build - uses: actions/upload-artifact@v4 - with: - name: ${{ env.E2E_BUILD_DIST_NAME }} - path: ${{ env.E2E_BUILD_DIST_DIR }}/ - if-no-files-found: error - retention-days: 10 - compression-level: 9 - - name: Upload e2e build ember - uses: actions/upload-artifact@v4 - with: - name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} - path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }}/ - if-no-files-found: error - retention-days: 10 - compression-level: 9 - e2e-test: - if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" - needs: e2e-ui-build - strategy: - fail-fast: false - matrix: - role: [ - { username: 'admin', tag: '@adminUser' }, - { username: 'standard_user', tag: '@standardUser' } - ] - features: [ - # ['@navigation', '@extensions'], - # ['@charts'], - ['@explorer'], - # ['@fleet'], - # ['@generic', '@globalSettings'], - # ['@manager'], - # ['@userMenu', '@usersAndAuths'], - # ['@components'], - # ['@vai'] - ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - name: Setup env - uses: ./.github/actions/setup - - # Installing fixed version of Chrome since latest version does not work (117-118 didn't work) - # Leaving this here again in case we need to pin to a specific Chrome version in the future - # - name: Install Chrome 116 - # run: | - # sudo apt-get install -y wget - # cd /tmp - # wget -q http://mirror.cs.uchicago.edu/google-chrome/pool/main/g/google-chrome-stable/google-chrome-stable_116.0.5845.187-1_amd64.deb - # sudo apt-get install -y --allow-downgrades ./google-chrome-stable_116.0.5845.187-1_amd64.deb - # google-chrome --version - - - name: Download e2e build - uses: actions/download-artifact@v4 - with: - name: ${{ env.E2E_BUILD_DIST_NAME }} - path: ${{ env.E2E_BUILD_DIST_DIR }} - - name: Download e2e build ember - uses: actions/download-artifact@v4 - with: - name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} - path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }} +# name: Tests +# on: +# push: +# branches: +# - master +# - 'release-*' +# pull_request: +# branches: +# - master +# - 'release-*' +# workflow_dispatch: +# inputs: +# environment: +# description: 'Environment to run tests against' +# type: environment +# required: true + +# env: +# TEST_USERNAME: admin +# TEST_PASSWORD: password +# CATTLE_BOOTSTRAP_PASSWORD: password +# TEST_BASE_URL: https://127.0.0.1:8005 +# API: https://127.0.0.1 +# TEST_PROJECT_ID: rancher-dashboard +# CYPRESS_API_URL: http://139.59.134.103:1234/ +# TEST_RUN_ID: ${{github.run_number}}-${{github.run_attempt}}-${{github.event.pull_request.title || github.event.head_commit.message}} +# # Build the dashboard to use in tests. When set to false it will grab `latest` from CDN (useful for running e2e tests quickly) +# BUILD_DASHBOARD: true + +# E2E_BUILD_DIST_NAME: dist +# E2E_BUILD_DIST_DIR: dist +# E2E_BUILD_DIST_EMBER_NAME: dist_ember +# E2E_BUILD_DIST_EMBER_DIR: dist_ember + +# jobs: +# e2e-ui-build: +# if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# with: +# fetch-depth: 1 +# - name: Setup env +# uses: ./.github/actions/setup +# - name: Build e2e +# run: yarn e2e:build +# - name: Upload e2e build +# uses: actions/upload-artifact@v4 +# with: +# name: ${{ env.E2E_BUILD_DIST_NAME }} +# path: ${{ env.E2E_BUILD_DIST_DIR }}/ +# if-no-files-found: error +# retention-days: 10 +# compression-level: 9 +# - name: Upload e2e build ember +# uses: actions/upload-artifact@v4 +# with: +# name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} +# path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }}/ +# if-no-files-found: error +# retention-days: 10 +# compression-level: 9 +# e2e-test: +# if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" +# needs: e2e-ui-build +# strategy: +# fail-fast: false +# matrix: +# role: [ +# { username: 'admin', tag: '@adminUser' }, +# { username: 'standard_user', tag: '@standardUser' } +# ] +# features: [ +# # ['@navigation', '@extensions'], +# # ['@charts'], +# ['@explorer'], +# # ['@fleet'], +# # ['@generic', '@globalSettings'], +# # ['@manager'], +# # ['@userMenu', '@usersAndAuths'], +# # ['@components'], +# # ['@vai'] +# ] +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# with: +# fetch-depth: 1 +# - name: Setup env +# uses: ./.github/actions/setup + +# # Installing fixed version of Chrome since latest version does not work (117-118 didn't work) +# # Leaving this here again in case we need to pin to a specific Chrome version in the future +# # - name: Install Chrome 116 +# # run: | +# # sudo apt-get install -y wget +# # cd /tmp +# # wget -q http://mirror.cs.uchicago.edu/google-chrome/pool/main/g/google-chrome-stable/google-chrome-stable_116.0.5845.187-1_amd64.deb +# # sudo apt-get install -y --allow-downgrades ./google-chrome-stable_116.0.5845.187-1_amd64.deb +# # google-chrome --version + +# - name: Download e2e build +# uses: actions/download-artifact@v4 +# with: +# name: ${{ env.E2E_BUILD_DIST_NAME }} +# path: ${{ env.E2E_BUILD_DIST_DIR }} +# - name: Download e2e build ember +# uses: actions/download-artifact@v4 +# with: +# name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} +# path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }} - - name: Run Rancher - run: yarn e2e:docker +# - name: Run Rancher +# run: yarn e2e:docker - - name: Setup Rancher and user - run: | - yarn e2e:prod - env: - GREP_TAGS: ${{ matrix.role.tag }}Setup+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}Setup+${{ matrix.features[1] || matrix.features[0] }} --@jenkins - TEST_USERNAME: admin - TEST_ONLY: setup - - name: Run user tests - run: | - yarn e2e:prod - [ "$BUILD_DASHBOARD" != "false" ] || exit 0 - env: - TEST_SKIP: setup - GREP_TAGS: ${{ matrix.role.tag }}+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}+${{ matrix.features[1] || matrix.features[0] }} --@jenkins - TEST_USERNAME: ${{ matrix.role.username }} +# - name: Setup Rancher and user +# run: | +# yarn e2e:prod +# env: +# GREP_TAGS: ${{ matrix.role.tag }}Setup+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}Setup+${{ matrix.features[1] || matrix.features[0] }} --@jenkins +# TEST_USERNAME: admin +# TEST_ONLY: setup +# - name: Run user tests +# run: | +# yarn e2e:prod +# [ "$BUILD_DASHBOARD" != "false" ] || exit 0 +# env: +# TEST_SKIP: setup +# GREP_TAGS: ${{ matrix.role.tag }}+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}+${{ matrix.features[1] || matrix.features[0] }} --@jenkins +# TEST_USERNAME: ${{ matrix.role.username }} - - name: Upload screenshots - uses: actions/upload-artifact@v3 - if: ${{ failure() }} - with: - name: ${{github.run_number}}-${{github.run_attempt}}-screenshots-${{ matrix.role.tag }}+${{ matrix.features[0] }} - path: cypress/screenshots +# - name: Upload screenshots +# uses: actions/upload-artifact@v3 +# if: ${{ failure() }} +# with: +# name: ${{github.run_number}}-${{github.run_attempt}}-screenshots-${{ matrix.role.tag }}+${{ matrix.features[0] }} +# path: cypress/screenshots - unit-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 1 +# unit-test: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# with: +# fetch-depth: 1 - - name: Run tests - uses: ./.github/actions/unit-tests +# - name: Run tests +# uses: ./.github/actions/unit-tests - - name: Collect Coverage - run: | - mkdir -p coverage-artifacts/coverage - cp coverage/unit/coverage-final.json coverage-artifacts/coverage/coverage-unit.json - cp -r coverage/unit/ coverage-artifacts/coverage/unit/ +# - name: Collect Coverage +# run: | +# mkdir -p coverage-artifacts/coverage +# cp coverage/unit/coverage-final.json coverage-artifacts/coverage/coverage-unit.json +# cp -r coverage/unit/ coverage-artifacts/coverage/unit/ - - name: Upload coverage - uses: actions/upload-artifact@v3 - with: - name: ${{github.run_number}}-${{github.run_attempt}}-coverage - path: coverage-artifacts/**/* +# - name: Upload coverage +# uses: actions/upload-artifact@v3 +# with: +# name: ${{github.run_number}}-${{github.run_attempt}}-coverage +# path: coverage-artifacts/**/* - i18n: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 1 +# i18n: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# with: +# fetch-depth: 1 - - name: Run i18n lint - uses: ./.github/actions/i18n-lint +# - name: Run i18n lint +# uses: ./.github/actions/i18n-lint +<<<<<<< HEAD check-i18n: runs-on: ubuntu-latest steps: @@ -177,25 +178,37 @@ jobs: - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' +======= +# check-i18n: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# with: +# fetch-depth: 1 +# - uses: actions/setup-node@v3 +# with: +# node-version: '16.x' +>>>>>>> d05c7b9587 (bind to only v2.9 to check if tests pass + comment other workflows) - - name: Install packages - run: yarn install:ci +# - name: Install packages +# run: yarn install:ci - - name: Run i18n string check - run: | - # Falure won't fail the job (remove -x when all current issues are fixed) - ./scripts/check-i18n -s -x +# - name: Run i18n string check +# run: | +# # Falure won't fail the job (remove -x when all current issues are fixed) +# ./scripts/check-i18n -s -x - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 1 +# lint: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# with: +# fetch-depth: 1 - - name: Run tests - uses: ./.github/actions/lint +# - name: Run tests +# uses: ./.github/actions/lint +<<<<<<< HEAD # coverage: # runs-on: ubuntu-latest # needs: @@ -232,3 +245,17 @@ jobs: - name: Check e2e tags run: | ./scripts/check-e2e-tests-for-tags +======= +# check-e2e-tags: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# with: +# fetch-depth: 1 +# - uses: actions/setup-node@v3 +# with: +# node-version: '16.x' +# - name: Check e2e tags +# run: | +# ./scripts/check-e2e-tests-for-tags +>>>>>>> d05c7b9587 (bind to only v2.9 to check if tests pass + comment other workflows) From 4f8e5cd1b60cec41945b8e0a464a20ebb9eabb1d Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 25 Jul 2024 12:33:37 +0100 Subject: [PATCH 14/46] comment workflows --- .github/workflows/check-plugins.yaml | 43 +++++++++++---- .github/workflows/docusaurus.yaml | 80 +++++++++++++++++----------- .github/workflows/storybook.yaml | 30 +++++++++++ 3 files changed, 113 insertions(+), 40 deletions(-) diff --git a/.github/workflows/check-plugins.yaml b/.github/workflows/check-plugins.yaml index 1dc63495047..1a98f3d615a 100644 --- a/.github/workflows/check-plugins.yaml +++ b/.github/workflows/check-plugins.yaml @@ -1,3 +1,4 @@ +<<<<<<< HEAD name: check-plugins-build on: pull_request: @@ -22,14 +23,36 @@ jobs: - name: Validate Plugin build system run: ./shell/scripts/test-plugins-build.sh shell: bash +======= +# name: check-plugins-build +# on: +# pull_request: +# branches: +# - master +# env: +# TEST_PERSIST_BUILD: true +# jobs: +# validate: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout +# uses: actions/checkout@v4 +# - name: Setup Node.js +# uses: actions/setup-node@v4 +# with: +# node-version: '16.20.2' +# - name: Validate Plugin build system +# run: ./shell/scripts/test-plugins-build.sh +# shell: bash +>>>>>>> 25d643d2d3 (comment workflows) - - name: Upload files - uses: actions/upload-artifact@v3 - if: failure() - with: - name: test - path: | - /tmp/tmp.**/test-app - !/tmp/tmp.**/test-app/node_modules/ - !/tmp/tmp.**/test-app/pkg/test-pkg/node_modules/ - retention-days: 2 \ No newline at end of file +# - name: Upload files +# uses: actions/upload-artifact@v3 +# if: failure() +# with: +# name: test +# path: | +# /tmp/tmp.**/test-app +# !/tmp/tmp.**/test-app/node_modules/ +# !/tmp/tmp.**/test-app/pkg/test-pkg/node_modules/ +# retention-days: 2 \ No newline at end of file diff --git a/.github/workflows/docusaurus.yaml b/.github/workflows/docusaurus.yaml index 7ce8ee1956c..cb3d505d684 100644 --- a/.github/workflows/docusaurus.yaml +++ b/.github/workflows/docusaurus.yaml @@ -1,5 +1,6 @@ -name: Publish Docusaurus +# name: Publish Docusaurus +<<<<<<< HEAD on: push: branches: @@ -23,38 +24,57 @@ jobs: node-version: 16.x >>>>>>> b7384b5fad (Revert "script adjustment/fix") cache: yarn +======= +# on: +# push: +# branches: +# - master +# pull_request: +# branches: +# - master +# jobs: +# build: +# name: Build +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - uses: actions/setup-node@v3 +# with: +# node-version: 16.x +# cache: yarn +>>>>>>> 25d643d2d3 (comment workflows) - - name: Install dependencies - run: cd docusaurus/ && yarn install:ci - - name: Build website - run: cd docusaurus/ && yarn build - - name: Add CNAME - run: | - echo "extensions.rancher.io" > ./docusaurus/build/CNAME +# - name: Install dependencies +# run: cd docusaurus/ && yarn install:ci +# - name: Build website +# run: cd docusaurus/ && yarn build +# - name: Add CNAME +# run: | +# echo "extensions.rancher.io" > ./docusaurus/build/CNAME - - name: Upload artifact - if: ${{ github.event_name == 'push' && github.repository_owner == 'rancher' }} - uses: actions/upload-pages-artifact@v3 - with: - path: ./docusaurus/build - retention-days: 10 - compression-level: 9 +# - name: Upload artifact +# if: ${{ github.event_name == 'push' && github.repository_owner == 'rancher' }} +# uses: actions/upload-pages-artifact@v3 +# with: +# path: ./docusaurus/build +# retention-days: 10 +# compression-level: 9 - # Seperate the deploy job to isolate write permissions - deploy: - name: Publish - if: ${{ github.event_name == 'push' && github.repository_owner == 'rancher' }} - runs-on: ubuntu-latest - needs: build +# # Seperate the deploy job to isolate write permissions +# deploy: +# name: Publish +# if: ${{ github.event_name == 'push' && github.repository_owner == 'rancher' }} +# runs-on: ubuntu-latest +# needs: build - # This is required to avoid https://github.com/actions/deploy-pages/issues/271 - environment: - name: github-pages +# # This is required to avoid https://github.com/actions/deploy-pages/issues/271 +# environment: +# name: github-pages - permissions: - pages: write - id-token: write +# permissions: +# pages: write +# id-token: write - steps: - - name: Deploy to GitHub Pages - uses: actions/deploy-pages@v4 \ No newline at end of file +# steps: +# - name: Deploy to GitHub Pages +# uses: actions/deploy-pages@v4 \ No newline at end of file diff --git a/.github/workflows/storybook.yaml b/.github/workflows/storybook.yaml index deb66b19bec..acd40411efc 100644 --- a/.github/workflows/storybook.yaml +++ b/.github/workflows/storybook.yaml @@ -1,3 +1,4 @@ +<<<<<<< HEAD name: storybook env: STORYBOOK_TOKEN: ${{ secrets.STORYBOOK_TOKEN }} @@ -29,3 +30,32 @@ jobs: - name: Publish Storybook if: ${{ github.event_name == 'push' && github.repository_owner == 'rancher'}} run: .github/workflows/scripts/publish-storybook +======= +# name: storybook +# env: +# STORYBOOK_TOKEN: ${{ secrets.STORYBOOK_TOKEN }} +# on: +# push: +# branches: +# - master +# pull_request: +# branches: +# - master +# jobs: +# storybook: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - name: Use Node.js +# uses: actions/setup-node@v4 +# with: +# node-version: '16.20.2' +# - name: Install packages +# run: yarn install +# - name: Build Storybook +# run: | +# yarn build-storybook +# - name: Publish Storybook +# if: ${{ github.event_name == 'push' && github.repository_owner == 'rancher'}} +# run: .github/workflows/scripts/publish-storybook +>>>>>>> 25d643d2d3 (comment workflows) From ddba6d58d065a039cf4bd18a75e58af1c02a2485 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 25 Jul 2024 12:34:31 +0100 Subject: [PATCH 15/46] use only before hook on elemental spec --- .../pages/extensions-compatibility-tests/elemental.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts index 9880a52748c..b187c978ea8 100644 --- a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts +++ b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts @@ -16,7 +16,7 @@ const EXTENSION_NAME = 'elemental'; // const UI_PLUGINS_PARTNERS_REPO_NAME = 'partner-extensions'; describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] }, () => { - beforeEach(() => { + before(() => { cy.login(); }); From d1b20c1c90fb561bb055dba5302efa566971f904 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 25 Jul 2024 12:40:10 +0100 Subject: [PATCH 16/46] comment workflows --- .github/workflows/test.yaml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ba44a020764..a3235a22e2a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -207,6 +207,7 @@ # - name: Run tests # uses: ./.github/actions/lint +<<<<<<< HEAD <<<<<<< HEAD # coverage: @@ -246,6 +247,33 @@ run: | ./scripts/check-e2e-tests-for-tags ======= +======= + +# coverage: +# runs-on: ubuntu-latest +# needs: +# - unit-test +# steps: +# - uses: actions/checkout@v3 +# with: +# fetch-depth: 1 + +# - uses: actions/setup-node@v3 +# with: +# node-version: '16.x' + +# - name: Download Coverage Artifacts +# uses: actions/download-artifact@v3 +# with: +# name: ${{github.run_number}}-${{github.run_attempt}}-coverage + +# - name: Install Codecov CLI +# run : .github/workflows/scripts/install-codecov.sh + +# - name: Upload tests coverage report to Codecov +# run: ./codecov --verbose upload-process -t ${{ secrets.CODECOV_TOKEN }} -n ${{github.run_number}}-${{github.run_attempt}}-coverage -F unit -f ./coverage/coverage-unit.json + +>>>>>>> 7cea97aad2 (comment workflows) # check-e2e-tags: # runs-on: ubuntu-latest # steps: @@ -258,4 +286,7 @@ # - name: Check e2e tags # run: | # ./scripts/check-e2e-tests-for-tags +<<<<<<< HEAD >>>>>>> d05c7b9587 (bind to only v2.9 to check if tests pass + comment other workflows) +======= +>>>>>>> 7cea97aad2 (comment workflows) From aef1a47c78b57922fa286d9eff40ddaed1430f94 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 25 Jul 2024 12:41:32 +0100 Subject: [PATCH 17/46] comment workflows --- .github/workflows/test.yaml | 401 +++++++++++++++++++----------------- 1 file changed, 215 insertions(+), 186 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a3235a22e2a..61d22f43e12 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,180 +1,184 @@ -# name: Tests -# on: -# push: -# branches: -# - master -# - 'release-*' -# pull_request: -# branches: -# - master -# - 'release-*' -# workflow_dispatch: -# inputs: -# environment: -# description: 'Environment to run tests against' -# type: environment -# required: true +name: Tests +on: + push: + branches: + - master + - 'release-*' + # pull_request: + # branches: + # - master + # - 'release-*' + workflow_dispatch: + inputs: + environment: + description: 'Environment to run tests against' + type: environment + required: true -# env: -# TEST_USERNAME: admin -# TEST_PASSWORD: password -# CATTLE_BOOTSTRAP_PASSWORD: password -# TEST_BASE_URL: https://127.0.0.1:8005 -# API: https://127.0.0.1 -# TEST_PROJECT_ID: rancher-dashboard -# CYPRESS_API_URL: http://139.59.134.103:1234/ -# TEST_RUN_ID: ${{github.run_number}}-${{github.run_attempt}}-${{github.event.pull_request.title || github.event.head_commit.message}} -# # Build the dashboard to use in tests. When set to false it will grab `latest` from CDN (useful for running e2e tests quickly) -# BUILD_DASHBOARD: true +env: + TEST_USERNAME: admin + TEST_PASSWORD: password + CATTLE_BOOTSTRAP_PASSWORD: password + TEST_BASE_URL: https://127.0.0.1:8005 + API: https://127.0.0.1 + TEST_PROJECT_ID: rancher-dashboard + CYPRESS_API_URL: http://139.59.134.103:1234/ + TEST_RUN_ID: ${{github.run_number}}-${{github.run_attempt}}-${{github.event.pull_request.title || github.event.head_commit.message}} + # Build the dashboard to use in tests. When set to false it will grab `latest` from CDN (useful for running e2e tests quickly) + BUILD_DASHBOARD: true -# E2E_BUILD_DIST_NAME: dist -# E2E_BUILD_DIST_DIR: dist -# E2E_BUILD_DIST_EMBER_NAME: dist_ember -# E2E_BUILD_DIST_EMBER_DIR: dist_ember + E2E_BUILD_DIST_NAME: dist + E2E_BUILD_DIST_DIR: dist + E2E_BUILD_DIST_EMBER_NAME: dist_ember + E2E_BUILD_DIST_EMBER_DIR: dist_ember -# jobs: -# e2e-ui-build: -# if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v3 -# with: -# fetch-depth: 1 -# - name: Setup env -# uses: ./.github/actions/setup -# - name: Build e2e -# run: yarn e2e:build -# - name: Upload e2e build -# uses: actions/upload-artifact@v4 -# with: -# name: ${{ env.E2E_BUILD_DIST_NAME }} -# path: ${{ env.E2E_BUILD_DIST_DIR }}/ -# if-no-files-found: error -# retention-days: 10 -# compression-level: 9 -# - name: Upload e2e build ember -# uses: actions/upload-artifact@v4 -# with: -# name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} -# path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }}/ -# if-no-files-found: error -# retention-days: 10 -# compression-level: 9 -# e2e-test: -# if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" -# needs: e2e-ui-build -# strategy: -# fail-fast: false -# matrix: -# role: [ -# { username: 'admin', tag: '@adminUser' }, -# { username: 'standard_user', tag: '@standardUser' } -# ] -# features: [ -# # ['@navigation', '@extensions'], -# # ['@charts'], -# ['@explorer'], -# # ['@fleet'], -# # ['@generic', '@globalSettings'], -# # ['@manager'], -# # ['@userMenu', '@usersAndAuths'], -# # ['@components'], -# # ['@vai'] -# ] -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v3 -# with: -# fetch-depth: 1 -# - name: Setup env -# uses: ./.github/actions/setup +jobs: + e2e-ui-build: + if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + - name: Setup env + uses: ./.github/actions/setup + - name: Build e2e + run: yarn e2e:build + - name: Upload e2e build + uses: actions/upload-artifact@v4 + with: + name: ${{ env.E2E_BUILD_DIST_NAME }} + path: ${{ env.E2E_BUILD_DIST_DIR }}/ + if-no-files-found: error + retention-days: 10 + compression-level: 9 + - name: Upload e2e build ember + uses: actions/upload-artifact@v4 + with: + name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} + path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }}/ + if-no-files-found: error + retention-days: 10 + compression-level: 9 + e2e-test: + if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" + needs: e2e-ui-build + strategy: + fail-fast: false + matrix: + role: [ + { username: 'admin', tag: '@adminUser' }, + { username: 'standard_user', tag: '@standardUser' } + ] + features: [ + # ['@navigation', '@extensions'], + # ['@charts'], + ['@explorer'], + # ['@fleet'], + # ['@generic', '@globalSettings'], + # ['@manager'], + # ['@userMenu', '@usersAndAuths'], + # ['@components'], + # ['@vai'] + ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + - name: Setup env + uses: ./.github/actions/setup -# # Installing fixed version of Chrome since latest version does not work (117-118 didn't work) -# # Leaving this here again in case we need to pin to a specific Chrome version in the future -# # - name: Install Chrome 116 -# # run: | -# # sudo apt-get install -y wget -# # cd /tmp -# # wget -q http://mirror.cs.uchicago.edu/google-chrome/pool/main/g/google-chrome-stable/google-chrome-stable_116.0.5845.187-1_amd64.deb -# # sudo apt-get install -y --allow-downgrades ./google-chrome-stable_116.0.5845.187-1_amd64.deb -# # google-chrome --version + # Installing fixed version of Chrome since latest version does not work (117-118 didn't work) + # Leaving this here again in case we need to pin to a specific Chrome version in the future + # - name: Install Chrome 116 + # run: | + # sudo apt-get install -y wget + # cd /tmp + # wget -q http://mirror.cs.uchicago.edu/google-chrome/pool/main/g/google-chrome-stable/google-chrome-stable_116.0.5845.187-1_amd64.deb + # sudo apt-get install -y --allow-downgrades ./google-chrome-stable_116.0.5845.187-1_amd64.deb + # google-chrome --version -# - name: Download e2e build -# uses: actions/download-artifact@v4 -# with: -# name: ${{ env.E2E_BUILD_DIST_NAME }} -# path: ${{ env.E2E_BUILD_DIST_DIR }} -# - name: Download e2e build ember -# uses: actions/download-artifact@v4 -# with: -# name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} -# path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }} + - name: Download e2e build + uses: actions/download-artifact@v4 + with: + name: ${{ env.E2E_BUILD_DIST_NAME }} + path: ${{ env.E2E_BUILD_DIST_DIR }} + - name: Download e2e build ember + uses: actions/download-artifact@v4 + with: + name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} + path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }} -# - name: Run Rancher -# run: yarn e2e:docker + - name: Run Rancher + run: yarn e2e:docker -# - name: Setup Rancher and user -# run: | -# yarn e2e:prod -# env: -# GREP_TAGS: ${{ matrix.role.tag }}Setup+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}Setup+${{ matrix.features[1] || matrix.features[0] }} --@jenkins -# TEST_USERNAME: admin -# TEST_ONLY: setup -# - name: Run user tests -# run: | -# yarn e2e:prod -# [ "$BUILD_DASHBOARD" != "false" ] || exit 0 -# env: -# TEST_SKIP: setup -# GREP_TAGS: ${{ matrix.role.tag }}+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}+${{ matrix.features[1] || matrix.features[0] }} --@jenkins -# TEST_USERNAME: ${{ matrix.role.username }} + - name: Setup Rancher and user + run: | + yarn e2e:prod + env: + GREP_TAGS: ${{ matrix.role.tag }}Setup+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}Setup+${{ matrix.features[1] || matrix.features[0] }} --@jenkins + TEST_USERNAME: admin + TEST_ONLY: setup + - name: Run user tests + run: | + yarn e2e:prod + [ "$BUILD_DASHBOARD" != "false" ] || exit 0 + env: + TEST_SKIP: setup + GREP_TAGS: ${{ matrix.role.tag }}+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}+${{ matrix.features[1] || matrix.features[0] }} --@jenkins + TEST_USERNAME: ${{ matrix.role.username }} -# - name: Upload screenshots -# uses: actions/upload-artifact@v3 -# if: ${{ failure() }} -# with: -# name: ${{github.run_number}}-${{github.run_attempt}}-screenshots-${{ matrix.role.tag }}+${{ matrix.features[0] }} -# path: cypress/screenshots + - name: Upload screenshots + uses: actions/upload-artifact@v3 + if: ${{ failure() }} + with: + name: ${{github.run_number}}-${{github.run_attempt}}-screenshots-${{ matrix.role.tag }}+${{ matrix.features[0] }} + path: cypress/screenshots -# unit-test: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v3 -# with: -# fetch-depth: 1 + unit-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 -# - name: Run tests -# uses: ./.github/actions/unit-tests + - name: Run tests + uses: ./.github/actions/unit-tests -# - name: Collect Coverage -# run: | -# mkdir -p coverage-artifacts/coverage -# cp coverage/unit/coverage-final.json coverage-artifacts/coverage/coverage-unit.json -# cp -r coverage/unit/ coverage-artifacts/coverage/unit/ + - name: Collect Coverage + run: | + mkdir -p coverage-artifacts/coverage + cp coverage/unit/coverage-final.json coverage-artifacts/coverage/coverage-unit.json + cp -r coverage/unit/ coverage-artifacts/coverage/unit/ -# - name: Upload coverage -# uses: actions/upload-artifact@v3 -# with: -# name: ${{github.run_number}}-${{github.run_attempt}}-coverage -# path: coverage-artifacts/**/* + - name: Upload coverage + uses: actions/upload-artifact@v3 + with: + name: ${{github.run_number}}-${{github.run_attempt}}-coverage + path: coverage-artifacts/**/* -# i18n: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v3 -# with: -# fetch-depth: 1 + i18n: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 -# - name: Run i18n lint -# uses: ./.github/actions/i18n-lint + - name: Run i18n lint + uses: ./.github/actions/i18n-lint <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> f0bfe54175 (comment workflows) check-i18n: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 1 +<<<<<<< HEAD - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' @@ -189,22 +193,28 @@ # with: # node-version: '16.x' >>>>>>> d05c7b9587 (bind to only v2.9 to check if tests pass + comment other workflows) +======= + - uses: actions/setup-node@v3 + with: + node-version: '16.x' +>>>>>>> f0bfe54175 (comment workflows) -# - name: Install packages -# run: yarn install:ci + - name: Install packages + run: yarn install:ci -# - name: Run i18n string check -# run: | -# # Falure won't fail the job (remove -x when all current issues are fixed) -# ./scripts/check-i18n -s -x + - name: Run i18n string check + run: | + # Falure won't fail the job (remove -x when all current issues are fixed) + ./scripts/check-i18n -s -x -# lint: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v3 -# with: -# fetch-depth: 1 + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 +<<<<<<< HEAD # - name: Run tests # uses: ./.github/actions/lint <<<<<<< HEAD @@ -248,31 +258,36 @@ ./scripts/check-e2e-tests-for-tags ======= ======= +======= + - name: Run tests + uses: ./.github/actions/lint +>>>>>>> f0bfe54175 (comment workflows) -# coverage: -# runs-on: ubuntu-latest -# needs: -# - unit-test -# steps: -# - uses: actions/checkout@v3 -# with: -# fetch-depth: 1 + coverage: + runs-on: ubuntu-latest + needs: + - unit-test + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 -# - uses: actions/setup-node@v3 -# with: -# node-version: '16.x' + - uses: actions/setup-node@v3 + with: + node-version: '16.x' -# - name: Download Coverage Artifacts -# uses: actions/download-artifact@v3 -# with: -# name: ${{github.run_number}}-${{github.run_attempt}}-coverage + - name: Download Coverage Artifacts + uses: actions/download-artifact@v3 + with: + name: ${{github.run_number}}-${{github.run_attempt}}-coverage -# - name: Install Codecov CLI -# run : .github/workflows/scripts/install-codecov.sh + - name: Install Codecov CLI + run : .github/workflows/scripts/install-codecov.sh -# - name: Upload tests coverage report to Codecov -# run: ./codecov --verbose upload-process -t ${{ secrets.CODECOV_TOKEN }} -n ${{github.run_number}}-${{github.run_attempt}}-coverage -F unit -f ./coverage/coverage-unit.json + - name: Upload tests coverage report to Codecov + run: ./codecov --verbose upload-process -t ${{ secrets.CODECOV_TOKEN }} -n ${{github.run_number}}-${{github.run_attempt}}-coverage -F unit -f ./coverage/coverage-unit.json +<<<<<<< HEAD >>>>>>> 7cea97aad2 (comment workflows) # check-e2e-tags: # runs-on: ubuntu-latest @@ -290,3 +305,17 @@ >>>>>>> d05c7b9587 (bind to only v2.9 to check if tests pass + comment other workflows) ======= >>>>>>> 7cea97aad2 (comment workflows) +======= + check-e2e-tags: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + - uses: actions/setup-node@v3 + with: + node-version: '16.x' + - name: Check e2e tags + run: | + ./scripts/check-e2e-tests-for-tags +>>>>>>> f0bfe54175 (comment workflows) From 777c6c046b0b5b5ac51ca7c1dfb2344f99f960ff Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 25 Jul 2024 12:43:40 +0100 Subject: [PATCH 18/46] comment workflows --- .github/workflows/check-plugins.yaml | 34 +++++++++---- .github/workflows/docusaurus.yaml | 76 +++++++++++++++++----------- .github/workflows/storybook.yaml | 16 ++++++ .github/workflows/test.yaml | 16 +++--- 4 files changed, 94 insertions(+), 48 deletions(-) diff --git a/.github/workflows/check-plugins.yaml b/.github/workflows/check-plugins.yaml index 1a98f3d615a..bb723a937c9 100644 --- a/.github/workflows/check-plugins.yaml +++ b/.github/workflows/check-plugins.yaml @@ -1,9 +1,16 @@ <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 25d6584234 (comment workflows) name: check-plugins-build on: pull_request: branches: +<<<<<<< HEAD - master +======= + - master-bananas +>>>>>>> 25d6584234 (comment workflows) env: TEST_PERSIST_BUILD: true jobs: @@ -15,6 +22,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: +<<<<<<< HEAD <<<<<<< HEAD node-version-file: '.nvmrc' ======= @@ -45,14 +53,20 @@ jobs: # run: ./shell/scripts/test-plugins-build.sh # shell: bash >>>>>>> 25d643d2d3 (comment workflows) +======= + node-version: '16.20.2' + - name: Validate Plugin build system + run: ./shell/scripts/test-plugins-build.sh + shell: bash +>>>>>>> 25d6584234 (comment workflows) -# - name: Upload files -# uses: actions/upload-artifact@v3 -# if: failure() -# with: -# name: test -# path: | -# /tmp/tmp.**/test-app -# !/tmp/tmp.**/test-app/node_modules/ -# !/tmp/tmp.**/test-app/pkg/test-pkg/node_modules/ -# retention-days: 2 \ No newline at end of file + - name: Upload files + uses: actions/upload-artifact@v3 + if: failure() + with: + name: test + path: | + /tmp/tmp.**/test-app + !/tmp/tmp.**/test-app/node_modules/ + !/tmp/tmp.**/test-app/pkg/test-pkg/node_modules/ + retention-days: 2 \ No newline at end of file diff --git a/.github/workflows/docusaurus.yaml b/.github/workflows/docusaurus.yaml index cb3d505d684..12558bb6726 100644 --- a/.github/workflows/docusaurus.yaml +++ b/.github/workflows/docusaurus.yaml @@ -1,19 +1,29 @@ -# name: Publish Docusaurus +name: Publish Docusaurus <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 25d6584234 (comment workflows) on: push: branches: - master +<<<<<<< HEAD pull_request: branches: - master +======= + # pull_request: + # branches: + # - master +>>>>>>> 25d6584234 (comment workflows) jobs: build: name: Build runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 +<<<<<<< HEAD <<<<<<< HEAD - uses: actions/setup-node@v4 with: @@ -43,38 +53,44 @@ jobs: # node-version: 16.x # cache: yarn >>>>>>> 25d643d2d3 (comment workflows) +======= + - uses: actions/setup-node@v3 + with: + node-version: 16.x + cache: yarn +>>>>>>> 25d6584234 (comment workflows) -# - name: Install dependencies -# run: cd docusaurus/ && yarn install:ci -# - name: Build website -# run: cd docusaurus/ && yarn build -# - name: Add CNAME -# run: | -# echo "extensions.rancher.io" > ./docusaurus/build/CNAME + - name: Install dependencies + run: cd docusaurus/ && yarn install:ci + - name: Build website + run: cd docusaurus/ && yarn build + - name: Add CNAME + run: | + echo "extensions.rancher.io" > ./docusaurus/build/CNAME -# - name: Upload artifact -# if: ${{ github.event_name == 'push' && github.repository_owner == 'rancher' }} -# uses: actions/upload-pages-artifact@v3 -# with: -# path: ./docusaurus/build -# retention-days: 10 -# compression-level: 9 + - name: Upload artifact + if: ${{ github.event_name == 'push' && github.repository_owner == 'rancher' }} + uses: actions/upload-pages-artifact@v3 + with: + path: ./docusaurus/build + retention-days: 10 + compression-level: 9 -# # Seperate the deploy job to isolate write permissions -# deploy: -# name: Publish -# if: ${{ github.event_name == 'push' && github.repository_owner == 'rancher' }} -# runs-on: ubuntu-latest -# needs: build + # Seperate the deploy job to isolate write permissions + deploy: + name: Publish + if: ${{ github.event_name == 'push' && github.repository_owner == 'rancher' }} + runs-on: ubuntu-latest + needs: build -# # This is required to avoid https://github.com/actions/deploy-pages/issues/271 -# environment: -# name: github-pages + # This is required to avoid https://github.com/actions/deploy-pages/issues/271 + environment: + name: github-pages -# permissions: -# pages: write -# id-token: write + permissions: + pages: write + id-token: write -# steps: -# - name: Deploy to GitHub Pages -# uses: actions/deploy-pages@v4 \ No newline at end of file + steps: + - name: Deploy to GitHub Pages + uses: actions/deploy-pages@v4 \ No newline at end of file diff --git a/.github/workflows/storybook.yaml b/.github/workflows/storybook.yaml index acd40411efc..ab1029a1fd7 100644 --- a/.github/workflows/storybook.yaml +++ b/.github/workflows/storybook.yaml @@ -1,4 +1,7 @@ <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 25d6584234 (comment workflows) name: storybook env: STORYBOOK_TOKEN: ${{ secrets.STORYBOOK_TOKEN }} @@ -6,9 +9,15 @@ on: push: branches: - master +<<<<<<< HEAD pull_request: branches: - master +======= + # pull_request: + # branches: + # - master +>>>>>>> 25d6584234 (comment workflows) jobs: storybook: runs-on: ubuntu-latest @@ -17,11 +26,15 @@ jobs: - name: Use Node.js uses: actions/setup-node@v4 with: +<<<<<<< HEAD <<<<<<< HEAD node-version-file: '.nvmrc' ======= node-version: '16.20.2' >>>>>>> b7384b5fad (Revert "script adjustment/fix") +======= + node-version: '16.20.2' +>>>>>>> 25d6584234 (comment workflows) - name: Install packages run: yarn install - name: Build Storybook @@ -30,6 +43,7 @@ jobs: - name: Publish Storybook if: ${{ github.event_name == 'push' && github.repository_owner == 'rancher'}} run: .github/workflows/scripts/publish-storybook +<<<<<<< HEAD ======= # name: storybook # env: @@ -59,3 +73,5 @@ jobs: # if: ${{ github.event_name == 'push' && github.repository_owner == 'rancher'}} # run: .github/workflows/scripts/publish-storybook >>>>>>> 25d643d2d3 (comment workflows) +======= +>>>>>>> 25d6584234 (comment workflows) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 61d22f43e12..09b6e2db59b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -71,15 +71,15 @@ jobs: { username: 'standard_user', tag: '@standardUser' } ] features: [ - # ['@navigation', '@extensions'], - # ['@charts'], + ['@navigation', '@extensions'], + ['@charts'], ['@explorer'], - # ['@fleet'], - # ['@generic', '@globalSettings'], - # ['@manager'], - # ['@userMenu', '@usersAndAuths'], - # ['@components'], - # ['@vai'] + ['@fleet'], + ['@generic', '@globalSettings'], + ['@manager'], + ['@userMenu', '@usersAndAuths'], + ['@components'], + ['@vai'] ] runs-on: ubuntu-latest steps: From f37a3b6da0583d5885a9c7390c2390c1e6f907b6 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 25 Jul 2024 12:45:18 +0100 Subject: [PATCH 19/46] update --- .github/workflows/extensions-compatibility-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index 352287c2a23..f554376ef6e 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -72,5 +72,5 @@ jobs: uses: actions/upload-artifact@v3 if: ${{ failure() }} with: - name: ${{github.run_number}}-${{github.run_attempt}}-extensions-compatibility-Tests-screenshots-${{ matrix.role.tag }}+${{ matrix.features[t] }} + name: ${{github.run_number}}-${{github.run_attempt}}-extensions-compatibility-tests-screenshots-${{ matrix.role.tag }}+${{ matrix.features[t] }} path: cypress/screenshots \ No newline at end of file From 5a03d1705d553095e89c4d3e086a4d2a2af9367a Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 25 Jul 2024 12:46:08 +0100 Subject: [PATCH 20/46] update --- .github/workflows/extensions-compatibility-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index f554376ef6e..2f1904f798f 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -72,5 +72,5 @@ jobs: uses: actions/upload-artifact@v3 if: ${{ failure() }} with: - name: ${{github.run_number}}-${{github.run_attempt}}-extensions-compatibility-tests-screenshots-${{ matrix.role.tag }}+${{ matrix.features[t] }} + name: ${{github.run_number}}-${{github.run_attempt}}-extensions-compatibility-tests-screenshots-${{ matrix.role.tag }}+${{ matrix.features[0] }} path: cypress/screenshots \ No newline at end of file From d5b6456d281df8e6eb07195b95e0c366231ef8ae Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 25 Jul 2024 14:43:50 +0100 Subject: [PATCH 21/46] see if setup runs --- .github/workflows/test.yaml | 3 +++ .../pages/extensions-compatibility-tests/elemental.spec.ts | 2 +- cypress/e2e/tests/setup/rancher-setup.spec.ts | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 09b6e2db59b..5ca908f7eba 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -261,8 +261,11 @@ jobs: ======= - name: Run tests uses: ./.github/actions/lint +<<<<<<< HEAD >>>>>>> f0bfe54175 (comment workflows) +======= +>>>>>>> 15910841c9 (see if setup runs) coverage: runs-on: ubuntu-latest needs: diff --git a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts index b187c978ea8..9880a52748c 100644 --- a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts +++ b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts @@ -16,7 +16,7 @@ const EXTENSION_NAME = 'elemental'; // const UI_PLUGINS_PARTNERS_REPO_NAME = 'partner-extensions'; describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] }, () => { - before(() => { + beforeEach(() => { cy.login(); }); diff --git a/cypress/e2e/tests/setup/rancher-setup.spec.ts b/cypress/e2e/tests/setup/rancher-setup.spec.ts index 067353090a7..255d74095e1 100644 --- a/cypress/e2e/tests/setup/rancher-setup.spec.ts +++ b/cypress/e2e/tests/setup/rancher-setup.spec.ts @@ -6,7 +6,7 @@ import { serverUrlLocalhostCases, urlWithTrailingForwardSlash, httpUrl, nonUrlCa // Cypress or the GrepTags avoid to run multiples times the same test for each tag used. // This is a temporary solution till initialization is not handled as a test -describe('Rancher setup', { tags: ['@adminUserSetup', '@standardUserSetup', '@setup', '@components', '@navigation', '@charts', '@explorer', '@extensions', '@fleet', '@generic', '@globalSettings', '@manager', '@userMenu', '@usersAndAuths', '@vai'] }, () => { +describe('Rancher setup', { tags: ['@adminUserSetup', '@standardUserSetup', '@setup', '@components', '@navigation', '@charts', '@explorer', '@extensions', '@fleet', '@generic', '@globalSettings', '@manager', '@userMenu', '@usersAndAuths', '@elemental', '@vai'] }, () => { const rancherSetupLoginPage = new RancherSetupLoginPagePo(); const rancherSetupConfigurePage = new RancherSetupConfigurePage(); const homePage = new HomePagePo(); From 64353ced2a028ef61da1d6fb97c6f69415a53e7a Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 25 Jul 2024 14:58:09 +0100 Subject: [PATCH 22/46] test multi rancher tests + add official extensions repo as first step of spec --- .../extensions-compatibility-tests.yaml | 1 + .../elemental.spec.ts | 378 +----------------- 2 files changed, 11 insertions(+), 368 deletions(-) diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index 2f1904f798f..9471ef35b39 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -36,6 +36,7 @@ jobs: ] rancherEnv: [ 'v2.9-head', + 'v2.8-head', ] runs-on: ubuntu-latest steps: diff --git a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts index 9880a52748c..cf824c65a1e 100644 --- a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts +++ b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts @@ -1,186 +1,26 @@ import ExtensionsPagePo from '@/cypress/e2e/po/pages/extensions.po'; -// import RepositoriesPagePo from '@/cypress/e2e/po/pages/chart-repositories.po'; -// import PromptRemove from '@/cypress/e2e/po/prompts/promptRemove.po'; -// import BurgerMenuPo from '@/cypress/e2e/po/side-bars/burger-side-menu.po'; -// import { LoginPagePo } from '@/cypress/e2e/po/pages/login-page.po'; import HomePagePo from '@/cypress/e2e/po/pages/home.po'; import AboutPagePo from '@/cypress/e2e/po/pages/about.po'; -// const DISABLED_CACHE_EXTENSION_NAME = 'large-extension'; -// const DISABLED_CACHE_EXTENSION_MENU_LABEL = 'Large-extension'; -// const DISABLED_CACHE_EXTENSION_TITLE = 'Large extension demo (> 20mb) - cache testing'; -// const UNAUTHENTICATED_EXTENSION_NAME = 'uk-locale'; const EXTENSION_NAME = 'elemental'; -// const UI_PLUGINS_PARTNERS_REPO_URL = 'https://github.com/rancher/partner-extensions'; -// const UI_PLUGINS_PARTNERS_REPO_NAME = 'partner-extensions'; describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] }, () => { beforeEach(() => { cy.login(); }); - // it('add repository', () => { - // // This should be in a `before` however is flaky. Move it to an `it` to let cypress retry - // const extensionsPo = new ExtensionsPagePo(); - - // extensionsPo.goTo(); - // extensionsPo.waitForPage(); - // extensionsPo.extensionTabInstalledClick(); // Avoid nav guard failures that probably auto move user to this tab - - // // install the rancher plugin examples - // extensionsPo.addExtensionsRepository('https://github.com/rancher/ui-plugin-examples', 'main', 'rancher-plugin-examples'); - // }); - - // it('has the correct title', () => { - // const extensionsPo = new ExtensionsPagePo(); - - // extensionsPo.goTo(); - - // cy.title().should('eq', 'Rancher - Extensions'); - // }); - - // it('Should check the feature flag', () => { - // const extensionsPo = new ExtensionsPagePo(); - - // extensionsPo.goTo(); - - // cy.intercept('GET', '/v1/management.cattle.io.features?*', { - // type: 'collection', - // resourceType: 'management.cattle.io.feature', - // data: [ - // { - // id: 'uiextension', - // type: 'management.cattle.io.feature', - // kind: 'Feature', - // spec: { value: true }, - // status: { - // default: true, - // description: 'Enable UI Extensions when starting Rancher', - // dynamic: false, - // lockedValue: null - // } - // } - // ] - // }).as('getFeatureFlag'); - - // extensionsPo.waitForPage(); - // extensionsPo.waitForTitle(); - - // cy.wait('@getFeatureFlag').then(() => { - // extensionsPo.extensionTabs.checkVisible(); - // }); - // }); - - // it('using "Add Rancher Repositories" should add a new repository (Partners repo)', () => { - // const extensionsPo = new ExtensionsPagePo(); - - // extensionsPo.goTo(); - - // // check if burguer menu nav is highlighted correctly for extensions - // // https://github.com/rancher/dashboard/issues/10010 - // BurgerMenuPo.checkIfMenuItemLinkIsHighlighted('Extensions'); - - // // catching regression https://github.com/rancher/dashboard/issues/10576 - // BurgerMenuPo.checkIfClusterMenuLinkIsHighlighted('local', false); - - // // go to "add rancher repositories" - // extensionsPo.extensionMenuToggle(); - // extensionsPo.addRepositoriesClick(); - - // // add the partners repo - // extensionsPo.addReposModalAddClick(); - // extensionsPo.addReposModal().should('not.exist'); - - // // go to repos list page - // const appRepoList = new RepositoriesPagePo('local', 'apps'); - - // appRepoList.goTo(); - // appRepoList.waitForPage(); - // appRepoList.sortableTable().rowElementWithName(UI_PLUGINS_PARTNERS_REPO_URL).should('exist'); - // }); - - // it('New repos banner should only appear once (after dismiss should NOT appear again)', () => { - // cy.getRancherResource('v3', 'setting', 'display-add-extension-repos-banner', null).then((resp: Cypress.Response) => { - // const notFound = resp.status === 404; - // const requiredValue = resp.body?.value === 'true'; - - // if (notFound || requiredValue) { - // cy.log('Good test state', '/v3/setting/display-add-extension-repos-banner', resp.status, JSON.stringify(resp?.body || {})); - // } else { - // cy.log('Bad test state', '/v3/setting/display-add-extension-repos-banner', resp.status, JSON.stringify(resp?.body || {})); - - // return cy.setRancherResource('v3', 'setting', 'display-add-extension-repos-banner', { - // ...resp.body, - // value: 'true' - // }); - // } - // }); - - // const appRepoList = new RepositoriesPagePo('local', 'apps'); - - // // Ensure that the banner should be shown (by confirming that a required repo isn't there) - // appRepoList.goTo(); - // appRepoList.waitForPage(); - // appRepoList.sortableTable().noRowsShouldNotExist(); - // appRepoList.sortableTable().rowNames().then((names) => { - // if (names.includes(UI_PLUGINS_PARTNERS_REPO_NAME)) { - // appRepoList.list().actionMenu(UI_PLUGINS_PARTNERS_REPO_NAME).getMenuItem('Delete').click(); - // const promptRemove = new PromptRemove(); - - // return promptRemove.remove(); - // } - // }); - - // // Now go to extensions (by nav, not page load....) - // appRepoList.navToMenuEntry('Extensions'); - - // const extensionsPo = new ExtensionsPagePo(); - - // extensionsPo.waitForPage(); - // extensionsPo.loading().should('not.exist'); - - // extensionsPo.repoBanner().checkVisible(); - // extensionsPo.repoBanner().self().find('[data-testid="extensions-new-repos-banner-action-btn"]').click(); - // extensionsPo.repoBanner().checkNotExists(); - - // // let's refresh the page to make sure it doesn't appear again... - // extensionsPo.goTo(); - // extensionsPo.waitForPage(); - // extensionsPo.waitForTitle(); - // extensionsPo.loading().should('not.exist'); - // extensionsPo.repoBanner().checkNotExists(); - // }); - - // it('Should toggle the extension details', () => { - // const extensionsPo = new ExtensionsPagePo(); - - // extensionsPo.goTo(); - - // extensionsPo.extensionTabAvailableClick(); - - // // we should be on the extensions page - // extensionsPo.waitForTitle(); - - // // show extension details - // extensionsPo.extensionCardClick(EXTENSION_NAME); - - // // after card click, we should get the info slide in panel - // extensionsPo.extensionDetails().should('be.visible'); - // extensionsPo.extensionDetailsTitle().should('contain', EXTENSION_NAME); - - // // close the details on the cross icon X - // extensionsPo.extensionDetailsCloseClick(); - // extensionsPo.extensionDetails().should('not.be.visible'); + it('add main extensions repository', () => { + // This should be in a `before` however is flaky. Move it to an `it` to let cypress retry + const extensionsPo = new ExtensionsPagePo(); - // // show extension details again... - // extensionsPo.extensionCardClick(EXTENSION_NAME); - // extensionsPo.extensionDetails().should('be.visible'); + extensionsPo.goTo(); + extensionsPo.waitForPage(); + extensionsPo.extensionTabInstalledClick(); // Avoid nav guard failures that probably auto move user to this tab - // // clicking outside the details tab should also close it - // extensionsPo.extensionDetailsBgClick(); - // extensionsPo.extensionDetails().should('not.be.visible'); - // }); + // install the rancher plugin examples + extensionsPo.addExtensionsRepository('https://github.com/rancher/ui-plugin-charts', 'main', 'Rancher Extensions'); + }); it('can navigate to About page', () => { const aboutPage = new AboutPagePo(); @@ -189,7 +29,7 @@ describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] } AboutPagePo.navTo(); aboutPage.waitForPage(); cy.wait(10000); // eslint-disable-line cypress/no-unnecessary-waiting - // just enough to render the page on sorry-cypress + // just enough to render the page on sorry-cypress so that we can check the version }); it('Should install an extension', () => { @@ -217,202 +57,4 @@ describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] } extensionsPo.extensionDetailsTitle().should('contain', EXTENSION_NAME); extensionsPo.extensionDetailsCloseClick(); }); - - it('Should not display installed extensions within the available tab', () => { - const extensionsPo = new ExtensionsPagePo(); - - extensionsPo.goTo(); - - // check for installed extension in "installed" tab - extensionsPo.extensionTabInstalledClick(); - extensionsPo.extensionCard(EXTENSION_NAME).should('be.visible'); - - // check for installed extension in "available" tab - extensionsPo.extensionTabAvailableClick(); - extensionsPo.extensionCard(EXTENSION_NAME).should('not.exist'); - }); - - it('Should update an extension version', () => { - const extensionsPo = new ExtensionsPagePo(); - - extensionsPo.goTo(); - - extensionsPo.extensionTabInstalledClick(); - - // click on update button on card - extensionsPo.extensionCardUpdateClick(EXTENSION_NAME); - extensionsPo.installModalInstallClick(); - - // let's check the extension reload banner and reload the page - extensionsPo.extensionReloadBanner().should('be.visible'); - extensionsPo.extensionReloadClick(); - - // make sure extension card is not available anymore on the updates tab - // since we installed the latest version - extensionsPo.extensionTabUpdatesClick(); - extensionsPo.extensionCard(EXTENSION_NAME).should('not.exist'); - }); - - it('Should rollback an extension version', () => { - const extensionsPo = new ExtensionsPagePo(); - - extensionsPo.goTo(); - - extensionsPo.extensionTabInstalledClick(); - - // click on the rollback button on card - // this will rollback to the immediate previous version - extensionsPo.extensionCardRollbackClick(EXTENSION_NAME); - extensionsPo.installModalInstallClick(); - - // let's check the extension reload banner and reload the page - extensionsPo.extensionReloadBanner().should('be.visible'); - extensionsPo.extensionReloadClick(); - - // make sure extension card is on the updates tab - extensionsPo.extensionTabUpdatesClick(); - extensionsPo.extensionCard(EXTENSION_NAME).should('be.visible'); - }); - - // it('An extension larger than 20mb, which will trigger chacheState disabled, should install and work fine', () => { - // const extensionsPo = new ExtensionsPagePo(); - - // extensionsPo.goTo(); - - // extensionsPo.extensionTabAvailableClick(); - - // // click on install button on card - // extensionsPo.extensionCardInstallClick(DISABLED_CACHE_EXTENSION_NAME); - // extensionsPo.extensionInstallModal().should('be.visible'); - - // // click install - // extensionsPo.installModalInstallClick(); - - // // let's check the extension reload banner and reload the page - // extensionsPo.extensionReloadBanner().should('be.visible'); - // extensionsPo.extensionReloadClick(); - - // // make sure extension card is in the installed tab - // extensionsPo.extensionTabInstalledClick(); - // extensionsPo.extensionCardClick(DISABLED_CACHE_EXTENSION_NAME); - // extensionsPo.extensionDetailsTitle().should('contain', DISABLED_CACHE_EXTENSION_NAME); - // extensionsPo.extensionDetailsCloseClick(); - - // // check if extension is working fine - // BurgerMenuPo.burgerMenuNavToMenubyLabel(DISABLED_CACHE_EXTENSION_MENU_LABEL); - // cy.get('h1').should('have.text', DISABLED_CACHE_EXTENSION_TITLE); - // }); - - // it('Should respect authentication when importing extension scripts', () => { - // const extensionsPo = new ExtensionsPagePo(); - - // extensionsPo.goTo(); - - // extensionsPo.extensionTabAvailableClick(); - - // // Install unauthenticated extension - // extensionsPo.extensionCardInstallClick(UNAUTHENTICATED_EXTENSION_NAME); - // extensionsPo.extensionInstallModal().should('be.visible'); - // extensionsPo.installModalInstallClick(); - - // // let's check the extension reload banner and reload the page - // extensionsPo.extensionReloadBanner().should('be.visible'); - // extensionsPo.extensionReloadClick(); - - // // make sure both extensions have been imported - // extensionsPo.extensionScriptImport(UNAUTHENTICATED_EXTENSION_NAME).should('exist'); - // extensionsPo.extensionScriptImport(EXTENSION_NAME).should('exist'); - - // cy.logout(); - - // // make sure only the unauthenticated extension has been imported after logout - // const loginPage = new LoginPagePo(); - - // loginPage.goTo(); - // loginPage.waitForPage(); - // loginPage.extensionScriptImport(UNAUTHENTICATED_EXTENSION_NAME).should('exist'); - // loginPage.extensionScriptImport(EXTENSION_NAME).should('not.exist'); - - // // make sure both extensions have been imported after logging in again - // cy.login(undefined, undefined, false); - // extensionsPo.goTo(); - // extensionsPo.waitForPage(); - // extensionsPo.waitForTitle(); - // extensionsPo.extensionScriptImport(UNAUTHENTICATED_EXTENSION_NAME).should('exist'); - // extensionsPo.extensionScriptImport(EXTENSION_NAME).should('exist'); - // }); - - it('Should uninstall extensions', () => { - // Because we logged out in the previous test this one will also have to use an uncached login - cy.login(undefined, undefined, false); - const extensionsPo = new ExtensionsPagePo(); - - extensionsPo.goTo(); - - extensionsPo.extensionTabInstalledClick(); - - // click on uninstall button on card - extensionsPo.extensionCardUninstallClick(EXTENSION_NAME); - extensionsPo.extensionUninstallModal().should('be.visible'); - extensionsPo.uninstallModaluninstallClick(); - extensionsPo.extensionReloadBanner().should('be.visible'); - - // let's check the extension reload banner and reload the page - extensionsPo.extensionReloadBanner().should('be.visible'); - extensionsPo.extensionReloadClick(); - - // make sure extension card is in the available tab - extensionsPo.extensionTabAvailableClick(); - extensionsPo.extensionCardClick(EXTENSION_NAME); - extensionsPo.extensionDetailsTitle().should('contain', EXTENSION_NAME); - }); - - // it('Should uninstall unathenticated extensions', () => { - // // Because we logged out in the previous test this one will also have to use an uncached login - // cy.login(undefined, undefined, false); - // const extensionsPo = new ExtensionsPagePo(); - - // extensionsPo.goTo(); - - // extensionsPo.extensionTabInstalledClick(); - - // // click on uninstall button on card - // extensionsPo.extensionCardUninstallClick(UNAUTHENTICATED_EXTENSION_NAME); - // extensionsPo.extensionUninstallModal().should('be.visible'); - // extensionsPo.uninstallModaluninstallClick(); - // extensionsPo.extensionReloadBanner().should('be.visible'); - - // // let's check the extension reload banner and reload the page - // extensionsPo.extensionReloadBanner().should('be.visible'); - // extensionsPo.extensionReloadClick(); - - // // make sure extension card is in the available tab - // extensionsPo.extensionTabAvailableClick(); - // extensionsPo.extensionCardClick(UNAUTHENTICATED_EXTENSION_NAME); - // extensionsPo.extensionDetailsTitle().should('contain', UNAUTHENTICATED_EXTENSION_NAME); - // }); - - // it('Should uninstall un-cached extensions', () => { - // // Because we logged out in the previous test this one will also have to use an uncached login - // cy.login(undefined, undefined, false); - // const extensionsPo = new ExtensionsPagePo(); - - // extensionsPo.goTo(); - - // extensionsPo.extensionTabInstalledClick(); - - // // click on uninstall button on card - // extensionsPo.extensionCardUninstallClick(DISABLED_CACHE_EXTENSION_NAME); - // extensionsPo.extensionUninstallModal().should('be.visible'); - // extensionsPo.uninstallModaluninstallClick(); - - // // let's check the extension reload banner and reload the page - // extensionsPo.extensionReloadBanner().should('be.visible'); - // extensionsPo.extensionReloadClick(); - - // // make sure extension card is in the available tab - // extensionsPo.extensionTabAvailableClick(); - // extensionsPo.extensionCardClick(DISABLED_CACHE_EXTENSION_NAME); - // extensionsPo.extensionDetailsTitle().should('contain', DISABLED_CACHE_EXTENSION_NAME); - // }); }); From aee3326e0cd02cabc75df54d17e4acd57fde7552 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 25 Jul 2024 15:43:11 +0100 Subject: [PATCH 23/46] add main repo of extensions to see if test passes --- .github/workflows/extensions-compatibility-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index 9471ef35b39..4a9da43a79a 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -36,7 +36,7 @@ jobs: ] rancherEnv: [ 'v2.9-head', - 'v2.8-head', + # 'v2.8-head', ] runs-on: ubuntu-latest steps: From 8736d1102274f8c344bb5d576abcbdf8f22a6dad Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 25 Jul 2024 16:16:35 +0100 Subject: [PATCH 24/46] add main repo of extensions to see if test passes --- .../elemental.spec.ts | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts index cf824c65a1e..bbfe266d1ca 100644 --- a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts +++ b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts @@ -1,4 +1,6 @@ import ExtensionsPagePo from '@/cypress/e2e/po/pages/extensions.po'; +import ReposListPagePo from '@/cypress/e2e/po/pages/chart-repositories.po'; +import AppClusterRepoEditPo from '@/cypress/e2e/po/edit/catalog.cattle.io.clusterrepo.po'; import HomePagePo from '@/cypress/e2e/po/pages/home.po'; import AboutPagePo from '@/cypress/e2e/po/pages/about.po'; @@ -11,15 +13,35 @@ describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] } }); it('add main extensions repository', () => { - // This should be in a `before` however is flaky. Move it to an `it` to let cypress retry - const extensionsPo = new ExtensionsPagePo(); + // // This should be in a `before` however is flaky. Move it to an `it` to let cypress retry + // const extensionsPo = new ExtensionsPagePo(); - extensionsPo.goTo(); - extensionsPo.waitForPage(); - extensionsPo.extensionTabInstalledClick(); // Avoid nav guard failures that probably auto move user to this tab + // extensionsPo.goTo(); + // extensionsPo.waitForPage(); + // extensionsPo.extensionTabInstalledClick(); // Avoid nav guard failures that probably auto move user to this tab + + // // install the rancher plugin examples + // extensionsPo.addExtensionsRepository('https://github.com/rancher/ui-plugin-charts', 'main', 'Rancher Extensions'); + + // const appRepoList = new ReposListPagePo('local', 'apps'); + + // appRepoList.goTo(); + // appRepoList.waitForGoTo('/v1/catalog.cattle.io.clusterrepos?exclude=metadata.managedFields'); + // appRepoList.create(); + + const appRepoCreate = new AppClusterRepoEditPo('local', 'create'); + + appRepoCreate.goTo(); + appRepoCreate.waitForPage(); + + appRepoCreate.nameNsDescription().name().set('rancher-extensions'); + appRepoCreate.selectRadioOptionGitRepo(1); + // fill the git repo form + appRepoCreate.enterGitRepoName('https://github.com/rancher/ui-plugin-charts'); + appRepoCreate.enterGitBranchName('main'); + appRepoCreate.create().click(); - // install the rancher plugin examples - extensionsPo.addExtensionsRepository('https://github.com/rancher/ui-plugin-charts', 'main', 'Rancher Extensions'); + cy.wait(5000); // eslint-disable-line cypress/no-unnecessary-waiting }); it('can navigate to About page', () => { @@ -28,7 +50,7 @@ describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] } HomePagePo.goToAndWaitForGet(); AboutPagePo.navTo(); aboutPage.waitForPage(); - cy.wait(10000); // eslint-disable-line cypress/no-unnecessary-waiting + cy.wait(5000); // eslint-disable-line cypress/no-unnecessary-waiting // just enough to render the page on sorry-cypress so that we can check the version }); From 31f82065abbdb26a1e00566df6022b0f8f0e5307 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Fri, 26 Jul 2024 09:53:41 +0100 Subject: [PATCH 25/46] adjust e2e test run to pass spec + adjust add of main extensions repo --- .../extensions-compatibility-tests.yaml | 2 +- cypress/e2e/po/pages/extensions.po.ts | 28 +++++++++++++++ .../elemental.spec.ts | 34 +++---------------- package.json | 2 +- scripts/e2e | 11 +++++- 5 files changed, 44 insertions(+), 33 deletions(-) diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index 4a9da43a79a..da6d66b1549 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -62,7 +62,7 @@ jobs: # This is the actual triggering of the e2e test specs - name: Run user tests run: | - yarn e2e:prod + export SPEC_FILE="cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts" && yarn e2e:prod [ "$BUILD_DASHBOARD" != "false" ] || exit 0 env: TEST_SKIP: setup diff --git a/cypress/e2e/po/pages/extensions.po.ts b/cypress/e2e/po/pages/extensions.po.ts index 06055ef4fc8..47188cb17c9 100644 --- a/cypress/e2e/po/pages/extensions.po.ts +++ b/cypress/e2e/po/pages/extensions.po.ts @@ -6,6 +6,7 @@ import NameNsDescriptionPo from '@/cypress/e2e/po/components/name-ns-description import RepositoriesPagePo from '@/cypress/e2e/po/pages/chart-repositories.po'; import BannersPo from '@/cypress/e2e/po/components/banners.po'; import ChartRepositoriesCreateEditPo from '@/cypress/e2e/po/edit/chart-repositories.po'; +import AppClusterRepoEditPo from '@/cypress/e2e/po/edit/catalog.cattle.io.clusterrepo.po'; import { LONG_TIMEOUT_OPT } from '@/cypress/support/utils/timeouts'; export default class ExtensionsPagePo extends PagePo { @@ -83,6 +84,33 @@ export default class ExtensionsPagePo extends PagePo { appRepoList.list().state(name).should('contain', 'Active'); } + /** + * Adds a cluster repo for extensions + * @param repo - The repository url (e.g. https://github.com/rancher/ui-plugin-examples) + * @param branch - The git branch to target + * @param name - A name for the repository + * @returns {Cypress.Chainable} + */ + addExtensionsRepositoryNew(repo: string, branch: string, name: string, waitForActiveState = true): Cypress.Chainable { + const appRepoList = new RepositoriesPagePo('local', 'apps'); + const appRepoCreate = new AppClusterRepoEditPo('local', 'create'); + + appRepoCreate.goTo(); + appRepoCreate.waitForPage(); + + appRepoCreate.nameNsDescription().name().set(name); + appRepoCreate.selectRadioOptionGitRepo(1); + // fill the git repo form + appRepoCreate.enterGitRepoName(repo); + appRepoCreate.enterGitBranchName(branch); + appRepoCreate.create().click(); + + if (waitForActiveState) { + appRepoList.waitForPage(); + appRepoList.list().state(name).should('contain', 'Active'); + } + } + // ------------------ extension card ------------------ extensionCard(extensionName: string) { return this.self().getId(`extension-card-${ extensionName }`); diff --git a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts index bbfe266d1ca..48c3566f610 100644 --- a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts +++ b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts @@ -1,6 +1,4 @@ import ExtensionsPagePo from '@/cypress/e2e/po/pages/extensions.po'; -import ReposListPagePo from '@/cypress/e2e/po/pages/chart-repositories.po'; -import AppClusterRepoEditPo from '@/cypress/e2e/po/edit/catalog.cattle.io.clusterrepo.po'; import HomePagePo from '@/cypress/e2e/po/pages/home.po'; import AboutPagePo from '@/cypress/e2e/po/pages/about.po'; @@ -14,37 +12,13 @@ describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] } it('add main extensions repository', () => { // // This should be in a `before` however is flaky. Move it to an `it` to let cypress retry - // const extensionsPo = new ExtensionsPagePo(); - - // extensionsPo.goTo(); - // extensionsPo.waitForPage(); - // extensionsPo.extensionTabInstalledClick(); // Avoid nav guard failures that probably auto move user to this tab - - // // install the rancher plugin examples - // extensionsPo.addExtensionsRepository('https://github.com/rancher/ui-plugin-charts', 'main', 'Rancher Extensions'); - - // const appRepoList = new ReposListPagePo('local', 'apps'); - - // appRepoList.goTo(); - // appRepoList.waitForGoTo('/v1/catalog.cattle.io.clusterrepos?exclude=metadata.managedFields'); - // appRepoList.create(); - - const appRepoCreate = new AppClusterRepoEditPo('local', 'create'); - - appRepoCreate.goTo(); - appRepoCreate.waitForPage(); - - appRepoCreate.nameNsDescription().name().set('rancher-extensions'); - appRepoCreate.selectRadioOptionGitRepo(1); - // fill the git repo form - appRepoCreate.enterGitRepoName('https://github.com/rancher/ui-plugin-charts'); - appRepoCreate.enterGitBranchName('main'); - appRepoCreate.create().click(); + const extensionsPo = new ExtensionsPagePo(); - cy.wait(5000); // eslint-disable-line cypress/no-unnecessary-waiting + extensionsPo.addExtensionsRepositoryNew('https://github.com/rancher/ui-plugin-charts', 'main', 'rancher-extensions'); }); - it('can navigate to About page', () => { + // TODO: TO REMOVE ONCE EVERYTHING IS GOOD! + it('can navigate to About page (get version from about page screenshots to make sure we are on the right system)', () => { const aboutPage = new AboutPagePo(); HomePagePo.goToAndWaitForGet(); diff --git a/package.json b/package.json index 489e2ea7e93..ccf36857384 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "cy:e2e": "cypress open --e2e --browser chrome", "cy:open": "cypress open", "cy:run": "cypress run --browser chrome", - "cy:run:sorry": "./scripts/e2e", + "cy:run:sorry": "./scripts/e2e $SPEC_FILE", "e2e:pre-dev": "yarn docker:local:stop && yarn docker:local:start && NODE_ENV=dev TEST_INSTRUMENT=true yarn build", "e2e:dev": "START_SERVER_AND_TEST_INSECURE=1 server-test start:dev https-get://localhost:8005 cy:run:sorry", "e2e:build": "mkdir dist && TEST_INSTRUMENT=true ./scripts/build-e2e", diff --git a/scripts/e2e b/scripts/e2e index d961830d62e..34029497c7a 100755 --- a/scripts/e2e +++ b/scripts/e2e @@ -2,4 +2,13 @@ ID="$(echo ${TEST_RUN_ID:-`date +%s` } | tr '[:upper:]' '[:lower:]' | tr ' ' '-')" echo "$ID" -CYPRESS_coverage=true CYPRESS_API_URL='http://139.59.134.103:1234' cy2 run --group "$GREP_TAGS" --browser chrome --record --key rancher-dashboard --parallel --ci-build-id "$ID" + + +# check if script invoke contains any argument. If so, add spec to run +if [ $# -eq 1 ]; then + echo "on the e2e script file where SPEC=$1" + CYPRESS_coverage=true CYPRESS_API_URL='http://139.59.134.103:1234' cy2 run --spec "$1" --group "$GREP_TAGS" --browser chrome --record --key rancher-dashboard --parallel --ci-build-id "$ID" +else + echo "normal e2e script" + CYPRESS_coverage=true CYPRESS_API_URL='http://139.59.134.103:1234' cy2 run --group "$GREP_TAGS" --browser chrome --record --key rancher-dashboard --parallel --ci-build-id "$ID" +fi From f5bd3e3c4963dd6a48b066c71125c87b86951a8d Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Fri, 26 Jul 2024 12:11:37 +0100 Subject: [PATCH 26/46] small change --- .github/workflows/extensions-compatibility-tests.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index da6d66b1549..76870ec73bb 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -35,27 +35,28 @@ jobs: # ['@neuvector'] ] rancherEnv: [ - 'v2.9-head', - # 'v2.8-head', + ['v2.9-head', 'master'], + # ['v2.8-head', 'release-2.8'] ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: + ref: matrix.rancherEnv[1] fetch-depth: 1 - name: Setup env uses: ./.github/actions/setup # this is where docker is set up with the enviroment - name: Run Rancher ${{ matrix.rancherEnv }} - run: export RANCHER_VERSION_E2E=${{ matrix.rancherEnv }} && yarn e2e:docker + run: export RANCHER_VERSION_E2E=${{ matrix.rancherEnv[0] }} && yarn e2e:docker ## this is just setting up rancher and user - name: Setup Rancher and user run: | yarn e2e:prod env: - GREP_TAGS: ${{ matrix.role.tag }}Setup+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}Setup+${{ matrix.features[1] || matrix.features[0] }} --@jenkins + GREP_TAGS: ${{ matrix.role.tag }}Setup+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}Setup+${{ matrix.features[0] }} --@jenkins TEST_USERNAME: ${{ matrix.role.username }} TEST_ONLY: setup @@ -66,7 +67,7 @@ jobs: [ "$BUILD_DASHBOARD" != "false" ] || exit 0 env: TEST_SKIP: setup - GREP_TAGS: ${{ matrix.role.tag }}+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}+${{ matrix.features[1] || matrix.features[0] }} --@jenkins + GREP_TAGS: ${{ matrix.role.tag }}+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}+${{ matrix.features[0] }} --@jenkins TEST_USERNAME: ${{ matrix.role.username }} - name: Upload screenshots From ec8285223c0632b9a8563c6644ef3e6221e15bdc Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Fri, 26 Jul 2024 14:30:25 +0100 Subject: [PATCH 27/46] fix matrix stuff --- .github/workflows/extensions-compatibility-tests.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index 76870ec73bb..fae0d44f037 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -42,13 +42,13 @@ jobs: steps: - uses: actions/checkout@v3 with: - ref: matrix.rancherEnv[1] + ref: ${{ matrix.rancherEnv[1] }} fetch-depth: 1 - name: Setup env uses: ./.github/actions/setup # this is where docker is set up with the enviroment - - name: Run Rancher ${{ matrix.rancherEnv }} + - name: Run Rancher ${{ matrix.rancherEnv[0] }} - branch:${{ matrix.rancherEnv[1] }} run: export RANCHER_VERSION_E2E=${{ matrix.rancherEnv[0] }} && yarn e2e:docker ## this is just setting up rancher and user @@ -56,7 +56,7 @@ jobs: run: | yarn e2e:prod env: - GREP_TAGS: ${{ matrix.role.tag }}Setup+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}Setup+${{ matrix.features[0] }} --@jenkins + GREP_TAGS: ${{ matrix.role.tag }}Setup+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}Setup+${{ matrix.features[1] || matrix.features[0] }} --@jenkins TEST_USERNAME: ${{ matrix.role.username }} TEST_ONLY: setup @@ -67,7 +67,7 @@ jobs: [ "$BUILD_DASHBOARD" != "false" ] || exit 0 env: TEST_SKIP: setup - GREP_TAGS: ${{ matrix.role.tag }}+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}+${{ matrix.features[0] }} --@jenkins + GREP_TAGS: ${{ matrix.role.tag }}+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}+${{ matrix.features[1] || matrix.features[0] }} --@jenkins TEST_USERNAME: ${{ matrix.role.username }} - name: Upload screenshots From 608452d71d4587714157e260986e82706c1be2e6 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Wed, 31 Jul 2024 11:10:05 +0100 Subject: [PATCH 28/46] use same version as master for test.yaml --- .github/workflows/test.yaml | 48 +++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5ca908f7eba..ffe1edfc3a7 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -178,6 +178,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 1 +<<<<<<< HEAD <<<<<<< HEAD - uses: actions/setup-node@v4 with: @@ -198,6 +199,11 @@ jobs: with: node-version: '16.x' >>>>>>> f0bfe54175 (comment workflows) +======= + - uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' +>>>>>>> 46989f9ad6 (use same version as master for test.yaml) - name: Install packages run: yarn install:ci @@ -262,6 +268,7 @@ jobs: - name: Run tests uses: ./.github/actions/lint <<<<<<< HEAD +<<<<<<< HEAD >>>>>>> f0bfe54175 (comment workflows) ======= @@ -274,21 +281,32 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 1 +======= +>>>>>>> 46989f9ad6 (use same version as master for test.yaml) - - uses: actions/setup-node@v3 - with: - node-version: '16.x' + # coverage: + # runs-on: ubuntu-latest + # needs: + # - unit-test + # steps: + # - uses: actions/checkout@v3 + # with: + # fetch-depth: 1 - - name: Download Coverage Artifacts - uses: actions/download-artifact@v3 - with: - name: ${{github.run_number}}-${{github.run_attempt}}-coverage + # - uses: actions/setup-node@v4 + # with: + # node-version-file: '.nvmrc' - - name: Install Codecov CLI - run : .github/workflows/scripts/install-codecov.sh + # - name: Download Coverage Artifacts + # uses: actions/download-artifact@v3 + # with: + # name: ${{github.run_number}}-${{github.run_attempt}}-coverage - - name: Upload tests coverage report to Codecov - run: ./codecov --verbose upload-process -t ${{ secrets.CODECOV_TOKEN }} -n ${{github.run_number}}-${{github.run_attempt}}-coverage -F unit -f ./coverage/coverage-unit.json + # - name: Install Codecov CLI + # run : .github/workflows/scripts/install-codecov.sh + + # - name: Upload tests coverage report to Codecov + # run: ./codecov --verbose upload-process -t ${{ secrets.CODECOV_TOKEN }} -n ${{github.run_number}}-${{github.run_attempt}}-coverage -F unit -f ./coverage/coverage-unit.json <<<<<<< HEAD >>>>>>> 7cea97aad2 (comment workflows) @@ -315,10 +333,14 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 1 - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: - node-version: '16.x' + node-version-file: '.nvmrc' - name: Check e2e tags run: | +<<<<<<< HEAD ./scripts/check-e2e-tests-for-tags >>>>>>> f0bfe54175 (comment workflows) +======= + ./scripts/check-e2e-tests-for-tags +>>>>>>> 46989f9ad6 (use same version as master for test.yaml) From 087a32130db2fd5c82a160b82b4b11fda63ec920 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Wed, 31 Jul 2024 11:14:46 +0100 Subject: [PATCH 29/46] update --- .github/workflows/test.yaml | 114 +----------------------------------- 1 file changed, 1 insertion(+), 113 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ffe1edfc3a7..7f45ff23ceb 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -168,42 +168,15 @@ jobs: - name: Run i18n lint uses: ./.github/actions/i18n-lint -<<<<<<< HEAD -<<<<<<< HEAD -======= ->>>>>>> f0bfe54175 (comment workflows) check-i18n: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 1 -<<<<<<< HEAD -<<<<<<< HEAD - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' -======= -# check-i18n: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v3 -# with: -# fetch-depth: 1 -# - uses: actions/setup-node@v3 -# with: -# node-version: '16.x' ->>>>>>> d05c7b9587 (bind to only v2.9 to check if tests pass + comment other workflows) -======= - - uses: actions/setup-node@v3 - with: - node-version: '16.x' ->>>>>>> f0bfe54175 (comment workflows) -======= - - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' ->>>>>>> 46989f9ad6 (use same version as master for test.yaml) - name: Install packages run: yarn install:ci @@ -220,69 +193,8 @@ jobs: with: fetch-depth: 1 -<<<<<<< HEAD -# - name: Run tests -# uses: ./.github/actions/lint -<<<<<<< HEAD - -<<<<<<< HEAD - # coverage: - # runs-on: ubuntu-latest - # needs: - # - unit-test - # steps: - # - uses: actions/checkout@v3 - # with: - # fetch-depth: 1 - - # - uses: actions/setup-node@v4 - # with: - # node-version-file: '.nvmrc' - - # - name: Download Coverage Artifacts - # uses: actions/download-artifact@v3 - # with: - # name: ${{github.run_number}}-${{github.run_attempt}}-coverage - - # - name: Install Codecov CLI - # run : .github/workflows/scripts/install-codecov.sh - - # - name: Upload tests coverage report to Codecov - # run: ./codecov --verbose upload-process -t ${{ secrets.CODECOV_TOKEN }} -n ${{github.run_number}}-${{github.run_attempt}}-coverage -F unit -f ./coverage/coverage-unit.json - - check-e2e-tags: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - - name: Check e2e tags - run: | - ./scripts/check-e2e-tests-for-tags -======= -======= -======= - name: Run tests uses: ./.github/actions/lint -<<<<<<< HEAD -<<<<<<< HEAD ->>>>>>> f0bfe54175 (comment workflows) - -======= ->>>>>>> 15910841c9 (see if setup runs) - coverage: - runs-on: ubuntu-latest - needs: - - unit-test - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 1 -======= ->>>>>>> 46989f9ad6 (use same version as master for test.yaml) # coverage: # runs-on: ubuntu-latest @@ -308,25 +220,6 @@ jobs: # - name: Upload tests coverage report to Codecov # run: ./codecov --verbose upload-process -t ${{ secrets.CODECOV_TOKEN }} -n ${{github.run_number}}-${{github.run_attempt}}-coverage -F unit -f ./coverage/coverage-unit.json -<<<<<<< HEAD ->>>>>>> 7cea97aad2 (comment workflows) -# check-e2e-tags: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v3 -# with: -# fetch-depth: 1 -# - uses: actions/setup-node@v3 -# with: -# node-version: '16.x' -# - name: Check e2e tags -# run: | -# ./scripts/check-e2e-tests-for-tags -<<<<<<< HEAD ->>>>>>> d05c7b9587 (bind to only v2.9 to check if tests pass + comment other workflows) -======= ->>>>>>> 7cea97aad2 (comment workflows) -======= check-e2e-tags: runs-on: ubuntu-latest steps: @@ -338,9 +231,4 @@ jobs: node-version-file: '.nvmrc' - name: Check e2e tags run: | -<<<<<<< HEAD - ./scripts/check-e2e-tests-for-tags ->>>>>>> f0bfe54175 (comment workflows) -======= - ./scripts/check-e2e-tests-for-tags ->>>>>>> 46989f9ad6 (use same version as master for test.yaml) + ./scripts/check-e2e-tests-for-tags \ No newline at end of file From 4d1bd323cc8221c0221dc014b65b4a327284fed3 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Wed, 31 Jul 2024 11:22:20 +0100 Subject: [PATCH 30/46] fix merge conflicts --- .github/workflows/add-issue-labels.yaml | 6 -- .../workflows/build-and-upload-release.yaml | 4 -- .github/workflows/build-and-upload.yaml | 12 ---- .github/workflows/build-extension-catalog.yml | 12 ---- .github/workflows/build-extension-charts.yml | 12 ---- .github/workflows/check-plugins.yaml | 41 ------------- .github/workflows/docusaurus.yaml | 42 -------------- .github/workflows/pr-gh-project.yaml | 6 -- .github/workflows/rancher-components.yaml | 12 ---- .../workflows/release-rancher-components.yml | 6 -- .github/workflows/release-rancher-desktop.yml | 58 ------------------- .github/workflows/release-shell-pkg.yaml | 12 ---- .github/workflows/storybook.yaml | 52 +---------------- 13 files changed, 1 insertion(+), 274 deletions(-) delete mode 100644 .github/workflows/release-rancher-desktop.yml diff --git a/.github/workflows/add-issue-labels.yaml b/.github/workflows/add-issue-labels.yaml index 075ac5d99fa..8db01a51cc0 100644 --- a/.github/workflows/add-issue-labels.yaml +++ b/.github/workflows/add-issue-labels.yaml @@ -11,15 +11,9 @@ jobs: steps: - uses: actions/checkout@v2 - name: Use Node.js -<<<<<<< HEAD uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' -======= - uses: actions/setup-node@v1 - with: - node-version: '16.x' ->>>>>>> b7384b5fad (Revert "script adjustment/fix") - name: script env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/build-and-upload-release.yaml b/.github/workflows/build-and-upload-release.yaml index d9b3f1f7f5e..7f514d00fda 100644 --- a/.github/workflows/build-and-upload-release.yaml +++ b/.github/workflows/build-and-upload-release.yaml @@ -2,11 +2,7 @@ name: Build Dashboard (Release) on: push: tags: -<<<<<<< HEAD - v2.* -======= - - v2.9.* ->>>>>>> b7384b5fad (Revert "script adjustment/fix") jobs: build-validation: diff --git a/.github/workflows/build-and-upload.yaml b/.github/workflows/build-and-upload.yaml index 3ca35d98bd2..434ca3bef7a 100644 --- a/.github/workflows/build-and-upload.yaml +++ b/.github/workflows/build-and-upload.yaml @@ -27,15 +27,9 @@ jobs: fetch-depth: 1 # Note - Cannot use the setup action here as it uses a different yarn install arg -<<<<<<< HEAD - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' -======= - - uses: actions/setup-node@v3 - with: - node-version: '14.x' ->>>>>>> b7384b5fad (Revert "script adjustment/fix") cache: 'yarn' # Build a directory containing the dashboard that can be used with ui-dashboard-index @@ -80,15 +74,9 @@ jobs: fetch-depth: 1 # Note - Cannot use the setup action here as it uses a different yarn install arg -<<<<<<< HEAD - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' -======= - - uses: actions/setup-node@v3 - with: - node-version: '14.x' ->>>>>>> b7384b5fad (Revert "script adjustment/fix") cache: 'yarn' # Build a tar that will be picked up by rancher builds and embedded into it diff --git a/.github/workflows/build-extension-catalog.yml b/.github/workflows/build-extension-catalog.yml index 18698a41c86..bbd6bbd6ed7 100644 --- a/.github/workflows/build-extension-catalog.yml +++ b/.github/workflows/build-extension-catalog.yml @@ -48,29 +48,17 @@ jobs: version: v3.8.0 - name: Setup Nodejs and npm -<<<<<<< HEAD uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' -======= - uses: actions/setup-node@v3 - with: - node-version: '16' ->>>>>>> b7384b5fad (Revert "script adjustment/fix") - name: Setup yarn run: npm install -g yarn - name: Setup Nodejs with yarn caching -<<<<<<< HEAD uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' -======= - uses: actions/setup-node@v3 - with: - node-version: '16' ->>>>>>> b7384b5fad (Revert "script adjustment/fix") cache: yarn - name: Install dependencies diff --git a/.github/workflows/build-extension-charts.yml b/.github/workflows/build-extension-charts.yml index 72fb2cc762b..a1ffe2d6212 100644 --- a/.github/workflows/build-extension-charts.yml +++ b/.github/workflows/build-extension-charts.yml @@ -43,29 +43,17 @@ jobs: version: v3.8.0 - name: Setup Nodejs and npm -<<<<<<< HEAD uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' -======= - uses: actions/setup-node@v3 - with: - node-version: '16' ->>>>>>> b7384b5fad (Revert "script adjustment/fix") - name: Setup yarn run: npm install -g yarn - name: Setup Nodejs with yarn caching -<<<<<<< HEAD uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' -======= - uses: actions/setup-node@v3 - with: - node-version: '16' ->>>>>>> b7384b5fad (Revert "script adjustment/fix") cache: yarn - name: Install dependencies diff --git a/.github/workflows/check-plugins.yaml b/.github/workflows/check-plugins.yaml index bb723a937c9..112680f5a2f 100644 --- a/.github/workflows/check-plugins.yaml +++ b/.github/workflows/check-plugins.yaml @@ -1,16 +1,8 @@ -<<<<<<< HEAD -<<<<<<< HEAD -======= ->>>>>>> 25d6584234 (comment workflows) name: check-plugins-build on: pull_request: branches: -<<<<<<< HEAD - - master -======= - master-bananas ->>>>>>> 25d6584234 (comment workflows) env: TEST_PERSIST_BUILD: true jobs: @@ -22,43 +14,10 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: -<<<<<<< HEAD -<<<<<<< HEAD node-version-file: '.nvmrc' -======= - node-version: '16.20.2' ->>>>>>> b7384b5fad (Revert "script adjustment/fix") - name: Validate Plugin build system run: ./shell/scripts/test-plugins-build.sh shell: bash -======= -# name: check-plugins-build -# on: -# pull_request: -# branches: -# - master -# env: -# TEST_PERSIST_BUILD: true -# jobs: -# validate: -# runs-on: ubuntu-latest -# steps: -# - name: Checkout -# uses: actions/checkout@v4 -# - name: Setup Node.js -# uses: actions/setup-node@v4 -# with: -# node-version: '16.20.2' -# - name: Validate Plugin build system -# run: ./shell/scripts/test-plugins-build.sh -# shell: bash ->>>>>>> 25d643d2d3 (comment workflows) -======= - node-version: '16.20.2' - - name: Validate Plugin build system - run: ./shell/scripts/test-plugins-build.sh - shell: bash ->>>>>>> 25d6584234 (comment workflows) - name: Upload files uses: actions/upload-artifact@v3 diff --git a/.github/workflows/docusaurus.yaml b/.github/workflows/docusaurus.yaml index 12558bb6726..b434d892797 100644 --- a/.github/workflows/docusaurus.yaml +++ b/.github/workflows/docusaurus.yaml @@ -1,64 +1,22 @@ name: Publish Docusaurus -<<<<<<< HEAD -<<<<<<< HEAD -======= ->>>>>>> 25d6584234 (comment workflows) on: push: branches: - master -<<<<<<< HEAD - pull_request: - branches: - - master -======= # pull_request: # branches: # - master ->>>>>>> 25d6584234 (comment workflows) jobs: build: name: Build runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 -<<<<<<< HEAD -<<<<<<< HEAD - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' -======= - - uses: actions/setup-node@v3 - with: - node-version: 16.x ->>>>>>> b7384b5fad (Revert "script adjustment/fix") - cache: yarn -======= -# on: -# push: -# branches: -# - master -# pull_request: -# branches: -# - master -# jobs: -# build: -# name: Build -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v2 -# - uses: actions/setup-node@v3 -# with: -# node-version: 16.x -# cache: yarn ->>>>>>> 25d643d2d3 (comment workflows) -======= - - uses: actions/setup-node@v3 - with: - node-version: 16.x cache: yarn ->>>>>>> 25d6584234 (comment workflows) - name: Install dependencies run: cd docusaurus/ && yarn install:ci diff --git a/.github/workflows/pr-gh-project.yaml b/.github/workflows/pr-gh-project.yaml index 3d8627d8847..971dc8c265a 100644 --- a/.github/workflows/pr-gh-project.yaml +++ b/.github/workflows/pr-gh-project.yaml @@ -14,15 +14,9 @@ jobs: steps: - uses: actions/checkout@v2 - name: Use Node.js -<<<<<<< HEAD uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' -======= - uses: actions/setup-node@v1 - with: - node-version: '16.x' ->>>>>>> b7384b5fad (Revert "script adjustment/fix") - name: Read secrets uses: rancher-eio/read-vault-secrets@main with: diff --git a/.github/workflows/rancher-components.yaml b/.github/workflows/rancher-components.yaml index ade60ebac7b..5f20eb5aedf 100644 --- a/.github/workflows/rancher-components.yaml +++ b/.github/workflows/rancher-components.yaml @@ -13,15 +13,9 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 1 -<<<<<<< HEAD - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' -======= - - uses: actions/setup-node@v3 - with: - node-version: '14.x' ->>>>>>> b7384b5fad (Revert "script adjustment/fix") - name: Install packages run: yarn install @@ -35,15 +29,9 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 1 -<<<<<<< HEAD - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' -======= - - uses: actions/setup-node@v3 - with: - node-version: '14.x' ->>>>>>> b7384b5fad (Revert "script adjustment/fix") - name: Install packages run: yarn install diff --git a/.github/workflows/release-rancher-components.yml b/.github/workflows/release-rancher-components.yml index a06afff717b..28313b443b7 100644 --- a/.github/workflows/release-rancher-components.yml +++ b/.github/workflows/release-rancher-components.yml @@ -17,15 +17,9 @@ jobs: fetch-depth: 0 persist-credentials: false -<<<<<<< HEAD - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' -======= - - uses: actions/setup-node@v3 - with: - node-version: '16.x' ->>>>>>> b7384b5fad (Revert "script adjustment/fix") registry-url: 'https://registry.npmjs.org' scope: '@rancher' diff --git a/.github/workflows/release-rancher-desktop.yml b/.github/workflows/release-rancher-desktop.yml deleted file mode 100644 index 4b6e149222b..00000000000 --- a/.github/workflows/release-rancher-desktop.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Build and Release Rancher Dashboard - Rancher Desktop Embed - -on: - push: - tags: - - 'desktop-v*' - -env: - OUTPUT_DIR: dist - RELEASE_DIR: release - ARTIFACT_NAME: rancher-dashboard-desktop-embed - API: "https://127.0.0.1:9443" - RESOURCE_BASE: "https://127.0.0.1:9443" - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - persist-credentials: false - - - uses: actions/setup-node@v2 - with: - node-version: '12.x' - - - name: Install & Build - run: - ROUTER_BASE="/dashboard" RANCHER_ENV=desktop ./.github/workflows/scripts/build-dashboard.sh - - - name: Upload Build - uses: actions/upload-artifact@v2 - with: - path: ${{ env.RELEASE_DIR}}/${{ env.ARTIFACT_NAME }}* - name: ${{ env.ARTIFACT_NAME }} - if-no-files-found: error - - release: - runs-on: ubuntu-latest - needs: build - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 1 - persist-credentials: false - - name: Download build - uses: actions/download-artifact@v2 - with: - name: ${{ env.ARTIFACT_NAME }} - path: build - - name: Set env - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - name: Upload Release Assets - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release upload ${{ env.RELEASE_VERSION }} build/${{ env.ARTIFACT_NAME }}.tar.gz build/${{ env.ARTIFACT_NAME }}.tar.gz.sha512sum diff --git a/.github/workflows/release-shell-pkg.yaml b/.github/workflows/release-shell-pkg.yaml index 6ed0543e9d5..12e50b6ef20 100644 --- a/.github/workflows/release-shell-pkg.yaml +++ b/.github/workflows/release-shell-pkg.yaml @@ -17,15 +17,9 @@ jobs: fetch-depth: 0 persist-credentials: false -<<<<<<< HEAD - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' -======= - - uses: actions/setup-node@v3 - with: - node-version: '16.x' ->>>>>>> b7384b5fad (Revert "script adjustment/fix") - name: Validate Plugin build system run: ./shell/scripts/test-plugins-build.sh @@ -41,15 +35,9 @@ jobs: echo $YARN_REGISTRY cat ./shell/package.json -<<<<<<< HEAD - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' -======= - - uses: actions/setup-node@v3 - with: - node-version: '16.x' ->>>>>>> b7384b5fad (Revert "script adjustment/fix") registry-url: 'https://registry.npmjs.org' scope: '@rancher' diff --git a/.github/workflows/storybook.yaml b/.github/workflows/storybook.yaml index ab1029a1fd7..dcbef3c778a 100644 --- a/.github/workflows/storybook.yaml +++ b/.github/workflows/storybook.yaml @@ -1,7 +1,3 @@ -<<<<<<< HEAD -<<<<<<< HEAD -======= ->>>>>>> 25d6584234 (comment workflows) name: storybook env: STORYBOOK_TOKEN: ${{ secrets.STORYBOOK_TOKEN }} @@ -9,15 +5,9 @@ on: push: branches: - master -<<<<<<< HEAD - pull_request: - branches: - - master -======= # pull_request: # branches: # - master ->>>>>>> 25d6584234 (comment workflows) jobs: storybook: runs-on: ubuntu-latest @@ -26,15 +16,7 @@ jobs: - name: Use Node.js uses: actions/setup-node@v4 with: -<<<<<<< HEAD -<<<<<<< HEAD node-version-file: '.nvmrc' -======= - node-version: '16.20.2' ->>>>>>> b7384b5fad (Revert "script adjustment/fix") -======= - node-version: '16.20.2' ->>>>>>> 25d6584234 (comment workflows) - name: Install packages run: yarn install - name: Build Storybook @@ -42,36 +24,4 @@ jobs: yarn build-storybook - name: Publish Storybook if: ${{ github.event_name == 'push' && github.repository_owner == 'rancher'}} - run: .github/workflows/scripts/publish-storybook -<<<<<<< HEAD -======= -# name: storybook -# env: -# STORYBOOK_TOKEN: ${{ secrets.STORYBOOK_TOKEN }} -# on: -# push: -# branches: -# - master -# pull_request: -# branches: -# - master -# jobs: -# storybook: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v4 -# - name: Use Node.js -# uses: actions/setup-node@v4 -# with: -# node-version: '16.20.2' -# - name: Install packages -# run: yarn install -# - name: Build Storybook -# run: | -# yarn build-storybook -# - name: Publish Storybook -# if: ${{ github.event_name == 'push' && github.repository_owner == 'rancher'}} -# run: .github/workflows/scripts/publish-storybook ->>>>>>> 25d643d2d3 (comment workflows) -======= ->>>>>>> 25d6584234 (comment workflows) + run: .github/workflows/scripts/publish-storybook \ No newline at end of file From 303c634ddd319afb86df87d2667e7fb2baedf92a Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Wed, 31 Jul 2024 15:15:10 +0100 Subject: [PATCH 31/46] add build of UI --- .../extensions-compatibility-tests.yaml | 40 +++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index fae0d44f037..c7bb10a55a6 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -19,15 +19,48 @@ env: # Build the dashboard to use in tests. When set to false it will grab `latest` from CDN (useful for running e2e tests quickly) BUILD_DASHBOARD: true + E2E_BUILD_DIST_NAME: dist + E2E_BUILD_DIST_DIR: dist + E2E_BUILD_DIST_EMBER_NAME: dist_ember + E2E_BUILD_DIST_EMBER_DIR: dist_ember + jobs: + e2e-ui-build: + if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: master + fetch-depth: 1 + - name: Setup env + uses: ./.github/actions/setup + - name: Build e2e + run: yarn e2e:build + - name: Upload e2e build + uses: actions/upload-artifact@v4 + with: + name: ${{ env.E2E_BUILD_DIST_NAME }} + path: ${{ env.E2E_BUILD_DIST_DIR }}/ + if-no-files-found: error + retention-days: 10 + compression-level: 9 + - name: Upload e2e build ember + uses: actions/upload-artifact@v4 + with: + name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} + path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }}/ + if-no-files-found: error + retention-days: 10 + compression-level: 9 e2e-test-extensions-compatibility: if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" + needs: e2e-ui-build strategy: fail-fast: false matrix: role: [ - { username: 'admin', tag: '@adminUser' }, - # { username: 'standard_user', tag: '@standardUser' } + { username: 'admin', tag: '@adminUser' } ] features: [ ['@elemental'], @@ -35,8 +68,7 @@ jobs: # ['@neuvector'] ] rancherEnv: [ - ['v2.9-head', 'master'], - # ['v2.8-head', 'release-2.8'] + ['v2.9-head', 'master'] ] runs-on: ubuntu-latest steps: From 7978f02e344b4e25ed5360bf26e9b433f10669fc Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Wed, 31 Jul 2024 16:11:13 +0100 Subject: [PATCH 32/46] adjust branch for 2.9 --- .github/workflows/extensions-compatibility-tests.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index c7bb10a55a6..f8c43e662e6 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -5,7 +5,7 @@ on: # TODO: DELETE THIS!!!! JUST FOR TESTING PURPOSES! pull_request: branches: - - master + - release-2.9 env: TEST_USERNAME: admin @@ -31,7 +31,7 @@ jobs: steps: - uses: actions/checkout@v3 with: - ref: master + ref: release-2.9 fetch-depth: 1 - name: Setup env uses: ./.github/actions/setup @@ -68,7 +68,7 @@ jobs: # ['@neuvector'] ] rancherEnv: [ - ['v2.9-head', 'master'] + ['v2.9-head', 'release-2.9'] ] runs-on: ubuntu-latest steps: From b210e671444ed54f270f6a47514c7abf45e74733 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Wed, 31 Jul 2024 16:11:20 +0100 Subject: [PATCH 33/46] name --- .github/workflows/extensions-compatibility-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index f8c43e662e6..f87b1b5bab6 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -1,4 +1,4 @@ -name: Extensions Compatibility Tests +name: Extensions Compatibility Tests 2.9 on: schedule: - cron: "0 0 * * *" # runs at midnight every day From 5b527d5334d87969e038b20e5548518f5f912678 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Wed, 31 Jul 2024 16:15:40 +0100 Subject: [PATCH 34/46] change branch --- .github/workflows/extensions-compatibility-tests.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index f87b1b5bab6..2f3a6cd6b02 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -5,7 +5,7 @@ on: # TODO: DELETE THIS!!!! JUST FOR TESTING PURPOSES! pull_request: branches: - - release-2.9 + - master env: TEST_USERNAME: admin @@ -31,7 +31,7 @@ jobs: steps: - uses: actions/checkout@v3 with: - ref: release-2.9 + ref: master fetch-depth: 1 - name: Setup env uses: ./.github/actions/setup @@ -68,7 +68,7 @@ jobs: # ['@neuvector'] ] rancherEnv: [ - ['v2.9-head', 'release-2.9'] + ['v2.9-head', 'master'] ] runs-on: ubuntu-latest steps: From bb468a3bd2120bf92c94c4bd4064dfa4631b7165 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 1 Aug 2024 10:23:29 +0100 Subject: [PATCH 35/46] echo on e2e-docker-start --- scripts/e2e-docker-start | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/e2e-docker-start b/scripts/e2e-docker-start index 21a03a07bef..55e65956dea 100755 --- a/scripts/e2e-docker-start +++ b/scripts/e2e-docker-start @@ -16,6 +16,9 @@ if [ $# -eq 1 ]; then HAS_ARGS="true" fi +echo "HAS_ARGS: ${HAS_ARGS}" +echo "RANCHER_IMG_VERSION: ${RANCHER_IMG_VERSION}" + if [ "$HAS_ARGS" == "false" ]; then # this flow is what test.yaml is expected to to be following echo "normal flow without args. Defaults to v2.9-head" From 008e72757c0264d1aad930903911600102dfc675 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 1 Aug 2024 10:40:30 +0100 Subject: [PATCH 36/46] another test run --- .../extensions-compatibility-tests.yaml | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index 2f3a6cd6b02..d96484ff7b2 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -19,43 +19,43 @@ env: # Build the dashboard to use in tests. When set to false it will grab `latest` from CDN (useful for running e2e tests quickly) BUILD_DASHBOARD: true - E2E_BUILD_DIST_NAME: dist - E2E_BUILD_DIST_DIR: dist - E2E_BUILD_DIST_EMBER_NAME: dist_ember - E2E_BUILD_DIST_EMBER_DIR: dist_ember + # E2E_BUILD_DIST_NAME: dist + # E2E_BUILD_DIST_DIR: dist + # E2E_BUILD_DIST_EMBER_NAME: dist_ember + # E2E_BUILD_DIST_EMBER_DIR: dist_ember jobs: - e2e-ui-build: - if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - ref: master - fetch-depth: 1 - - name: Setup env - uses: ./.github/actions/setup - - name: Build e2e - run: yarn e2e:build - - name: Upload e2e build - uses: actions/upload-artifact@v4 - with: - name: ${{ env.E2E_BUILD_DIST_NAME }} - path: ${{ env.E2E_BUILD_DIST_DIR }}/ - if-no-files-found: error - retention-days: 10 - compression-level: 9 - - name: Upload e2e build ember - uses: actions/upload-artifact@v4 - with: - name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} - path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }}/ - if-no-files-found: error - retention-days: 10 - compression-level: 9 + # e2e-ui-build: + # if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + # with: + # ref: master + # fetch-depth: 1 + # - name: Setup env + # uses: ./.github/actions/setup + # - name: Build e2e + # run: yarn e2e:build + # - name: Upload e2e build + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ env.E2E_BUILD_DIST_NAME }} + # path: ${{ env.E2E_BUILD_DIST_DIR }}/ + # if-no-files-found: error + # retention-days: 10 + # compression-level: 9 + # - name: Upload e2e build ember + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} + # path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }} + # if-no-files-found: error + # retention-days: 10 + # compression-level: 9 e2e-test-extensions-compatibility: - if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" - needs: e2e-ui-build + # if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" + # needs: e2e-ui-build strategy: fail-fast: false matrix: @@ -74,7 +74,7 @@ jobs: steps: - uses: actions/checkout@v3 with: - ref: ${{ matrix.rancherEnv[1] }} + # ref: ${{ matrix.rancherEnv[1] }} TODO: should be removed after it get's merged fetch-depth: 1 - name: Setup env uses: ./.github/actions/setup From 594fe5bae609cb98f255f38da707b8a9b515385f Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Fri, 2 Aug 2024 12:16:17 +0100 Subject: [PATCH 37/46] finalized workflow + remove echos from e2e-docker-start + working on elemental spec --- .../extensions-compatibility-tests.yaml | 37 +-------------- .../e2e/po/components/labeled-select.po.ts | 6 +++ .../elemental.po.ts | 16 +++++++ .../extensions-compatibility.po.ts | 45 +++++++++++++++++++ cypress/e2e/po/pages/extensions.po.ts | 12 ++++- .../elemental.spec.ts | 42 +++++++++++------ scripts/e2e-docker-start | 3 -- 7 files changed, 107 insertions(+), 54 deletions(-) create mode 100644 cypress/e2e/po/pages/extensions-compatibility-tests/elemental.po.ts create mode 100644 cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index d96484ff7b2..d24824406e1 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -1,4 +1,4 @@ -name: Extensions Compatibility Tests 2.9 +name: Extensions Compatibility Tests 2.10 on: schedule: - cron: "0 0 * * *" # runs at midnight every day @@ -19,43 +19,8 @@ env: # Build the dashboard to use in tests. When set to false it will grab `latest` from CDN (useful for running e2e tests quickly) BUILD_DASHBOARD: true - # E2E_BUILD_DIST_NAME: dist - # E2E_BUILD_DIST_DIR: dist - # E2E_BUILD_DIST_EMBER_NAME: dist_ember - # E2E_BUILD_DIST_EMBER_DIR: dist_ember - jobs: - # e2e-ui-build: - # if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - # with: - # ref: master - # fetch-depth: 1 - # - name: Setup env - # uses: ./.github/actions/setup - # - name: Build e2e - # run: yarn e2e:build - # - name: Upload e2e build - # uses: actions/upload-artifact@v4 - # with: - # name: ${{ env.E2E_BUILD_DIST_NAME }} - # path: ${{ env.E2E_BUILD_DIST_DIR }}/ - # if-no-files-found: error - # retention-days: 10 - # compression-level: 9 - # - name: Upload e2e build ember - # uses: actions/upload-artifact@v4 - # with: - # name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} - # path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }} - # if-no-files-found: error - # retention-days: 10 - # compression-level: 9 e2e-test-extensions-compatibility: - # if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" - # needs: e2e-ui-build strategy: fail-fast: false matrix: diff --git a/cypress/e2e/po/components/labeled-select.po.ts b/cypress/e2e/po/components/labeled-select.po.ts index ea49ed1eaed..57e4c70e76c 100644 --- a/cypress/e2e/po/components/labeled-select.po.ts +++ b/cypress/e2e/po/components/labeled-select.po.ts @@ -5,6 +5,12 @@ export default class LabeledSelectPo extends ComponentPo { return this.self().click(); } + setOptionAndClick(label: string) { + this.self().get('input[type="search"]').type(label); + + return this.clickOption(1); + } + clickOption(optionIndex: number) { return this.self().get(`.vs__dropdown-menu .vs__dropdown-option:nth-child(${ optionIndex })`).click(); } diff --git a/cypress/e2e/po/pages/extensions-compatibility-tests/elemental.po.ts b/cypress/e2e/po/pages/extensions-compatibility-tests/elemental.po.ts new file mode 100644 index 00000000000..688153415e3 --- /dev/null +++ b/cypress/e2e/po/pages/extensions-compatibility-tests/elemental.po.ts @@ -0,0 +1,16 @@ +import ExtensionsCompatibiliyPo from '@/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po'; + +export default class ElementalPo extends ExtensionsCompatibiliyPo { + static url = '/elemental/c/_/dashboard'; + static goTo(): Cypress.Chainable { + return super.goTo(ElementalPo.url); + } + + constructor(url: string) { + super(ElementalPo.url); + } + + installOperatorBtnClick(): Cypress.Chainable { + return this.self().getId('charts-install-button').click(); + } +} diff --git a/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts b/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts new file mode 100644 index 00000000000..34044306cea --- /dev/null +++ b/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts @@ -0,0 +1,45 @@ +import PagePo from '@/cypress/e2e/po/pages/page.po'; +import { InstallChartPage } from '@/cypress/e2e/po/pages/explorer/charts/install-charts.po'; +import Kubectl from '@/cypress/e2e/po/components/kubectl.po'; +import ChartInstalledAppsPagePo from '@/cypress/e2e/po/pages/chart-installed-apps.po'; + +const installChart = new InstallChartPage(); +const terminal = new Kubectl(); +const installedApps = new ChartInstalledAppsPagePo(); + +export default class ExtensionsCompatibiliyPo extends PagePo { + title(selector: string): Cypress.Chainable { + return this.self().find(selector).invoke('text'); + } + + waitForTitle(selector: string, title: string) { + return this.title(selector).should('contain', title); + } + + waitForInstallChartPage() { + return installChart.waitForChartPage('rancher-charts', 'elemental'); + } + + chartInstallNext() { + return installChart.nextPage(); + } + + chartInstallClick() { + return installChart.installChart(); + } + + chartInstallWaitForInstallationAndCloseTerminal(interceptName: string) { + cy.wait(`@${ interceptName }`, { requestTimeout: 15000 }).its('response.statusCode').should('eq', 201); + + // giving it a small buffer so that the install is properly triggered + cy.wait(3000); + terminal.closeTerminal(); + + installedApps.list().state('elemental-operator-crds').should('contain', 'Deployed'); + installedApps.list().state('elemental-operator').should('contain', 'Deployed'); + + // timeout to give time for everything to be setup, otherwise the extension + // won't find the chart and show the correct screen + return cy.wait(5000); + } +} diff --git a/cypress/e2e/po/pages/extensions.po.ts b/cypress/e2e/po/pages/extensions.po.ts index 47188cb17c9..97d05c1f2e8 100644 --- a/cypress/e2e/po/pages/extensions.po.ts +++ b/cypress/e2e/po/pages/extensions.po.ts @@ -91,13 +91,15 @@ export default class ExtensionsPagePo extends PagePo { * @param name - A name for the repository * @returns {Cypress.Chainable} */ - addExtensionsRepositoryNew(repo: string, branch: string, name: string, waitForActiveState = true): Cypress.Chainable { + addExtensionsRepositoryDirectLink(repo: string, branch: string, name: string, waitForActiveState = true): Cypress.Chainable { const appRepoList = new RepositoriesPagePo('local', 'apps'); const appRepoCreate = new AppClusterRepoEditPo('local', 'create'); appRepoCreate.goTo(); appRepoCreate.waitForPage(); + appRepoCreate.nameNsDescription().name().self().scrollIntoView() + .should('be.visible'); appRepoCreate.nameNsDescription().name().set(name); appRepoCreate.selectRadioOptionGitRepo(1); // fill the git repo form @@ -141,6 +143,14 @@ export default class ExtensionsPagePo extends PagePo { return this.self().get('[data-modal="installPluginDialog"]'); } + installModalSelectVersionLabel(label: string): Cypress.Chainable { + const selectVersion = new LabeledSelectPo(this.extensionInstallModal().getId('install-ext-modal-select-version')); + + selectVersion.toggle(); + + return selectVersion.setOptionAndClick(label); + } + installModalSelectVersionClick(optionIndex: number): Cypress.Chainable { const selectVersion = new LabeledSelectPo(this.extensionInstallModal().getId('install-ext-modal-select-version')); diff --git a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts index 48c3566f610..be23fd7ac70 100644 --- a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts +++ b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts @@ -1,31 +1,28 @@ import ExtensionsPagePo from '@/cypress/e2e/po/pages/extensions.po'; +import ElementalPo from '@/cypress/e2e/po/pages/extensions-compatibility-tests/elemental.po'; import HomePagePo from '@/cypress/e2e/po/pages/home.po'; import AboutPagePo from '@/cypress/e2e/po/pages/about.po'; const EXTENSION_NAME = 'elemental'; +const EXTENSION_VERSION = '1.3.1-rc7'; +const EXTENSION_REPO = 'https://github.com/rancher/elemental-ui'; +const EXTENSION_BRANCH = 'gh-pages'; +const EXTENSION_CLUSTER_REPO_NAME = 'elemental-ui-extension'; +const EXTENSION_CHART_CREATION = 'chartCreation'; + +const elementalPo = new ElementalPo(); describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] }, () => { beforeEach(() => { cy.login(); }); - it('add main extensions repository', () => { + it('add extension repository', () => { // // This should be in a `before` however is flaky. Move it to an `it` to let cypress retry const extensionsPo = new ExtensionsPagePo(); - extensionsPo.addExtensionsRepositoryNew('https://github.com/rancher/ui-plugin-charts', 'main', 'rancher-extensions'); - }); - - // TODO: TO REMOVE ONCE EVERYTHING IS GOOD! - it('can navigate to About page (get version from about page screenshots to make sure we are on the right system)', () => { - const aboutPage = new AboutPagePo(); - - HomePagePo.goToAndWaitForGet(); - AboutPagePo.navTo(); - aboutPage.waitForPage(); - cy.wait(5000); // eslint-disable-line cypress/no-unnecessary-waiting - // just enough to render the page on sorry-cypress so that we can check the version + extensionsPo.addExtensionsRepositoryDirectLink(EXTENSION_REPO, EXTENSION_BRANCH, EXTENSION_CLUSTER_REPO_NAME, false); }); it('Should install an extension', () => { @@ -40,7 +37,7 @@ describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] } extensionsPo.extensionInstallModal().should('be.visible'); // select version and click install - extensionsPo.installModalSelectVersionClick(2); + extensionsPo.installModalSelectVersionLabel(EXTENSION_VERSION); extensionsPo.installModalInstallClick(); // let's check the extension reload banner and reload the page @@ -53,4 +50,21 @@ describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] } extensionsPo.extensionDetailsTitle().should('contain', EXTENSION_NAME); extensionsPo.extensionDetailsCloseClick(); }); + + it('Should setup all of the needed backend parts', () => { + cy.intercept('POST', 'v1/catalog.cattle.io.clusterrepos/rancher-charts?action=install').as(EXTENSION_CHART_CREATION); + + elementalPo.goTo(); + elementalPo.waitForTitle('h1', 'OS Management'); + + elementalPo.installOperatorBtnClick(); + + elementalPo.waitForInstallChartPage(); + elementalPo.chartInstallNext(); + elementalPo.chartInstallClick(); + elementalPo.chartInstallWaitForInstallationAndCloseTerminal(EXTENSION_CHART_CREATION); + + elementalPo.goTo(); + elementalPo.waitForTitle('[data-testid="elemental-main-title"]', 'OS Management Dashboard'); + }); }); diff --git a/scripts/e2e-docker-start b/scripts/e2e-docker-start index 55e65956dea..21a03a07bef 100755 --- a/scripts/e2e-docker-start +++ b/scripts/e2e-docker-start @@ -16,9 +16,6 @@ if [ $# -eq 1 ]; then HAS_ARGS="true" fi -echo "HAS_ARGS: ${HAS_ARGS}" -echo "RANCHER_IMG_VERSION: ${RANCHER_IMG_VERSION}" - if [ "$HAS_ARGS" == "false" ]; then # this flow is what test.yaml is expected to to be following echo "normal flow without args. Defaults to v2.9-head" From 04138754d0f105a9a767214be8246d7b0469c82d Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Fri, 2 Aug 2024 13:38:14 +0100 Subject: [PATCH 38/46] continue work on elemental spec --- .../elemental.po.ts | 2 +- .../extensions-compatibility.po.ts | 26 +++++++++++++++ .../elemental.spec.ts | 33 +++++++++++++++++-- 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/po/pages/extensions-compatibility-tests/elemental.po.ts b/cypress/e2e/po/pages/extensions-compatibility-tests/elemental.po.ts index 688153415e3..e3722cb1f5f 100644 --- a/cypress/e2e/po/pages/extensions-compatibility-tests/elemental.po.ts +++ b/cypress/e2e/po/pages/extensions-compatibility-tests/elemental.po.ts @@ -6,7 +6,7 @@ export default class ElementalPo extends ExtensionsCompatibiliyPo { return super.goTo(ElementalPo.url); } - constructor(url: string) { + constructor() { super(ElementalPo.url); } diff --git a/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts b/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts index 34044306cea..20ab8dda63a 100644 --- a/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts +++ b/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts @@ -2,6 +2,10 @@ import PagePo from '@/cypress/e2e/po/pages/page.po'; import { InstallChartPage } from '@/cypress/e2e/po/pages/explorer/charts/install-charts.po'; import Kubectl from '@/cypress/e2e/po/components/kubectl.po'; import ChartInstalledAppsPagePo from '@/cypress/e2e/po/pages/chart-installed-apps.po'; +import ProductNavPo from '@/cypress/e2e/po/side-bars/product-side-nav.po'; +import BaseResourceList from '@/cypress/e2e/po/lists/base-resource-list.po'; +import CodeMirrorPo from '@/cypress/e2e/po/components/code-mirror.po'; +import AsyncButtonPo from '@/cypress/e2e/po/components/async-button.po'; const installChart = new InstallChartPage(); const terminal = new Kubectl(); @@ -42,4 +46,26 @@ export default class ExtensionsCompatibiliyPo extends PagePo { // won't find the chart and show the correct screen return cy.wait(5000); } + + sideMenuNavTo(label: string) { + const sideNav = new ProductNavPo(); + + sideNav.navToSideMenuEntryByLabel(label); + } + + genericListView(): BaseResourceList { + return new BaseResourceList(this.self()); + } + + createFromYamlClick(): Cypress.Chainable { + return this.genericListView().masthead().createYaml(); + } + + genericYamlEditor(): CodeMirrorPo { + return CodeMirrorPo.bySelector(this.self(), '[data-testid="yaml-editor-code-mirror"]'); + } + + saveEditYamlForm(): AsyncButtonPo { + return new AsyncButtonPo('[data-testid="action-button-async-button"]', this.self()); + } } diff --git a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts index be23fd7ac70..69c7d98d7d7 100644 --- a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts +++ b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts @@ -1,8 +1,7 @@ import ExtensionsPagePo from '@/cypress/e2e/po/pages/extensions.po'; import ElementalPo from '@/cypress/e2e/po/pages/extensions-compatibility-tests/elemental.po'; - -import HomePagePo from '@/cypress/e2e/po/pages/home.po'; -import AboutPagePo from '@/cypress/e2e/po/pages/about.po'; +import { NamespaceFilterPo } from '@/cypress/e2e/po/components/namespace-filter.po'; +import * as jsyaml from 'js-yaml'; const EXTENSION_NAME = 'elemental'; const EXTENSION_VERSION = '1.3.1-rc7'; @@ -11,7 +10,10 @@ const EXTENSION_BRANCH = 'gh-pages'; const EXTENSION_CLUSTER_REPO_NAME = 'elemental-ui-extension'; const EXTENSION_CHART_CREATION = 'chartCreation'; +const MACHINE_INV_NAME = 'machine-inventory-1'; + const elementalPo = new ElementalPo(); +const namespacePicker = new NamespaceFilterPo(); describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] }, () => { beforeEach(() => { @@ -60,6 +62,12 @@ describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] } elementalPo.installOperatorBtnClick(); elementalPo.waitForInstallChartPage(); + + // we need to change the namespace picker in order for the install check on the list view + namespacePicker.toggle(); + namespacePicker.clickOptionByLabel('All Namespaces'); + namespacePicker.closeDropdown(); + elementalPo.chartInstallNext(); elementalPo.chartInstallClick(); elementalPo.chartInstallWaitForInstallationAndCloseTerminal(EXTENSION_CHART_CREATION); @@ -67,4 +75,23 @@ describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] } elementalPo.goTo(); elementalPo.waitForTitle('[data-testid="elemental-main-title"]', 'OS Management Dashboard'); }); + + it('Should create an Elemental resource via YAML (Inventory of Machines)', () => { + elementalPo.goTo(); + elementalPo.sideMenuNavTo('Inventory of Machines'); + elementalPo.createFromYamlClick(); + + elementalPo.genericYamlEditor().value().then((val) => { + // convert yaml into json to update values + const json: any = jsyaml.load(val); + + json.metadata.name = MACHINE_INV_NAME; + + elementalPo.genericYamlEditor().set(jsyaml.dump(json)); + elementalPo.saveEditYamlForm().click(); + + elementalPo.waitForPageWithSpecificUrl('/elemental/c/_/elemental.cattle.io.machineinventory'); + elementalPo.genericListView().rowWithName(MACHINE_INV_NAME).column(2).should('contain', MACHINE_INV_NAME); + }); + }); }); From ee07186119f887b9b35581a73e24536fc939cd0f Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 8 Aug 2024 11:16:19 +0100 Subject: [PATCH 39/46] finished elemental spec --- .../elemental.po.ts | 24 ++++- .../extensions-compatibility.po.ts | 25 ++++- .../elemental.spec.ts | 98 ++++++++++++++++++- 3 files changed, 143 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/po/pages/extensions-compatibility-tests/elemental.po.ts b/cypress/e2e/po/pages/extensions-compatibility-tests/elemental.po.ts index e3722cb1f5f..f96c249fd88 100644 --- a/cypress/e2e/po/pages/extensions-compatibility-tests/elemental.po.ts +++ b/cypress/e2e/po/pages/extensions-compatibility-tests/elemental.po.ts @@ -1,5 +1,7 @@ import ExtensionsCompatibiliyPo from '@/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po'; - +import BannersPo from '@/cypress/e2e/po/components/banners.po'; +import LabeledSelectPo from '@/cypress/e2e/po/components/labeled-select.po'; +import RadioGroupInputPo from '@/cypress/e2e/po/components/radio-group-input.po'; export default class ElementalPo extends ExtensionsCompatibiliyPo { static url = '/elemental/c/_/dashboard'; static goTo(): Cypress.Chainable { @@ -13,4 +15,24 @@ export default class ElementalPo extends ExtensionsCompatibiliyPo { installOperatorBtnClick(): Cypress.Chainable { return this.self().getId('charts-install-button').click(); } + + dashboardCreateElementalClusterClick() { + return this.self().getId('button-create-elemental-cluster').click(); + } + + dashboardCreateUpdateGroupClick() { + return this.self().getId('create-update-group-btn').click(); + } + + elementalClusterSelectorTemplateBanner() { + return new BannersPo('[provider="machineinventoryselectortemplate"] .banner.warning'); + } + + updateGroupTargetClustersSelect() { + return new LabeledSelectPo('[data-testid="cluster-target"]'); + } + + updateGroupImageOption() { + return new RadioGroupInputPo('[data-testid="upgrade-choice-selector"]'); + } } diff --git a/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts b/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts index 20ab8dda63a..f3d10df8a11 100644 --- a/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts +++ b/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts @@ -6,6 +6,7 @@ import ProductNavPo from '@/cypress/e2e/po/side-bars/product-side-nav.po'; import BaseResourceList from '@/cypress/e2e/po/lists/base-resource-list.po'; import CodeMirrorPo from '@/cypress/e2e/po/components/code-mirror.po'; import AsyncButtonPo from '@/cypress/e2e/po/components/async-button.po'; +import LabeledInputPo from '@/cypress/e2e/po/components/labeled-input.po'; const installChart = new InstallChartPage(); const terminal = new Kubectl(); @@ -33,10 +34,10 @@ export default class ExtensionsCompatibiliyPo extends PagePo { } chartInstallWaitForInstallationAndCloseTerminal(interceptName: string) { - cy.wait(`@${ interceptName }`, { requestTimeout: 15000 }).its('response.statusCode').should('eq', 201); + cy.wait(`@${ interceptName }`, { requestTimeout: 20000 }).its('response.statusCode').should('eq', 201); // giving it a small buffer so that the install is properly triggered - cy.wait(3000); + cy.wait(15000); terminal.closeTerminal(); installedApps.list().state('elemental-operator-crds').should('contain', 'Deployed'); @@ -61,6 +62,18 @@ export default class ExtensionsCompatibiliyPo extends PagePo { return this.genericListView().masthead().createYaml(); } + createClick(): Cypress.Chainable { + return this.genericListView().masthead().create(); + } + + genericNameInput() { + return LabeledInputPo.bySelector(this.self(), '[data-testid="name-ns-description-name"]'); + } + + genericLabeledInputByLabel(label:string): LabeledInputPo { + return LabeledInputPo.byLabel(this.self(), label); + } + genericYamlEditor(): CodeMirrorPo { return CodeMirrorPo.bySelector(this.self(), '[data-testid="yaml-editor-code-mirror"]'); } @@ -68,4 +81,12 @@ export default class ExtensionsCompatibiliyPo extends PagePo { saveEditYamlForm(): AsyncButtonPo { return new AsyncButtonPo('[data-testid="action-button-async-button"]', this.self()); } + + saveOrCreateResource(): AsyncButtonPo { + return new AsyncButtonPo('[data-testid="form-save"]', this.self()); + } + + saveOrCreateCluster(): AsyncButtonPo { + return new AsyncButtonPo('[data-testid="rke2-custom-create-save"]', this.self()); + } } diff --git a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts index 69c7d98d7d7..430422972d5 100644 --- a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts +++ b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts @@ -4,14 +4,24 @@ import { NamespaceFilterPo } from '@/cypress/e2e/po/components/namespace-filter. import * as jsyaml from 'js-yaml'; const EXTENSION_NAME = 'elemental'; -const EXTENSION_VERSION = '1.3.1-rc7'; +const EXTENSION_VERSION = '2.0.0-rc1'; const EXTENSION_REPO = 'https://github.com/rancher/elemental-ui'; const EXTENSION_BRANCH = 'gh-pages'; const EXTENSION_CLUSTER_REPO_NAME = 'elemental-ui-extension'; const EXTENSION_CHART_CREATION = 'chartCreation'; +const REG_ENDPOINT_NAME = 'reg-endpoint-1'; +const REG_ENDPOINT_DEVICE_PATH = '/dev/nvme0n123'; + const MACHINE_INV_NAME = 'machine-inventory-1'; +const ELEMENTAL_CLUSTER_NAME = 'elemental-cluster-1'; +const ELEMENTAL_CLUSTER_BANNER_TEXT = 'Matches all 1 existing Inventory of Machines'; +const ELEMENTAL_CLUSTER_MACHINE_CONFIG_REF = 'MachineInventorySelectorTemplate'; + +const UPDATE_GROUP_NAME = 'update-group-1'; +const UPDATE_GROUP_IMAGE_PATH = 'some/path'; + const elementalPo = new ElementalPo(); const namespacePicker = new NamespaceFilterPo(); @@ -76,6 +86,31 @@ describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] } elementalPo.waitForTitle('[data-testid="elemental-main-title"]', 'OS Management Dashboard'); }); + it('Should create an Elemental registration endpoint', () => { + cy.intercept('POST', 'v1/elemental.cattle.io.machineregistrations/fleet-default').as('machineRegCreation'); + + elementalPo.goTo(); + elementalPo.sideMenuNavTo('Registration Endpoints'); + elementalPo.createClick(); + + elementalPo.genericNameInput().set(REG_ENDPOINT_NAME); + elementalPo.genericYamlEditor().value().then((val) => { + // convert yaml into json to update values + const json: any = jsyaml.load(val); + + json.config.elemental.install.device = REG_ENDPOINT_DEVICE_PATH; + + elementalPo.genericYamlEditor().set(jsyaml.dump(json)); + elementalPo.saveOrCreateResource().click(); + + cy.wait('@machineRegCreation', { requestTimeout: 15000 }).then(({ response }) => { + expect(response?.statusCode).to.eq(201); + expect(response?.body.metadata).to.have.property('name', REG_ENDPOINT_NAME); + expect(response?.body.spec.config.elemental.install).to.have.property('device', REG_ENDPOINT_DEVICE_PATH); + }); + }); + }); + it('Should create an Elemental resource via YAML (Inventory of Machines)', () => { elementalPo.goTo(); elementalPo.sideMenuNavTo('Inventory of Machines'); @@ -94,4 +129,65 @@ describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] } elementalPo.genericListView().rowWithName(MACHINE_INV_NAME).column(2).should('contain', MACHINE_INV_NAME); }); }); + + it('Should create an Elemental cluster, targeting all of the inventory of machines', () => { + cy.intercept('POST', 'v1/provisioning.cattle.io.clusters').as('elementalClusterCreation'); + + elementalPo.goTo(); + elementalPo.dashboardCreateElementalClusterClick(); + + elementalPo.genericNameInput().set(ELEMENTAL_CLUSTER_NAME); + elementalPo.elementalClusterSelectorTemplateBanner().banner().contains(ELEMENTAL_CLUSTER_BANNER_TEXT); + elementalPo.saveOrCreateCluster().click(); + + cy.wait('@elementalClusterCreation', { requestTimeout: 15000 }).then(({ response }) => { + expect(response?.statusCode).to.eq(201); + expect(response?.body.metadata).to.have.property('name', ELEMENTAL_CLUSTER_NAME); + expect(response?.body.spec.rkeConfig.machinePools[0].machineConfigRef).to.have.property('kind', ELEMENTAL_CLUSTER_MACHINE_CONFIG_REF); + }); + }); + + it('Should create an Upgrade Group', () => { + cy.intercept('POST', 'v1/elemental.cattle.io.managedosimages').as('elementalUpdateGroupCreation'); + + elementalPo.goTo(); + elementalPo.dashboardCreateUpdateGroupClick(); + + elementalPo.genericNameInput().set(UPDATE_GROUP_NAME); + elementalPo.updateGroupTargetClustersSelect().toggle(); + elementalPo.updateGroupTargetClustersSelect().clickOptionWithLabel(ELEMENTAL_CLUSTER_NAME); + elementalPo.updateGroupImageOption().set(1); + + elementalPo.genericLabeledInputByLabel('Image path').set(UPDATE_GROUP_IMAGE_PATH); + elementalPo.saveOrCreateResource().click(); + + cy.wait('@elementalUpdateGroupCreation', { requestTimeout: 15000 }).then(({ response }) => { + expect(response?.statusCode).to.eq(201); + expect(response?.body.metadata).to.have.property('name', UPDATE_GROUP_NAME); + expect(response?.body.spec.clusterTargets[0]).to.have.property('clusterName', ELEMENTAL_CLUSTER_NAME); + expect(response?.body.spec).to.have.property('osImage', UPDATE_GROUP_IMAGE_PATH); + }); + }); + + it('Should uninstall the extension', () => { + const extensionsPo = new ExtensionsPagePo(); + + extensionsPo.goTo(); + extensionsPo.extensionTabInstalledClick(); + + // click on uninstall button on card + extensionsPo.extensionCardUninstallClick(EXTENSION_NAME); + extensionsPo.extensionUninstallModal().should('be.visible'); + extensionsPo.uninstallModaluninstallClick(); + extensionsPo.extensionReloadBanner().should('be.visible'); + + // let's check the extension reload banner and reload the page + extensionsPo.extensionReloadBanner().should('be.visible'); + extensionsPo.extensionReloadClick(); + + // make sure extension card is in the available tab + extensionsPo.extensionTabAvailableClick(); + extensionsPo.extensionCardClick(EXTENSION_NAME); + extensionsPo.extensionDetailsTitle().should('contain', EXTENSION_NAME); + }); }); From 99747700987f4d5aac780da7742de434745178a7 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 8 Aug 2024 14:25:34 +0100 Subject: [PATCH 40/46] final test elemental spec --- .../extensions-compatibility-tests.yaml | 10 ++++------ .../extensions-compatibility.po.ts | 2 +- .../elemental.spec.ts | 19 +++++++++++++++++-- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index d24824406e1..195f5dc0ad0 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -28,9 +28,7 @@ jobs: { username: 'admin', tag: '@adminUser' } ] features: [ - ['@elemental'], - # ['@kubewarden'], - # ['@neuvector'] + ['@elemental', 'elemental'] ] rancherEnv: [ ['v2.9-head', 'master'] @@ -53,18 +51,18 @@ jobs: run: | yarn e2e:prod env: - GREP_TAGS: ${{ matrix.role.tag }}Setup+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}Setup+${{ matrix.features[1] || matrix.features[0] }} --@jenkins + GREP_TAGS: ${{ matrix.role.tag }}Setup+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}Setup+${{ matrix.features[0] }} --@jenkins TEST_USERNAME: ${{ matrix.role.username }} TEST_ONLY: setup # This is the actual triggering of the e2e test specs - name: Run user tests run: | - export SPEC_FILE="cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts" && yarn e2e:prod + export SPEC_FILE="cypress/e2e/tests/pages/extensions-compatibility-tests/${{ matrix.features[1] }}.spec.ts" && yarn e2e:prod [ "$BUILD_DASHBOARD" != "false" ] || exit 0 env: TEST_SKIP: setup - GREP_TAGS: ${{ matrix.role.tag }}+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}+${{ matrix.features[1] || matrix.features[0] }} --@jenkins + GREP_TAGS: ${{ matrix.role.tag }}+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}+${{ matrix.features[0] }} --@jenkins TEST_USERNAME: ${{ matrix.role.username }} - name: Upload screenshots diff --git a/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts b/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts index f3d10df8a11..315ce63ad39 100644 --- a/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts +++ b/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts @@ -45,7 +45,7 @@ export default class ExtensionsCompatibiliyPo extends PagePo { // timeout to give time for everything to be setup, otherwise the extension // won't find the chart and show the correct screen - return cy.wait(5000); + return cy.wait(10000); } sideMenuNavTo(label: string) { diff --git a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts index 430422972d5..a47beb76591 100644 --- a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts +++ b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts @@ -4,7 +4,7 @@ import { NamespaceFilterPo } from '@/cypress/e2e/po/components/namespace-filter. import * as jsyaml from 'js-yaml'; const EXTENSION_NAME = 'elemental'; -const EXTENSION_VERSION = '2.0.0-rc1'; +const EXTENSION_VERSION = '2.0.0-rc2'; const EXTENSION_REPO = 'https://github.com/rancher/elemental-ui'; const EXTENSION_BRANCH = 'gh-pages'; const EXTENSION_CLUSTER_REPO_NAME = 'elemental-ui-extension'; @@ -112,9 +112,24 @@ describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] } }); it('Should create an Elemental resource via YAML (Inventory of Machines)', () => { + function poolingSchemaDefinition() { + cy + .request('GET', 'v1/schemaDefinitions/elemental.cattle.io.machineinventory') + .then((resp) => { + if (resp.status === 200) { + return; + } + + cy.wait(5000); // let's wait for a bit so that we don't overload the server + poolingSchemaDefinition(); + }); + } + elementalPo.goTo(); elementalPo.sideMenuNavTo('Inventory of Machines'); - elementalPo.createFromYamlClick(); + // after we hit create from YAML we need to pool for the schemaDefinition since + // that takes while to be available https://docs.cypress.io/api/commands/request#Request-Polling + elementalPo.createFromYamlClick().then(poolingSchemaDefinition); elementalPo.genericYamlEditor().value().then((val) => { // convert yaml into json to update values From 88428777915be63416240fd70680c43977ef394c Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Thu, 8 Aug 2024 18:28:15 +0100 Subject: [PATCH 41/46] some minor adjustments to elemental spec + start work on kubewarden spec --- .../extensions-compatibility-tests.yaml | 3 +- .../extensions-compatibility.po.ts | 11 +- .../kubewarden.po.ts | 67 +++++ .../elemental.spec.ts | 10 +- .../kubewarden.spec.ts | 228 ++++++++++++++++++ cypress/e2e/tests/setup/rancher-setup.spec.ts | 2 +- 6 files changed, 311 insertions(+), 10 deletions(-) create mode 100644 cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po.ts create mode 100644 cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index 195f5dc0ad0..fbd3f8c4378 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -28,7 +28,8 @@ jobs: { username: 'admin', tag: '@adminUser' } ] features: [ - ['@elemental', 'elemental'] + ['@elemental', 'elemental'], + ['@kubewarden', 'kubewarden'] ] rancherEnv: [ ['v2.9-head', 'master'] diff --git a/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts b/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts index 315ce63ad39..459e47ef80e 100644 --- a/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts +++ b/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts @@ -21,8 +21,8 @@ export default class ExtensionsCompatibiliyPo extends PagePo { return this.title(selector).should('contain', title); } - waitForInstallChartPage() { - return installChart.waitForChartPage('rancher-charts', 'elemental'); + waitForInstallChartPage(repoName:string, chartName:string) { + return installChart.waitForChartPage(repoName, chartName); } chartInstallNext() { @@ -33,15 +33,16 @@ export default class ExtensionsCompatibiliyPo extends PagePo { return installChart.installChart(); } - chartInstallWaitForInstallationAndCloseTerminal(interceptName: string) { + chartInstallWaitForInstallationAndCloseTerminal(interceptName: string, installableParts: Array) { cy.wait(`@${ interceptName }`, { requestTimeout: 20000 }).its('response.statusCode').should('eq', 201); // giving it a small buffer so that the install is properly triggered cy.wait(15000); terminal.closeTerminal(); - installedApps.list().state('elemental-operator-crds').should('contain', 'Deployed'); - installedApps.list().state('elemental-operator').should('contain', 'Deployed'); + installableParts.forEach((item:string) => { + installedApps.list().state(item).should('contain', 'Deployed'); + }); // timeout to give time for everything to be setup, otherwise the extension // won't find the chart and show the correct screen diff --git a/cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po.ts b/cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po.ts new file mode 100644 index 00000000000..eb4aae0caea --- /dev/null +++ b/cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po.ts @@ -0,0 +1,67 @@ +import ExtensionsCompatibiliyPo from '@/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po'; +import Kubectl from '~/cypress/e2e/po/components/kubectl.po'; +import BannersPo from '@/cypress/e2e/po/components/banners.po'; +import LabeledSelectPo from '@/cypress/e2e/po/components/labeled-select.po'; +import RadioGroupInputPo from '@/cypress/e2e/po/components/radio-group-input.po'; +export default class KubewardenPo extends ExtensionsCompatibiliyPo { + static url = '/c/local/kubewarden'; + static goTo(): Cypress.Chainable { + return super.goTo(KubewardenPo.url); + } + + constructor() { + super(KubewardenPo.url); + } + + startBackendInstallClick(): Cypress.Chainable { + return this.self().getId('kw-initial-install-button').click(); + } + + openTerminalClick() { + return this.self().getId('kw-cm-open-shell').click(); + } + + kubectlShell() { + return new Kubectl(); + } + + waitForCertManagerToInstall() { + return cy.get('[data-testid="kw-repo-add-button"]', { timeout: 30000 }).invoke('text').should('contain', 'Add Kubewarden Repository'); + } + + waitForKwRepoToBeAdded() { + return cy.get('[data-testid="kw-app-install-button"]', { timeout: 30000 }).invoke('text').should('contain', 'Install Kubewarden'); + } + + addKwRepoClick() { + return this.self().getId('kw-repo-add-button').click(); + } + + installOperatorBtnClick(): Cypress.Chainable { + return this.self().getId('kw-app-install-button').click(); + } + + // installOperatorBtnClick(): Cypress.Chainable { + // return this.self().getId('charts-install-button').click(); + // } + + // dashboardCreateElementalClusterClick() { + // return this.self().getId('button-create-elemental-cluster').click(); + // } + + // dashboardCreateUpdateGroupClick() { + // return this.self().getId('create-update-group-btn').click(); + // } + + // elementalClusterSelectorTemplateBanner() { + // return new BannersPo('[provider="machineinventoryselectortemplate"] .banner.warning'); + // } + + // updateGroupTargetClustersSelect() { + // return new LabeledSelectPo('[data-testid="cluster-target"]'); + // } + + // updateGroupImageOption() { + // return new RadioGroupInputPo('[data-testid="upgrade-choice-selector"]'); + // } +} diff --git a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts index a47beb76591..11abdc6f72f 100644 --- a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts +++ b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts @@ -71,7 +71,7 @@ describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] } elementalPo.installOperatorBtnClick(); - elementalPo.waitForInstallChartPage(); + elementalPo.waitForInstallChartPage('rancher-charts', 'elemental'); // we need to change the namespace picker in order for the install check on the list view namespacePicker.toggle(); @@ -80,7 +80,7 @@ describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] } elementalPo.chartInstallNext(); elementalPo.chartInstallClick(); - elementalPo.chartInstallWaitForInstallationAndCloseTerminal(EXTENSION_CHART_CREATION); + elementalPo.chartInstallWaitForInstallationAndCloseTerminal(EXTENSION_CHART_CREATION, ['elemental-operator-crds', 'elemental-operator']); elementalPo.goTo(); elementalPo.waitForTitle('[data-testid="elemental-main-title"]', 'OS Management Dashboard'); @@ -114,7 +114,11 @@ describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] } it('Should create an Elemental resource via YAML (Inventory of Machines)', () => { function poolingSchemaDefinition() { cy - .request('GET', 'v1/schemaDefinitions/elemental.cattle.io.machineinventory') + .request({ + url: 'v1/schemaDefinitions/elemental.cattle.io.machineinventory', + method: 'GET', + failOnStatusCode: false + }) .then((resp) => { if (resp.status === 200) { return; diff --git a/cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts b/cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts new file mode 100644 index 00000000000..acabaf9b3e9 --- /dev/null +++ b/cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts @@ -0,0 +1,228 @@ +import ExtensionsPagePo from '@/cypress/e2e/po/pages/extensions.po'; +import KubewardenPo from '@/cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po'; +import { NamespaceFilterPo } from '@/cypress/e2e/po/components/namespace-filter.po'; +import * as jsyaml from 'js-yaml'; + +const EXTENSION_NAME = 'kubewarden'; +const EXTENSION_VERSION = '2.0.0'; +const EXTENSION_REPO = 'https://github.com/rancher/kubewarden-ui'; +const EXTENSION_BRANCH = 'gh-pages'; +const EXTENSION_CLUSTER_REPO_NAME = 'kubewarden-ui-extension'; +const EXTENSION_KW_REPO_ADD = 'addKwRepo'; +const EXTENSION_CHART_CREATION = 'chartCreation'; + +const REG_ENDPOINT_NAME = 'reg-endpoint-1'; +const REG_ENDPOINT_DEVICE_PATH = '/dev/nvme0n123'; + +const MACHINE_INV_NAME = 'machine-inventory-1'; + +const ELEMENTAL_CLUSTER_NAME = 'elemental-cluster-1'; +const ELEMENTAL_CLUSTER_BANNER_TEXT = 'Matches all 1 existing Inventory of Machines'; +const ELEMENTAL_CLUSTER_MACHINE_CONFIG_REF = 'MachineInventorySelectorTemplate'; + +const UPDATE_GROUP_NAME = 'update-group-1'; +const UPDATE_GROUP_IMAGE_PATH = 'some/path'; + +const kubewardenPo = new KubewardenPo(); +const namespacePicker = new NamespaceFilterPo(); + +describe('Extensions Compatibility spec', { tags: ['@kubewarden', '@adminUser'] }, () => { + beforeEach(() => { + cy.login(); + }); + + it('add extension repository', () => { + // // This should be in a `before` however is flaky. Move it to an `it` to let cypress retry + const extensionsPo = new ExtensionsPagePo(); + + extensionsPo.addExtensionsRepositoryDirectLink(EXTENSION_REPO, EXTENSION_BRANCH, EXTENSION_CLUSTER_REPO_NAME, false); + }); + + it('Should install an extension', () => { + const extensionsPo = new ExtensionsPagePo(); + + extensionsPo.goTo(); + + extensionsPo.extensionTabAvailableClick(); + + // click on install button on card + extensionsPo.extensionCardInstallClick(EXTENSION_NAME); + extensionsPo.extensionInstallModal().should('be.visible'); + + // select version and click install + extensionsPo.installModalSelectVersionLabel(EXTENSION_VERSION); + extensionsPo.installModalInstallClick(); + + // let's check the extension reload banner and reload the page + extensionsPo.extensionReloadBanner().should('be.visible'); + extensionsPo.extensionReloadClick(); + + // make sure extension card is in the installed tab + extensionsPo.extensionTabInstalledClick(); + extensionsPo.extensionCardClick(EXTENSION_NAME); + extensionsPo.extensionDetailsTitle().should('contain', EXTENSION_NAME); + extensionsPo.extensionDetailsCloseClick(); + }); + + it('Should setup all of the needed backend parts', () => { + cy.intercept('POST', 'v1/catalog.cattle.io.clusterrepos/rancher-charts?action=install').as(EXTENSION_CHART_CREATION); + + kubewardenPo.goTo(); + kubewardenPo.waitForTitle('h1', 'Kubewarden'); + + // we need to change the namespace picker in order for the install check on the list view + namespacePicker.toggle(); + namespacePicker.clickOptionByLabel('All Namespaces'); + namespacePicker.closeDropdown(); + + // start install steps + kubewardenPo.startBackendInstallClick(); + + // 1 - install cert manager + kubewardenPo.openTerminalClick(); + kubewardenPo.kubectlShell().executeCommand('apply -f https://github.com/jetstack/cert-manager/releases/latest/download/cert-manager.yaml'); + kubewardenPo.waitForCertManagerToInstall(); + kubewardenPo.kubectlShell().closeTerminal(); + + // 2 - Add kubewarden repository + kubewardenPo.addKwRepoClick(); + kubewardenPo.waitForKwRepoToBeAdded(); + + // 2 - Install kubewarden operator + kubewardenPo.installOperatorBtnClick(); + kubewardenPo.waitForInstallChartPage('kubewarden-charts', 'kubewarden-controller'); + kubewardenPo.chartInstallNext(); + + // // we need to change the namespace picker in order for the install check on the list view + // namespacePicker.toggle(); + // namespacePicker.clickOptionByLabel('All Namespaces'); + // namespacePicker.closeDropdown(); + + // kubewardenPo.chartInstallNext(); + // kubewardenPo.chartInstallClick(); + // kubewardenPo.chartInstallWaitForInstallationAndCloseTerminal(EXTENSION_CHART_CREATION); + + // kubewardenPo.goTo(); + // kubewardenPo.waitForTitle('[data-testid="elemental-main-title"]', 'OS Management Dashboard'); + }); + + // it('Should create an Elemental registration endpoint', () => { + // cy.intercept('POST', 'v1/elemental.cattle.io.machineregistrations/fleet-default').as('machineRegCreation'); + + // kubewardenPo.goTo(); + // kubewardenPo.sideMenuNavTo('Registration Endpoints'); + // kubewardenPo.createClick(); + + // kubewardenPo.genericNameInput().set(REG_ENDPOINT_NAME); + // kubewardenPo.genericYamlEditor().value().then((val) => { + // // convert yaml into json to update values + // const json: any = jsyaml.load(val); + + // json.config.elemental.install.device = REG_ENDPOINT_DEVICE_PATH; + + // kubewardenPo.genericYamlEditor().set(jsyaml.dump(json)); + // kubewardenPo.saveOrCreateResource().click(); + + // cy.wait('@machineRegCreation', { requestTimeout: 15000 }).then(({ response }) => { + // expect(response?.statusCode).to.eq(201); + // expect(response?.body.metadata).to.have.property('name', REG_ENDPOINT_NAME); + // expect(response?.body.spec.config.elemental.install).to.have.property('device', REG_ENDPOINT_DEVICE_PATH); + // }); + // }); + // }); + + // it('Should create an Elemental resource via YAML (Inventory of Machines)', () => { + // function poolingSchemaDefinition() { + // cy + // .request('GET', 'v1/schemaDefinitions/elemental.cattle.io.machineinventory') + // .then((resp) => { + // if (resp.status === 200) { + // return; + // } + + // cy.wait(5000); // let's wait for a bit so that we don't overload the server + // poolingSchemaDefinition(); + // }); + // } + + // kubewardenPo.goTo(); + // kubewardenPo.sideMenuNavTo('Inventory of Machines'); + // // after we hit create from YAML we need to pool for the schemaDefinition since + // // that takes while to be available https://docs.cypress.io/api/commands/request#Request-Polling + // kubewardenPo.createFromYamlClick().then(poolingSchemaDefinition); + + // kubewardenPo.genericYamlEditor().value().then((val) => { + // // convert yaml into json to update values + // const json: any = jsyaml.load(val); + + // json.metadata.name = MACHINE_INV_NAME; + + // kubewardenPo.genericYamlEditor().set(jsyaml.dump(json)); + // kubewardenPo.saveEditYamlForm().click(); + + // kubewardenPo.waitForPageWithSpecificUrl('/elemental/c/_/elemental.cattle.io.machineinventory'); + // kubewardenPo.genericListView().rowWithName(MACHINE_INV_NAME).column(2).should('contain', MACHINE_INV_NAME); + // }); + // }); + + // it('Should create an Elemental cluster, targeting all of the inventory of machines', () => { + // cy.intercept('POST', 'v1/provisioning.cattle.io.clusters').as('elementalClusterCreation'); + + // kubewardenPo.goTo(); + // kubewardenPo.dashboardCreateElementalClusterClick(); + + // kubewardenPo.genericNameInput().set(ELEMENTAL_CLUSTER_NAME); + // kubewardenPo.elementalClusterSelectorTemplateBanner().banner().contains(ELEMENTAL_CLUSTER_BANNER_TEXT); + // kubewardenPo.saveOrCreateCluster().click(); + + // cy.wait('@elementalClusterCreation', { requestTimeout: 15000 }).then(({ response }) => { + // expect(response?.statusCode).to.eq(201); + // expect(response?.body.metadata).to.have.property('name', ELEMENTAL_CLUSTER_NAME); + // expect(response?.body.spec.rkeConfig.machinePools[0].machineConfigRef).to.have.property('kind', ELEMENTAL_CLUSTER_MACHINE_CONFIG_REF); + // }); + // }); + + // it('Should create an Upgrade Group', () => { + // cy.intercept('POST', 'v1/elemental.cattle.io.managedosimages').as('elementalUpdateGroupCreation'); + + // kubewardenPo.goTo(); + // kubewardenPo.dashboardCreateUpdateGroupClick(); + + // kubewardenPo.genericNameInput().set(UPDATE_GROUP_NAME); + // kubewardenPo.updateGroupTargetClustersSelect().toggle(); + // kubewardenPo.updateGroupTargetClustersSelect().clickOptionWithLabel(ELEMENTAL_CLUSTER_NAME); + // kubewardenPo.updateGroupImageOption().set(1); + + // kubewardenPo.genericLabeledInputByLabel('Image path').set(UPDATE_GROUP_IMAGE_PATH); + // kubewardenPo.saveOrCreateResource().click(); + + // cy.wait('@elementalUpdateGroupCreation', { requestTimeout: 15000 }).then(({ response }) => { + // expect(response?.statusCode).to.eq(201); + // expect(response?.body.metadata).to.have.property('name', UPDATE_GROUP_NAME); + // expect(response?.body.spec.clusterTargets[0]).to.have.property('clusterName', ELEMENTAL_CLUSTER_NAME); + // expect(response?.body.spec).to.have.property('osImage', UPDATE_GROUP_IMAGE_PATH); + // }); + // }); + + // it('Should uninstall the extension', () => { + // const extensionsPo = new ExtensionsPagePo(); + + // extensionsPo.goTo(); + // extensionsPo.extensionTabInstalledClick(); + + // // click on uninstall button on card + // extensionsPo.extensionCardUninstallClick(EXTENSION_NAME); + // extensionsPo.extensionUninstallModal().should('be.visible'); + // extensionsPo.uninstallModaluninstallClick(); + // extensionsPo.extensionReloadBanner().should('be.visible'); + + // // let's check the extension reload banner and reload the page + // extensionsPo.extensionReloadBanner().should('be.visible'); + // extensionsPo.extensionReloadClick(); + + // // make sure extension card is in the available tab + // extensionsPo.extensionTabAvailableClick(); + // extensionsPo.extensionCardClick(EXTENSION_NAME); + // extensionsPo.extensionDetailsTitle().should('contain', EXTENSION_NAME); + // }); +}); diff --git a/cypress/e2e/tests/setup/rancher-setup.spec.ts b/cypress/e2e/tests/setup/rancher-setup.spec.ts index 255d74095e1..314f9d4bea6 100644 --- a/cypress/e2e/tests/setup/rancher-setup.spec.ts +++ b/cypress/e2e/tests/setup/rancher-setup.spec.ts @@ -6,7 +6,7 @@ import { serverUrlLocalhostCases, urlWithTrailingForwardSlash, httpUrl, nonUrlCa // Cypress or the GrepTags avoid to run multiples times the same test for each tag used. // This is a temporary solution till initialization is not handled as a test -describe('Rancher setup', { tags: ['@adminUserSetup', '@standardUserSetup', '@setup', '@components', '@navigation', '@charts', '@explorer', '@extensions', '@fleet', '@generic', '@globalSettings', '@manager', '@userMenu', '@usersAndAuths', '@elemental', '@vai'] }, () => { +describe('Rancher setup', { tags: ['@adminUserSetup', '@standardUserSetup', '@setup', '@components', '@navigation', '@charts', '@explorer', '@extensions', '@fleet', '@generic', '@globalSettings', '@manager', '@userMenu', '@usersAndAuths', '@elemental', '@kubewarden', '@vai'] }, () => { const rancherSetupLoginPage = new RancherSetupLoginPagePo(); const rancherSetupConfigurePage = new RancherSetupConfigurePage(); const homePage = new HomePagePo(); From a254707a66e1ce1b9e7219346659dc0988118af4 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Fri, 9 Aug 2024 11:25:03 +0100 Subject: [PATCH 42/46] tidy up pr to prepare for merge + stop kw spec form running + working on kw spec --- .github/workflows/check-plugins.yaml | 2 +- .github/workflows/docusaurus.yaml | 6 +- .../extensions-compatibility-tests.yaml | 17 +- .github/workflows/storybook.yaml | 6 +- .github/workflows/test.yaml | 8 +- .../extensions-compatibility.po.ts | 5 + .../kubewarden.po.ts | 29 +-- .../elemental.spec.ts | 2 +- .../kubewarden.spec.ts | 194 ++++-------------- cypress/e2e/tests/setup/rancher-setup.spec.ts | 2 +- 10 files changed, 67 insertions(+), 204 deletions(-) diff --git a/.github/workflows/check-plugins.yaml b/.github/workflows/check-plugins.yaml index 112680f5a2f..75fd2a2a923 100644 --- a/.github/workflows/check-plugins.yaml +++ b/.github/workflows/check-plugins.yaml @@ -2,7 +2,7 @@ name: check-plugins-build on: pull_request: branches: - - master-bananas + - master env: TEST_PERSIST_BUILD: true jobs: diff --git a/.github/workflows/docusaurus.yaml b/.github/workflows/docusaurus.yaml index b434d892797..8204dc40fb5 100644 --- a/.github/workflows/docusaurus.yaml +++ b/.github/workflows/docusaurus.yaml @@ -4,9 +4,9 @@ on: push: branches: - master - # pull_request: - # branches: - # - master + pull_request: + branches: + - master jobs: build: name: Build diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index fbd3f8c4378..0eb3a9bbdea 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -1,11 +1,7 @@ -name: Extensions Compatibility Tests 2.10 +name: Extensions Compatibility Tests on: schedule: - cron: "0 0 * * *" # runs at midnight every day - # TODO: DELETE THIS!!!! JUST FOR TESTING PURPOSES! - pull_request: - branches: - - master env: TEST_USERNAME: admin @@ -28,24 +24,23 @@ jobs: { username: 'admin', tag: '@adminUser' } ] features: [ - ['@elemental', 'elemental'], - ['@kubewarden', 'kubewarden'] + ['@elemental', 'elemental'] ] rancherEnv: [ - ['v2.9-head', 'master'] + ['2.10', 'v2.9-head'], + ['2.9', 'v2.9-head'] ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: - # ref: ${{ matrix.rancherEnv[1] }} TODO: should be removed after it get's merged fetch-depth: 1 - name: Setup env uses: ./.github/actions/setup # this is where docker is set up with the enviroment - - name: Run Rancher ${{ matrix.rancherEnv[0] }} - branch:${{ matrix.rancherEnv[1] }} - run: export RANCHER_VERSION_E2E=${{ matrix.rancherEnv[0] }} && yarn e2e:docker + - name: Run Rancher system ${{ matrix.rancherEnv[0] }} - image:${{ matrix.rancherEnv[1] }} + run: export RANCHER_VERSION_E2E=${{ matrix.rancherEnv[1] }} && yarn e2e:docker ## this is just setting up rancher and user - name: Setup Rancher and user diff --git a/.github/workflows/storybook.yaml b/.github/workflows/storybook.yaml index dcbef3c778a..7e8483c742a 100644 --- a/.github/workflows/storybook.yaml +++ b/.github/workflows/storybook.yaml @@ -5,9 +5,9 @@ on: push: branches: - master - # pull_request: - # branches: - # - master + pull_request: + branches: + - master jobs: storybook: runs-on: ubuntu-latest diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7f45ff23ceb..c6365c87116 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -4,10 +4,10 @@ on: branches: - master - 'release-*' - # pull_request: - # branches: - # - master - # - 'release-*' + pull_request: + branches: + - master + - 'release-*' workflow_dispatch: inputs: environment: diff --git a/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts b/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts index 459e47ef80e..1f3d3cd4f6e 100644 --- a/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts +++ b/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts @@ -7,6 +7,7 @@ import BaseResourceList from '@/cypress/e2e/po/lists/base-resource-list.po'; import CodeMirrorPo from '@/cypress/e2e/po/components/code-mirror.po'; import AsyncButtonPo from '@/cypress/e2e/po/components/async-button.po'; import LabeledInputPo from '@/cypress/e2e/po/components/labeled-input.po'; +import CheckboxInputPo from '@/cypress/e2e/po/components/checkbox-input.po'; const installChart = new InstallChartPage(); const terminal = new Kubectl(); @@ -90,4 +91,8 @@ export default class ExtensionsCompatibiliyPo extends PagePo { saveOrCreateCluster(): AsyncButtonPo { return new AsyncButtonPo('[data-testid="rke2-custom-create-save"]', this.self()); } + + genericCheckboxByLabel(label:string): CheckboxInputPo { + return CheckboxInputPo.byLabel(this.self(), label); + } } diff --git a/cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po.ts b/cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po.ts index eb4aae0caea..8880736f918 100644 --- a/cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po.ts +++ b/cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po.ts @@ -1,8 +1,5 @@ import ExtensionsCompatibiliyPo from '@/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po'; import Kubectl from '~/cypress/e2e/po/components/kubectl.po'; -import BannersPo from '@/cypress/e2e/po/components/banners.po'; -import LabeledSelectPo from '@/cypress/e2e/po/components/labeled-select.po'; -import RadioGroupInputPo from '@/cypress/e2e/po/components/radio-group-input.po'; export default class KubewardenPo extends ExtensionsCompatibiliyPo { static url = '/c/local/kubewarden'; static goTo(): Cypress.Chainable { @@ -41,27 +38,7 @@ export default class KubewardenPo extends ExtensionsCompatibiliyPo { return this.self().getId('kw-app-install-button').click(); } - // installOperatorBtnClick(): Cypress.Chainable { - // return this.self().getId('charts-install-button').click(); - // } - - // dashboardCreateElementalClusterClick() { - // return this.self().getId('button-create-elemental-cluster').click(); - // } - - // dashboardCreateUpdateGroupClick() { - // return this.self().getId('create-update-group-btn').click(); - // } - - // elementalClusterSelectorTemplateBanner() { - // return new BannersPo('[provider="machineinventoryselectortemplate"] .banner.warning'); - // } - - // updateGroupTargetClustersSelect() { - // return new LabeledSelectPo('[data-testid="cluster-target"]'); - // } - - // updateGroupImageOption() { - // return new RadioGroupInputPo('[data-testid="upgrade-choice-selector"]'); - // } + defaultPolicyServerInstallClick() { + return this.self().getId('kw-defaults-banner-button').click(); + } } diff --git a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts index 11abdc6f72f..c068d3563b8 100644 --- a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts +++ b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts @@ -34,7 +34,7 @@ describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] } // // This should be in a `before` however is flaky. Move it to an `it` to let cypress retry const extensionsPo = new ExtensionsPagePo(); - extensionsPo.addExtensionsRepositoryDirectLink(EXTENSION_REPO, EXTENSION_BRANCH, EXTENSION_CLUSTER_REPO_NAME, false); + extensionsPo.addExtensionsRepositoryDirectLink(EXTENSION_REPO, EXTENSION_BRANCH, EXTENSION_CLUSTER_REPO_NAME, true); }); it('Should install an extension', () => { diff --git a/cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts b/cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts index acabaf9b3e9..ab5053acde4 100644 --- a/cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts +++ b/cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts @@ -11,18 +11,6 @@ const EXTENSION_CLUSTER_REPO_NAME = 'kubewarden-ui-extension'; const EXTENSION_KW_REPO_ADD = 'addKwRepo'; const EXTENSION_CHART_CREATION = 'chartCreation'; -const REG_ENDPOINT_NAME = 'reg-endpoint-1'; -const REG_ENDPOINT_DEVICE_PATH = '/dev/nvme0n123'; - -const MACHINE_INV_NAME = 'machine-inventory-1'; - -const ELEMENTAL_CLUSTER_NAME = 'elemental-cluster-1'; -const ELEMENTAL_CLUSTER_BANNER_TEXT = 'Matches all 1 existing Inventory of Machines'; -const ELEMENTAL_CLUSTER_MACHINE_CONFIG_REF = 'MachineInventorySelectorTemplate'; - -const UPDATE_GROUP_NAME = 'update-group-1'; -const UPDATE_GROUP_IMAGE_PATH = 'some/path'; - const kubewardenPo = new KubewardenPo(); const namespacePicker = new NamespaceFilterPo(); @@ -31,41 +19,41 @@ describe('Extensions Compatibility spec', { tags: ['@kubewarden', '@adminUser'] cy.login(); }); - it('add extension repository', () => { - // // This should be in a `before` however is flaky. Move it to an `it` to let cypress retry - const extensionsPo = new ExtensionsPagePo(); + // it('add extension repository', () => { + // // // This should be in a `before` however is flaky. Move it to an `it` to let cypress retry + // const extensionsPo = new ExtensionsPagePo(); - extensionsPo.addExtensionsRepositoryDirectLink(EXTENSION_REPO, EXTENSION_BRANCH, EXTENSION_CLUSTER_REPO_NAME, false); - }); + // extensionsPo.addExtensionsRepositoryDirectLink(EXTENSION_REPO, EXTENSION_BRANCH, EXTENSION_CLUSTER_REPO_NAME, true); + // }); - it('Should install an extension', () => { - const extensionsPo = new ExtensionsPagePo(); + // it('Should install an extension', () => { + // const extensionsPo = new ExtensionsPagePo(); - extensionsPo.goTo(); + // extensionsPo.goTo(); - extensionsPo.extensionTabAvailableClick(); + // extensionsPo.extensionTabAvailableClick(); - // click on install button on card - extensionsPo.extensionCardInstallClick(EXTENSION_NAME); - extensionsPo.extensionInstallModal().should('be.visible'); + // // click on install button on card + // extensionsPo.extensionCardInstallClick(EXTENSION_NAME); + // extensionsPo.extensionInstallModal().should('be.visible'); - // select version and click install - extensionsPo.installModalSelectVersionLabel(EXTENSION_VERSION); - extensionsPo.installModalInstallClick(); + // // select version and click install + // extensionsPo.installModalSelectVersionLabel(EXTENSION_VERSION); + // extensionsPo.installModalInstallClick(); - // let's check the extension reload banner and reload the page - extensionsPo.extensionReloadBanner().should('be.visible'); - extensionsPo.extensionReloadClick(); + // // let's check the extension reload banner and reload the page + // extensionsPo.extensionReloadBanner().should('be.visible'); + // extensionsPo.extensionReloadClick(); - // make sure extension card is in the installed tab - extensionsPo.extensionTabInstalledClick(); - extensionsPo.extensionCardClick(EXTENSION_NAME); - extensionsPo.extensionDetailsTitle().should('contain', EXTENSION_NAME); - extensionsPo.extensionDetailsCloseClick(); - }); + // // make sure extension card is in the installed tab + // extensionsPo.extensionTabInstalledClick(); + // extensionsPo.extensionCardClick(EXTENSION_NAME); + // extensionsPo.extensionDetailsTitle().should('contain', EXTENSION_NAME); + // extensionsPo.extensionDetailsCloseClick(); + // }); it('Should setup all of the needed backend parts', () => { - cy.intercept('POST', 'v1/catalog.cattle.io.clusterrepos/rancher-charts?action=install').as(EXTENSION_CHART_CREATION); + cy.intercept('POST', 'v1/catalog.cattle.io.clusterrepos/kubewarden-charts?action=install').as(EXTENSION_CHART_CREATION); kubewardenPo.goTo(); kubewardenPo.waitForTitle('h1', 'Kubewarden'); @@ -78,132 +66,30 @@ describe('Extensions Compatibility spec', { tags: ['@kubewarden', '@adminUser'] // start install steps kubewardenPo.startBackendInstallClick(); - // 1 - install cert manager - kubewardenPo.openTerminalClick(); - kubewardenPo.kubectlShell().executeCommand('apply -f https://github.com/jetstack/cert-manager/releases/latest/download/cert-manager.yaml'); - kubewardenPo.waitForCertManagerToInstall(); - kubewardenPo.kubectlShell().closeTerminal(); + // // 1 - install cert manager + // kubewardenPo.openTerminalClick(); + // kubewardenPo.kubectlShell().executeCommand('apply -f https://github.com/jetstack/cert-manager/releases/latest/download/cert-manager.yaml'); + // kubewardenPo.waitForCertManagerToInstall(); + // kubewardenPo.kubectlShell().closeTerminal(); - // 2 - Add kubewarden repository - kubewardenPo.addKwRepoClick(); - kubewardenPo.waitForKwRepoToBeAdded(); + // // 2 - Add kubewarden repository + // kubewardenPo.addKwRepoClick(); + // kubewardenPo.waitForKwRepoToBeAdded(); - // 2 - Install kubewarden operator + // 3 - Install kubewarden operator kubewardenPo.installOperatorBtnClick(); kubewardenPo.waitForInstallChartPage('kubewarden-charts', 'kubewarden-controller'); kubewardenPo.chartInstallNext(); + kubewardenPo.genericCheckboxByLabel('Enable Policy Reporter UI').set(); + kubewardenPo.chartInstallClick(); + kubewardenPo.chartInstallWaitForInstallationAndCloseTerminal(EXTENSION_CHART_CREATION, ['rancher-kubewarden-controller', 'rancher-kubewarden-crds']); - // // we need to change the namespace picker in order for the install check on the list view - // namespacePicker.toggle(); - // namespacePicker.clickOptionByLabel('All Namespaces'); - // namespacePicker.closeDropdown(); - - // kubewardenPo.chartInstallNext(); - // kubewardenPo.chartInstallClick(); - // kubewardenPo.chartInstallWaitForInstallationAndCloseTerminal(EXTENSION_CHART_CREATION); + kubewardenPo.goTo(); + kubewardenPo.waitForTitle('[data-testid="kw-dashboard-title"]', 'Welcome to Kubewarden'); - // kubewardenPo.goTo(); - // kubewardenPo.waitForTitle('[data-testid="elemental-main-title"]', 'OS Management Dashboard'); + // 4 - add default policy server charts }); - // it('Should create an Elemental registration endpoint', () => { - // cy.intercept('POST', 'v1/elemental.cattle.io.machineregistrations/fleet-default').as('machineRegCreation'); - - // kubewardenPo.goTo(); - // kubewardenPo.sideMenuNavTo('Registration Endpoints'); - // kubewardenPo.createClick(); - - // kubewardenPo.genericNameInput().set(REG_ENDPOINT_NAME); - // kubewardenPo.genericYamlEditor().value().then((val) => { - // // convert yaml into json to update values - // const json: any = jsyaml.load(val); - - // json.config.elemental.install.device = REG_ENDPOINT_DEVICE_PATH; - - // kubewardenPo.genericYamlEditor().set(jsyaml.dump(json)); - // kubewardenPo.saveOrCreateResource().click(); - - // cy.wait('@machineRegCreation', { requestTimeout: 15000 }).then(({ response }) => { - // expect(response?.statusCode).to.eq(201); - // expect(response?.body.metadata).to.have.property('name', REG_ENDPOINT_NAME); - // expect(response?.body.spec.config.elemental.install).to.have.property('device', REG_ENDPOINT_DEVICE_PATH); - // }); - // }); - // }); - - // it('Should create an Elemental resource via YAML (Inventory of Machines)', () => { - // function poolingSchemaDefinition() { - // cy - // .request('GET', 'v1/schemaDefinitions/elemental.cattle.io.machineinventory') - // .then((resp) => { - // if (resp.status === 200) { - // return; - // } - - // cy.wait(5000); // let's wait for a bit so that we don't overload the server - // poolingSchemaDefinition(); - // }); - // } - - // kubewardenPo.goTo(); - // kubewardenPo.sideMenuNavTo('Inventory of Machines'); - // // after we hit create from YAML we need to pool for the schemaDefinition since - // // that takes while to be available https://docs.cypress.io/api/commands/request#Request-Polling - // kubewardenPo.createFromYamlClick().then(poolingSchemaDefinition); - - // kubewardenPo.genericYamlEditor().value().then((val) => { - // // convert yaml into json to update values - // const json: any = jsyaml.load(val); - - // json.metadata.name = MACHINE_INV_NAME; - - // kubewardenPo.genericYamlEditor().set(jsyaml.dump(json)); - // kubewardenPo.saveEditYamlForm().click(); - - // kubewardenPo.waitForPageWithSpecificUrl('/elemental/c/_/elemental.cattle.io.machineinventory'); - // kubewardenPo.genericListView().rowWithName(MACHINE_INV_NAME).column(2).should('contain', MACHINE_INV_NAME); - // }); - // }); - - // it('Should create an Elemental cluster, targeting all of the inventory of machines', () => { - // cy.intercept('POST', 'v1/provisioning.cattle.io.clusters').as('elementalClusterCreation'); - - // kubewardenPo.goTo(); - // kubewardenPo.dashboardCreateElementalClusterClick(); - - // kubewardenPo.genericNameInput().set(ELEMENTAL_CLUSTER_NAME); - // kubewardenPo.elementalClusterSelectorTemplateBanner().banner().contains(ELEMENTAL_CLUSTER_BANNER_TEXT); - // kubewardenPo.saveOrCreateCluster().click(); - - // cy.wait('@elementalClusterCreation', { requestTimeout: 15000 }).then(({ response }) => { - // expect(response?.statusCode).to.eq(201); - // expect(response?.body.metadata).to.have.property('name', ELEMENTAL_CLUSTER_NAME); - // expect(response?.body.spec.rkeConfig.machinePools[0].machineConfigRef).to.have.property('kind', ELEMENTAL_CLUSTER_MACHINE_CONFIG_REF); - // }); - // }); - - // it('Should create an Upgrade Group', () => { - // cy.intercept('POST', 'v1/elemental.cattle.io.managedosimages').as('elementalUpdateGroupCreation'); - - // kubewardenPo.goTo(); - // kubewardenPo.dashboardCreateUpdateGroupClick(); - - // kubewardenPo.genericNameInput().set(UPDATE_GROUP_NAME); - // kubewardenPo.updateGroupTargetClustersSelect().toggle(); - // kubewardenPo.updateGroupTargetClustersSelect().clickOptionWithLabel(ELEMENTAL_CLUSTER_NAME); - // kubewardenPo.updateGroupImageOption().set(1); - - // kubewardenPo.genericLabeledInputByLabel('Image path').set(UPDATE_GROUP_IMAGE_PATH); - // kubewardenPo.saveOrCreateResource().click(); - - // cy.wait('@elementalUpdateGroupCreation', { requestTimeout: 15000 }).then(({ response }) => { - // expect(response?.statusCode).to.eq(201); - // expect(response?.body.metadata).to.have.property('name', UPDATE_GROUP_NAME); - // expect(response?.body.spec.clusterTargets[0]).to.have.property('clusterName', ELEMENTAL_CLUSTER_NAME); - // expect(response?.body.spec).to.have.property('osImage', UPDATE_GROUP_IMAGE_PATH); - // }); - // }); - // it('Should uninstall the extension', () => { // const extensionsPo = new ExtensionsPagePo(); diff --git a/cypress/e2e/tests/setup/rancher-setup.spec.ts b/cypress/e2e/tests/setup/rancher-setup.spec.ts index 314f9d4bea6..255d74095e1 100644 --- a/cypress/e2e/tests/setup/rancher-setup.spec.ts +++ b/cypress/e2e/tests/setup/rancher-setup.spec.ts @@ -6,7 +6,7 @@ import { serverUrlLocalhostCases, urlWithTrailingForwardSlash, httpUrl, nonUrlCa // Cypress or the GrepTags avoid to run multiples times the same test for each tag used. // This is a temporary solution till initialization is not handled as a test -describe('Rancher setup', { tags: ['@adminUserSetup', '@standardUserSetup', '@setup', '@components', '@navigation', '@charts', '@explorer', '@extensions', '@fleet', '@generic', '@globalSettings', '@manager', '@userMenu', '@usersAndAuths', '@elemental', '@kubewarden', '@vai'] }, () => { +describe('Rancher setup', { tags: ['@adminUserSetup', '@standardUserSetup', '@setup', '@components', '@navigation', '@charts', '@explorer', '@extensions', '@fleet', '@generic', '@globalSettings', '@manager', '@userMenu', '@usersAndAuths', '@elemental', '@vai'] }, () => { const rancherSetupLoginPage = new RancherSetupLoginPagePo(); const rancherSetupConfigurePage = new RancherSetupConfigurePage(); const homePage = new HomePagePo(); From 5654bbd5fbfd1c847ecdaf762d0a41550be672d0 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Fri, 9 Aug 2024 11:25:51 +0100 Subject: [PATCH 43/46] changes --- .github/workflows/storybook.yaml | 2 +- .github/workflows/test.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/storybook.yaml b/.github/workflows/storybook.yaml index 7e8483c742a..b71bc7a58c8 100644 --- a/.github/workflows/storybook.yaml +++ b/.github/workflows/storybook.yaml @@ -24,4 +24,4 @@ jobs: yarn build-storybook - name: Publish Storybook if: ${{ github.event_name == 'push' && github.repository_owner == 'rancher'}} - run: .github/workflows/scripts/publish-storybook \ No newline at end of file + run: .github/workflows/scripts/publish-storybook diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c6365c87116..80ebb206a44 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -231,4 +231,4 @@ jobs: node-version-file: '.nvmrc' - name: Check e2e tags run: | - ./scripts/check-e2e-tests-for-tags \ No newline at end of file + ./scripts/check-e2e-tests-for-tags From 61a16e5fc6e465bdd7eac61880884ee17b3da5d2 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Fri, 9 Aug 2024 11:31:00 +0100 Subject: [PATCH 44/46] fix lint issues --- .../extensions-compatibility.po.ts | 4 ++-- .../elemental.spec.ts | 4 +++- .../kubewarden.spec.ts | 18 +++++++++--------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts b/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts index 1f3d3cd4f6e..adb32d4f7f7 100644 --- a/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts +++ b/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts @@ -38,7 +38,7 @@ export default class ExtensionsCompatibiliyPo extends PagePo { cy.wait(`@${ interceptName }`, { requestTimeout: 20000 }).its('response.statusCode').should('eq', 201); // giving it a small buffer so that the install is properly triggered - cy.wait(15000); + cy.wait(15000); // eslint-disable-line cypress/no-unnecessary-waiting terminal.closeTerminal(); installableParts.forEach((item:string) => { @@ -47,7 +47,7 @@ export default class ExtensionsCompatibiliyPo extends PagePo { // timeout to give time for everything to be setup, otherwise the extension // won't find the chart and show the correct screen - return cy.wait(10000); + return cy.wait(10000); // eslint-disable-line cypress/no-unnecessary-waiting } sideMenuNavTo(label: string) { diff --git a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts index c068d3563b8..2afc61d06db 100644 --- a/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts +++ b/cypress/e2e/tests/pages/extensions-compatibility-tests/elemental.spec.ts @@ -124,7 +124,9 @@ describe('Extensions Compatibility spec', { tags: ['@elemental', '@adminUser'] } return; } - cy.wait(5000); // let's wait for a bit so that we don't overload the server + // let's wait for a bit so that we don't overload the server + // with requests + cy.wait(5000); // eslint-disable-line cypress/no-unnecessary-waiting poolingSchemaDefinition(); }); } diff --git a/cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts b/cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts index ab5053acde4..22b70df5b50 100644 --- a/cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts +++ b/cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts @@ -1,14 +1,14 @@ -import ExtensionsPagePo from '@/cypress/e2e/po/pages/extensions.po'; +// import ExtensionsPagePo from '@/cypress/e2e/po/pages/extensions.po'; import KubewardenPo from '@/cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po'; import { NamespaceFilterPo } from '@/cypress/e2e/po/components/namespace-filter.po'; -import * as jsyaml from 'js-yaml'; - -const EXTENSION_NAME = 'kubewarden'; -const EXTENSION_VERSION = '2.0.0'; -const EXTENSION_REPO = 'https://github.com/rancher/kubewarden-ui'; -const EXTENSION_BRANCH = 'gh-pages'; -const EXTENSION_CLUSTER_REPO_NAME = 'kubewarden-ui-extension'; -const EXTENSION_KW_REPO_ADD = 'addKwRepo'; +// import * as jsyaml from 'js-yaml'; + +// const EXTENSION_NAME = 'kubewarden'; +// const EXTENSION_VERSION = '2.0.0'; +// const EXTENSION_REPO = 'https://github.com/rancher/kubewarden-ui'; +// const EXTENSION_BRANCH = 'gh-pages'; +// const EXTENSION_CLUSTER_REPO_NAME = 'kubewarden-ui-extension'; +// const EXTENSION_KW_REPO_ADD = 'addKwRepo'; const EXTENSION_CHART_CREATION = 'chartCreation'; const kubewardenPo = new KubewardenPo(); From 1895c1988df220fce4bec8250ac9284aa992fae7 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Fri, 9 Aug 2024 16:53:27 +0100 Subject: [PATCH 45/46] working on kubewarden spec --- .github/workflows/check-plugins.yaml | 2 +- .github/workflows/docusaurus.yaml | 6 +- .../extensions-compatibility-tests.yaml | 9 +- .github/workflows/storybook.yaml | 6 +- .github/workflows/test.yaml | 8 +- cypress/e2e/po/components/kubectl.po.ts | 6 +- .../extensions-compatibility.po.ts | 39 ++++- .../kubewarden.po.ts | 9 + .../kubewarden.spec.ts | 162 ++++++++++++++---- cypress/e2e/tests/setup/rancher-setup.spec.ts | 2 +- 10 files changed, 195 insertions(+), 54 deletions(-) diff --git a/.github/workflows/check-plugins.yaml b/.github/workflows/check-plugins.yaml index 75fd2a2a923..112680f5a2f 100644 --- a/.github/workflows/check-plugins.yaml +++ b/.github/workflows/check-plugins.yaml @@ -2,7 +2,7 @@ name: check-plugins-build on: pull_request: branches: - - master + - master-bananas env: TEST_PERSIST_BUILD: true jobs: diff --git a/.github/workflows/docusaurus.yaml b/.github/workflows/docusaurus.yaml index 8204dc40fb5..b434d892797 100644 --- a/.github/workflows/docusaurus.yaml +++ b/.github/workflows/docusaurus.yaml @@ -4,9 +4,9 @@ on: push: branches: - master - pull_request: - branches: - - master + # pull_request: + # branches: + # - master jobs: build: name: Build diff --git a/.github/workflows/extensions-compatibility-tests.yaml b/.github/workflows/extensions-compatibility-tests.yaml index 0eb3a9bbdea..3160b49b519 100644 --- a/.github/workflows/extensions-compatibility-tests.yaml +++ b/.github/workflows/extensions-compatibility-tests.yaml @@ -2,6 +2,10 @@ name: Extensions Compatibility Tests on: schedule: - cron: "0 0 * * *" # runs at midnight every day + # TODO: DELETE THIS!!!! JUST FOR TESTING PURPOSES! + pull_request: + branches: + - master env: TEST_USERNAME: admin @@ -24,10 +28,11 @@ jobs: { username: 'admin', tag: '@adminUser' } ] features: [ - ['@elemental', 'elemental'] + ['@elemental', 'elemental'], + ['@kubewarden', 'kubewarden'] ] rancherEnv: [ - ['2.10', 'v2.9-head'], + # ['2.10', 'v2.9-head'], ['2.9', 'v2.9-head'] ] runs-on: ubuntu-latest diff --git a/.github/workflows/storybook.yaml b/.github/workflows/storybook.yaml index b71bc7a58c8..bba2101021b 100644 --- a/.github/workflows/storybook.yaml +++ b/.github/workflows/storybook.yaml @@ -5,9 +5,9 @@ on: push: branches: - master - pull_request: - branches: - - master + # pull_request: + # branches: + # - master jobs: storybook: runs-on: ubuntu-latest diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 80ebb206a44..e93ae062ad5 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -4,10 +4,10 @@ on: branches: - master - 'release-*' - pull_request: - branches: - - master - - 'release-*' + # pull_request: + # branches: + # - master + # - 'release-*' workflow_dispatch: inputs: environment: diff --git a/cypress/e2e/po/components/kubectl.po.ts b/cypress/e2e/po/components/kubectl.po.ts index 841665ca124..d1a99cafecb 100644 --- a/cypress/e2e/po/components/kubectl.po.ts +++ b/cypress/e2e/po/components/kubectl.po.ts @@ -29,8 +29,10 @@ export default class Kubectl extends ComponentPo { * @param command Kube command without the 'kubectl' * @returns executeCommand for method chanining */ - executeCommand(command: string, wait = 3000) { - this.self().get(this.terminalRow).type(`${ this.kubeCommand } ${ command }{enter}`); + executeCommand(command: string, prependKubectl = true, wait = 3000) { + const parsedCommand = prependKubectl ? `${ this.kubeCommand } ${ command }{enter}` : `${ command }{enter}`; + + this.self().get(this.terminalRow).type(parsedCommand); cy.wait(wait); return this; diff --git a/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts b/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts index adb32d4f7f7..ca30447d697 100644 --- a/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts +++ b/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts @@ -8,6 +8,7 @@ import CodeMirrorPo from '@/cypress/e2e/po/components/code-mirror.po'; import AsyncButtonPo from '@/cypress/e2e/po/components/async-button.po'; import LabeledInputPo from '@/cypress/e2e/po/components/labeled-input.po'; import CheckboxInputPo from '@/cypress/e2e/po/components/checkbox-input.po'; +import TabbedPo from '@/cypress/e2e/po/components/tabbed.po'; const installChart = new InstallChartPage(); const terminal = new Kubectl(); @@ -22,6 +23,10 @@ export default class ExtensionsCompatibiliyPo extends PagePo { return this.title(selector).should('contain', title); } + goToInstallChartPage(clusterId:string, queryParams = '') { + return installChart.goTo(clusterId, queryParams); + } + waitForInstallChartPage(repoName:string, chartName:string) { return installChart.waitForChartPage(repoName, chartName); } @@ -34,11 +39,11 @@ export default class ExtensionsCompatibiliyPo extends PagePo { return installChart.installChart(); } - chartInstallWaitForInstallationAndCloseTerminal(interceptName: string, installableParts: Array) { + chartInstallWaitForInstallationAndCloseTerminal(interceptName: string, installableParts: Array, beforeTimeout = 15000) { cy.wait(`@${ interceptName }`, { requestTimeout: 20000 }).its('response.statusCode').should('eq', 201); // giving it a small buffer so that the install is properly triggered - cy.wait(15000); // eslint-disable-line cypress/no-unnecessary-waiting + cy.wait(beforeTimeout); // eslint-disable-line cypress/no-unnecessary-waiting terminal.closeTerminal(); installableParts.forEach((item:string) => { @@ -50,6 +55,30 @@ export default class ExtensionsCompatibiliyPo extends PagePo { return cy.wait(10000); // eslint-disable-line cypress/no-unnecessary-waiting } + chartInstallWaitForUpgradeAndCloseTerminal(interceptName: string, beforeTimeout = 15000) { + cy.wait(`@${ interceptName }`, { requestTimeout: 20000 }).its('response.statusCode').should('eq', 201); + + // giving it a small buffer so that the install is properly triggered + cy.wait(beforeTimeout); // eslint-disable-line cypress/no-unnecessary-waiting + terminal.closeTerminal(); + + cy.get('.masthead-state.badge-state').invoke('text').should('contain', 'Deployed'); + + // timeout to give time for everything to be setup, otherwise the extension + // won't find the chart and show the correct screen + return cy.wait(10000); // eslint-disable-line cypress/no-unnecessary-waiting + } + + genericWaitForAppToInstall(appName: string, isTerminalOp = true) { + if (isTerminalOp) { + cy.wait(15000); // eslint-disable-line cypress/no-unnecessary-waiting + terminal.closeTerminal(); + } + installedApps.list().state(appName).should('contain', 'Deployed'); + + return cy.wait(5000); // eslint-disable-line cypress/no-unnecessary-waiting + } + sideMenuNavTo(label: string) { const sideNav = new ProductNavPo(); @@ -95,4 +124,10 @@ export default class ExtensionsCompatibiliyPo extends PagePo { genericCheckboxByLabel(label:string): CheckboxInputPo { return CheckboxInputPo.byLabel(this.self(), label); } + + clickGenericLateralTab(selector: string) { + const tab = new TabbedPo(); + + return tab.clickTabWithSelector(selector); + } } diff --git a/cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po.ts b/cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po.ts index 8880736f918..e5ef7a9e119 100644 --- a/cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po.ts +++ b/cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po.ts @@ -1,5 +1,6 @@ import ExtensionsCompatibiliyPo from '@/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po'; import Kubectl from '~/cypress/e2e/po/components/kubectl.po'; +import LabeledSelectPo from '@/cypress/e2e/po/components/labeled-select.po'; export default class KubewardenPo extends ExtensionsCompatibiliyPo { static url = '/c/local/kubewarden'; static goTo(): Cypress.Chainable { @@ -41,4 +42,12 @@ export default class KubewardenPo extends ExtensionsCompatibiliyPo { defaultPolicyServerInstallClick() { return this.self().getId('kw-defaults-banner-button').click(); } + + rancherMonitoringInstallIntoProjectSelect(optionIndex: number): Cypress.Chainable { + const selectProject = new LabeledSelectPo('.labeled-select.edit'); + + selectProject.toggle(); + + return selectProject.clickOption(optionIndex); + } } diff --git a/cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts b/cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts index 22b70df5b50..5c97aa3b4a5 100644 --- a/cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts +++ b/cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts @@ -1,6 +1,7 @@ // import ExtensionsPagePo from '@/cypress/e2e/po/pages/extensions.po'; import KubewardenPo from '@/cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po'; import { NamespaceFilterPo } from '@/cypress/e2e/po/components/namespace-filter.po'; +import ChartInstalledAppsPagePo from '@/cypress/e2e/po/pages/chart-installed-apps.po'; // import * as jsyaml from 'js-yaml'; // const EXTENSION_NAME = 'kubewarden'; @@ -9,10 +10,12 @@ import { NamespaceFilterPo } from '@/cypress/e2e/po/components/namespace-filter. // const EXTENSION_BRANCH = 'gh-pages'; // const EXTENSION_CLUSTER_REPO_NAME = 'kubewarden-ui-extension'; // const EXTENSION_KW_REPO_ADD = 'addKwRepo'; -const EXTENSION_CHART_CREATION = 'chartCreation'; +const MAIN_EXTENSION_CHART_CREATION = 'chartCreation'; +const MAIN_EXTENSION_CHART_UPGRADE = 'chartUpgrade'; const kubewardenPo = new KubewardenPo(); const namespacePicker = new NamespaceFilterPo(); +const installedApps = new ChartInstalledAppsPagePo('local', 'apps'); describe('Extensions Compatibility spec', { tags: ['@kubewarden', '@adminUser'] }, () => { beforeEach(() => { @@ -53,41 +56,128 @@ describe('Extensions Compatibility spec', { tags: ['@kubewarden', '@adminUser'] // }); it('Should setup all of the needed backend parts', () => { - cy.intercept('POST', 'v1/catalog.cattle.io.clusterrepos/kubewarden-charts?action=install').as(EXTENSION_CHART_CREATION); - - kubewardenPo.goTo(); - kubewardenPo.waitForTitle('h1', 'Kubewarden'); - - // we need to change the namespace picker in order for the install check on the list view - namespacePicker.toggle(); - namespacePicker.clickOptionByLabel('All Namespaces'); - namespacePicker.closeDropdown(); - - // start install steps - kubewardenPo.startBackendInstallClick(); - - // // 1 - install cert manager - // kubewardenPo.openTerminalClick(); - // kubewardenPo.kubectlShell().executeCommand('apply -f https://github.com/jetstack/cert-manager/releases/latest/download/cert-manager.yaml'); - // kubewardenPo.waitForCertManagerToInstall(); - // kubewardenPo.kubectlShell().closeTerminal(); - - // // 2 - Add kubewarden repository - // kubewardenPo.addKwRepoClick(); - // kubewardenPo.waitForKwRepoToBeAdded(); - - // 3 - Install kubewarden operator - kubewardenPo.installOperatorBtnClick(); - kubewardenPo.waitForInstallChartPage('kubewarden-charts', 'kubewarden-controller'); - kubewardenPo.chartInstallNext(); - kubewardenPo.genericCheckboxByLabel('Enable Policy Reporter UI').set(); - kubewardenPo.chartInstallClick(); - kubewardenPo.chartInstallWaitForInstallationAndCloseTerminal(EXTENSION_CHART_CREATION, ['rancher-kubewarden-controller', 'rancher-kubewarden-crds']); - - kubewardenPo.goTo(); - kubewardenPo.waitForTitle('[data-testid="kw-dashboard-title"]', 'Welcome to Kubewarden'); - - // 4 - add default policy server charts + cy.intercept('POST', 'v1/catalog.cattle.io.clusterrepos/kubewarden-charts?action=install').as(MAIN_EXTENSION_CHART_CREATION); + cy.intercept('POST', 'v1/catalog.cattle.io.clusterrepos/kubewarden-charts?action=upgrade').as(MAIN_EXTENSION_CHART_UPGRADE); + + // kubewardenPo.goTo(); + // kubewardenPo.waitForTitle('h1', 'Kubewarden'); + + // // we need to change the namespace picker in order for the install check on the list view + // namespacePicker.toggle(); + // namespacePicker.clickOptionByLabel('All Namespaces'); + // namespacePicker.closeDropdown(); + + // // start install steps + // kubewardenPo.startBackendInstallClick(); + + // // 1 - install cert manager + // kubewardenPo.openTerminalClick(); + // kubewardenPo.kubectlShell().executeCommand('kubectl apply -f https://github.com/jetstack/cert-manager/releases/latest/download/cert-manager.yaml', false); + // kubewardenPo.waitForCertManagerToInstall(); + // kubewardenPo.kubectlShell().closeTerminal(); + + // // 2 - Add kubewarden repository + // kubewardenPo.addKwRepoClick(); + // kubewardenPo.waitForKwRepoToBeAdded(); + + // // 3 - Install kubewarden operator + // kubewardenPo.installOperatorBtnClick(); + // kubewardenPo.waitForInstallChartPage('kubewarden-charts', 'kubewarden-controller'); + // kubewardenPo.chartInstallNext(); + // kubewardenPo.genericCheckboxByLabel('Enable Policy Reporter UI').set(); + // kubewardenPo.chartInstallClick(); + // kubewardenPo.chartInstallWaitForInstallationAndCloseTerminal(MAIN_EXTENSION_CHART_CREATION, ['rancher-kubewarden-controller', 'rancher-kubewarden-crds'], 40000); + + // kubewardenPo.goTo(); + // kubewardenPo.waitForTitle('[data-testid="kw-dashboard-title"]', 'Welcome to Kubewarden'); + + // // 4 - add default policy server charts + // kubewardenPo.defaultPolicyServerInstallClick(); + // kubewardenPo.waitForInstallChartPage('kubewarden-charts', 'kubewarden-defaults'); + // kubewardenPo.chartInstallNext(); + // kubewardenPo.genericCheckboxByLabel('Enable recommended policies').set(); + // kubewardenPo.chartInstallClick(); + // kubewardenPo.chartInstallWaitForInstallationAndCloseTerminal(MAIN_EXTENSION_CHART_CREATION, ['rancher-kubewarden-defaults']); + + // installedApps.goTo(); + // installedApps.waitForPage(); + + // // 5 - Install Tracing parts + // // 5.1 - Open Telemetry Operator as per https://docs.kubewarden.io/next/howtos/telemetry/opentelemetry-qs#install-opentelemetry + // const addOTCommand = `helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts + + // helm install --wait \ + // --namespace open-telemetry \ + // --create-namespace \ + // --version 0.56.0 \ + // --set "manager.collectorImage.repository=otel/opentelemetry-collector-contrib" \ + // my-opentelemetry-operator open-telemetry/opentelemetry-operator`; + + // kubewardenPo.kubectlShell().openTerminal(); + // kubewardenPo.kubectlShell().executeCommand(addOTCommand, false); + // kubewardenPo.genericWaitForAppToInstall('my-opentelemetry-operator'); + + // // 5.2 - Jaeger Operator as per https://docs.kubewarden.io/next/howtos/telemetry/tracing-qs#install-jaeger + // const addJaegerOperatorCommand = `helm repo add jaegertracing https://jaegertracing.github.io/helm-charts + + // helm upgrade -i --wait \ + // --namespace jaeger \ + // --create-namespace \ + // --version 2.49.0 \ + // jaeger-operator jaegertracing/jaeger-operator \ + // --set rbac.clusterRole=true`; + + // kubewardenPo.kubectlShell().openTerminal(); + // kubewardenPo.kubectlShell().executeCommand(addJaegerOperatorCommand, false); + // kubewardenPo.genericWaitForAppToInstall('jaeger-operator'); + + // // 5.3 - Create Jaeger Resource as per https://docs.kubewarden.io/next/howtos/telemetry/tracing-qs#install-jaeger + // const createJaegerResource = `kubectl apply -f - < { diff --git a/cypress/e2e/tests/setup/rancher-setup.spec.ts b/cypress/e2e/tests/setup/rancher-setup.spec.ts index 255d74095e1..314f9d4bea6 100644 --- a/cypress/e2e/tests/setup/rancher-setup.spec.ts +++ b/cypress/e2e/tests/setup/rancher-setup.spec.ts @@ -6,7 +6,7 @@ import { serverUrlLocalhostCases, urlWithTrailingForwardSlash, httpUrl, nonUrlCa // Cypress or the GrepTags avoid to run multiples times the same test for each tag used. // This is a temporary solution till initialization is not handled as a test -describe('Rancher setup', { tags: ['@adminUserSetup', '@standardUserSetup', '@setup', '@components', '@navigation', '@charts', '@explorer', '@extensions', '@fleet', '@generic', '@globalSettings', '@manager', '@userMenu', '@usersAndAuths', '@elemental', '@vai'] }, () => { +describe('Rancher setup', { tags: ['@adminUserSetup', '@standardUserSetup', '@setup', '@components', '@navigation', '@charts', '@explorer', '@extensions', '@fleet', '@generic', '@globalSettings', '@manager', '@userMenu', '@usersAndAuths', '@elemental', '@kubewarden', '@vai'] }, () => { const rancherSetupLoginPage = new RancherSetupLoginPagePo(); const rancherSetupConfigurePage = new RancherSetupConfigurePage(); const homePage = new HomePagePo(); From 4d8b007077f80f19d6ce61d836a31237b26d8097 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Wed, 14 Aug 2024 09:04:01 +0100 Subject: [PATCH 46/46] working on kubewarden spec --- .../extensions-compatibility.po.ts | 24 +- .../kubewarden.po.ts | 44 ++ .../e2e/po/side-bars/product-side-nav.po.ts | 10 + .../kubewarden.spec.ts | 414 +++++++++++------- 4 files changed, 325 insertions(+), 167 deletions(-) diff --git a/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts b/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts index ca30447d697..a2e05e9b890 100644 --- a/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts +++ b/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po.ts @@ -9,6 +9,8 @@ import AsyncButtonPo from '@/cypress/e2e/po/components/async-button.po'; import LabeledInputPo from '@/cypress/e2e/po/components/labeled-input.po'; import CheckboxInputPo from '@/cypress/e2e/po/components/checkbox-input.po'; import TabbedPo from '@/cypress/e2e/po/components/tabbed.po'; +import ResourceTablePo from '@/cypress/e2e/po/components/resource-table.po'; +import LabeledSelectPo from '@/cypress/e2e/po/components/labeled-select.po'; const installChart = new InstallChartPage(); const terminal = new Kubectl(); @@ -39,8 +41,8 @@ export default class ExtensionsCompatibiliyPo extends PagePo { return installChart.installChart(); } - chartInstallWaitForInstallationAndCloseTerminal(interceptName: string, installableParts: Array, beforeTimeout = 15000) { - cy.wait(`@${ interceptName }`, { requestTimeout: 20000 }).its('response.statusCode').should('eq', 201); + chartInstallWaitForInstallationAndCloseTerminal(interceptName: string, installableParts: Array, beforeTimeout = 15000, requestTimeout = 20000) { + cy.wait(`@${ interceptName }`, { requestTimeout }).its('response.statusCode').should('eq', 201); // giving it a small buffer so that the install is properly triggered cy.wait(beforeTimeout); // eslint-disable-line cypress/no-unnecessary-waiting @@ -71,24 +73,30 @@ export default class ExtensionsCompatibiliyPo extends PagePo { genericWaitForAppToInstall(appName: string, isTerminalOp = true) { if (isTerminalOp) { - cy.wait(15000); // eslint-disable-line cypress/no-unnecessary-waiting + cy.wait(20000); // eslint-disable-line cypress/no-unnecessary-waiting terminal.closeTerminal(); } installedApps.list().state(appName).should('contain', 'Deployed'); - return cy.wait(5000); // eslint-disable-line cypress/no-unnecessary-waiting + return cy.wait(10000); // eslint-disable-line cypress/no-unnecessary-waiting } sideMenuNavTo(label: string) { const sideNav = new ProductNavPo(); - sideNav.navToSideMenuEntryByLabel(label); + sideNav.navToSideMenuEntryByExactLabel(label); } genericListView(): BaseResourceList { return new BaseResourceList(this.self()); } + goToDetailsPage(elemName: string) { + const resourceTable = new ResourceTablePo(this.self()); + + return resourceTable.sortableTable().detailsPageLinkWithName(elemName).click(); + } + createFromYamlClick(): Cypress.Chainable { return this.genericListView().masthead().createYaml(); } @@ -101,6 +109,10 @@ export default class ExtensionsCompatibiliyPo extends PagePo { return LabeledInputPo.bySelector(this.self(), '[data-testid="name-ns-description-name"]'); } + genericNamespaceInput(): LabeledSelectPo { + return new LabeledSelectPo('[data-testid="name-ns-description-namespace"]'); + } + genericLabeledInputByLabel(label:string): LabeledInputPo { return LabeledInputPo.byLabel(this.self(), label); } @@ -125,7 +137,7 @@ export default class ExtensionsCompatibiliyPo extends PagePo { return CheckboxInputPo.byLabel(this.self(), label); } - clickGenericLateralTab(selector: string) { + clickGenericTab(selector: string) { const tab = new TabbedPo(); return tab.clickTabWithSelector(selector); diff --git a/cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po.ts b/cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po.ts index e5ef7a9e119..935d0369145 100644 --- a/cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po.ts +++ b/cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po.ts @@ -1,6 +1,8 @@ import ExtensionsCompatibiliyPo from '@/cypress/e2e/po/pages/extensions-compatibility-tests/extensions-compatibility.po'; import Kubectl from '~/cypress/e2e/po/components/kubectl.po'; import LabeledSelectPo from '@/cypress/e2e/po/components/labeled-select.po'; +import SortableTablePo from '@/cypress/e2e/po/components/sortable-table.po'; +import AsyncButtonPo from '@/cypress/e2e/po/components/async-button.po'; export default class KubewardenPo extends ExtensionsCompatibiliyPo { static url = '/c/local/kubewarden'; static goTo(): Cypress.Chainable { @@ -50,4 +52,46 @@ export default class KubewardenPo extends ExtensionsCompatibiliyPo { return selectProject.clickOption(optionIndex); } + + metricsAddServiceMonitorClick() { + this.self().getId('kw-monitoring-checklist-step-service-monitor-button').click(); + } + + metricsAddGrafanaDasboardClick() { + this.self().getId('kw-monitoring-checklist-step-config-map-button').click(); + } + + waitForNamespaceCreation(interceptName: string, namespaceToCheck: string) { + cy.wait(`@${ interceptName }`, { requestTimeout: 15000 }).then(({ response }) => { + expect(response?.statusCode).to.eq(201); + expect(response?.body.metadata).to.have.property('name', namespaceToCheck); + cy.wait(3000); // eslint-disable-line cypress/no-unnecessary-waiting + }); + } + + addToArtifactHubClick() { + this.self().getId('action-button-async-button').click(); + } + + apOfficialPoliciesTable() { + return new SortableTablePo(this.self().get('.sortable-table')); + } + + apOfficialPoliciesTableRowClick(policyName: string) { + this.apOfficialPoliciesTable().rowElementWithName(policyName).scrollIntoView().click(); + } + + apCreateBtn(): AsyncButtonPo { + return new AsyncButtonPo('[data-testid="kw-policy-create-finish-button"]', this.self()); + } + + waitForApCreation(interceptName: string, name: string) { + cy.wait(`@${ interceptName }`, { requestTimeout: 15000 }).then(({ response }) => { + expect(response?.statusCode).to.eq(201); + expect(response?.body).to.have.property('id', `default/${ name }`); + expect(response?.body.spec).to.have.property('mode', 'protect'); + expect(response?.body.spec.settings).to.have.property('requireTLS', true); + cy.wait(3000); // eslint-disable-line cypress/no-unnecessary-waiting + }); + } } diff --git a/cypress/e2e/po/side-bars/product-side-nav.po.ts b/cypress/e2e/po/side-bars/product-side-nav.po.ts index e8385610a20..365ac5bd0b6 100644 --- a/cypress/e2e/po/side-bars/product-side-nav.po.ts +++ b/cypress/e2e/po/side-bars/product-side-nav.po.ts @@ -45,6 +45,16 @@ export default class ProductNavPo extends ComponentPo { .click({ force: true }); } + /** + * Navigate to a side menu entry by label (exact match) + */ + navToSideMenuEntryByExactLabel(label: string): Cypress.Chainable { + const regexp = new RegExp(`^${ label }$`); + + return this.self().should('exist').find('.child.nav-type a .label').contains(regexp) + .click({ force: true }); + } + /** * Check existence of menu group by label */ diff --git a/cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts b/cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts index 5c97aa3b4a5..5a2a5328757 100644 --- a/cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts +++ b/cypress/e2e/tests/pages/extensions-compatibility-tests/kubewarden.spec.ts @@ -1,185 +1,277 @@ -// import ExtensionsPagePo from '@/cypress/e2e/po/pages/extensions.po'; +import ExtensionsPagePo from '@/cypress/e2e/po/pages/extensions.po'; import KubewardenPo from '@/cypress/e2e/po/pages/extensions-compatibility-tests/kubewarden.po'; import { NamespaceFilterPo } from '@/cypress/e2e/po/components/namespace-filter.po'; import ChartInstalledAppsPagePo from '@/cypress/e2e/po/pages/chart-installed-apps.po'; +import ProjectsNamespacesPagePo from '@/cypress/e2e/po/pages/explorer/projects-namespaces.po'; +import ProductNavPo from '@/cypress/e2e/po/side-bars/product-side-nav.po'; +import { IngressPagePo } from '@/cypress/e2e/po/pages/explorer/ingress.po'; // import * as jsyaml from 'js-yaml'; -// const EXTENSION_NAME = 'kubewarden'; -// const EXTENSION_VERSION = '2.0.0'; -// const EXTENSION_REPO = 'https://github.com/rancher/kubewarden-ui'; -// const EXTENSION_BRANCH = 'gh-pages'; -// const EXTENSION_CLUSTER_REPO_NAME = 'kubewarden-ui-extension'; +const EXTENSION_NAME = 'kubewarden'; +const EXTENSION_VERSION = '2.0.0'; +const EXTENSION_REPO = 'https://github.com/rancher/kubewarden-ui'; +const EXTENSION_BRANCH = 'gh-pages'; +const EXTENSION_CLUSTER_REPO_NAME = 'kubewarden-ui-extension'; // const EXTENSION_KW_REPO_ADD = 'addKwRepo'; +const RANCHER_CHART_CREATION = 'rancherCreation'; const MAIN_EXTENSION_CHART_CREATION = 'chartCreation'; const MAIN_EXTENSION_CHART_UPGRADE = 'chartUpgrade'; +const DUMMY_NAMESPACE = 'another-dummy-namespace'; +const NAMESPACE_CREATION = 'namespaceCreation'; + +const INGRESS_POLICY_NAME = 'some-ingress-policy-name'; +const AP_CREATION = 'apCreation'; + const kubewardenPo = new KubewardenPo(); const namespacePicker = new NamespaceFilterPo(); const installedApps = new ChartInstalledAppsPagePo('local', 'apps'); +const projectsNamespacesPage = new ProjectsNamespacesPagePo('local'); +const sideNav = new ProductNavPo(); +const ingressPagePo = new IngressPagePo(); describe('Extensions Compatibility spec', { tags: ['@kubewarden', '@adminUser'] }, () => { beforeEach(() => { cy.login(); }); - // it('add extension repository', () => { - // // // This should be in a `before` however is flaky. Move it to an `it` to let cypress retry - // const extensionsPo = new ExtensionsPagePo(); - - // extensionsPo.addExtensionsRepositoryDirectLink(EXTENSION_REPO, EXTENSION_BRANCH, EXTENSION_CLUSTER_REPO_NAME, true); - // }); - - // it('Should install an extension', () => { - // const extensionsPo = new ExtensionsPagePo(); - - // extensionsPo.goTo(); - - // extensionsPo.extensionTabAvailableClick(); - - // // click on install button on card - // extensionsPo.extensionCardInstallClick(EXTENSION_NAME); - // extensionsPo.extensionInstallModal().should('be.visible'); - - // // select version and click install - // extensionsPo.installModalSelectVersionLabel(EXTENSION_VERSION); - // extensionsPo.installModalInstallClick(); - - // // let's check the extension reload banner and reload the page - // extensionsPo.extensionReloadBanner().should('be.visible'); - // extensionsPo.extensionReloadClick(); + // it('add extension repository', () => { + // // // This should be in a `before` however is flaky. Move it to an `it` to let cypress retry + // const extensionsPo = new ExtensionsPagePo(); + + // extensionsPo.addExtensionsRepositoryDirectLink(EXTENSION_REPO, EXTENSION_BRANCH, EXTENSION_CLUSTER_REPO_NAME, true); + // cy.wait(10000); // eslint-disable-line cypress/no-unnecessary-waiting + // }); + + // it('Should install an extension', () => { + // const extensionsPo = new ExtensionsPagePo(); + + // extensionsPo.goTo(); + + // extensionsPo.extensionTabAvailableClick(); + + // // click on install button on card + // extensionsPo.extensionCardInstallClick(EXTENSION_NAME); + // extensionsPo.extensionInstallModal().should('be.visible'); + + // // select version and click install + // extensionsPo.installModalSelectVersionLabel(EXTENSION_VERSION); + // extensionsPo.installModalInstallClick(); + + // // let's check the extension reload banner and reload the page + // extensionsPo.extensionReloadBanner().should('be.visible'); + // extensionsPo.extensionReloadClick(); + + // // make sure extension card is in the installed tab + // extensionsPo.extensionTabInstalledClick(); + // extensionsPo.extensionCardClick(EXTENSION_NAME); + // extensionsPo.extensionDetailsTitle().should('contain', EXTENSION_NAME); + // extensionsPo.extensionDetailsCloseClick(); + // }); + + // it('Should setup all of the needed backend parts', () => { + // cy.intercept('POST', 'v1/catalog.cattle.io.clusterrepos/rancher-charts?action=install').as(RANCHER_CHART_CREATION); + // cy.intercept('POST', 'v1/catalog.cattle.io.clusterrepos/kubewarden-charts?action=install').as(MAIN_EXTENSION_CHART_CREATION); + // cy.intercept('POST', 'v1/catalog.cattle.io.clusterrepos/kubewarden-charts?action=upgrade').as(MAIN_EXTENSION_CHART_UPGRADE); + + // kubewardenPo.goTo(); + // kubewardenPo.waitForTitle('h1', 'Kubewarden'); + + // // we need to change the namespace picker in order for the install check on the list view + // namespacePicker.toggle(); + // namespacePicker.clickOptionByLabel('All Namespaces'); + // namespacePicker.closeDropdown(); + + // // start install steps + // kubewardenPo.startBackendInstallClick(); + + // // 1 - install cert manager + // kubewardenPo.openTerminalClick(); + // kubewardenPo.kubectlShell().executeCommand('kubectl apply -f https://github.com/jetstack/cert-manager/releases/latest/download/cert-manager.yaml', false); + // kubewardenPo.waitForCertManagerToInstall(); + // kubewardenPo.kubectlShell().closeTerminal(); + + // // 2 - Add kubewarden repository + // kubewardenPo.addKwRepoClick(); + // kubewardenPo.waitForKwRepoToBeAdded(); + + // // 3 - Install kubewarden operator + // kubewardenPo.installOperatorBtnClick(); + // kubewardenPo.waitForInstallChartPage('kubewarden-charts', 'kubewarden-controller'); + // kubewardenPo.chartInstallNext(); + // kubewardenPo.genericCheckboxByLabel('Enable Policy Reporter UI').set(); + // kubewardenPo.chartInstallClick(); + // kubewardenPo.chartInstallWaitForInstallationAndCloseTerminal(MAIN_EXTENSION_CHART_CREATION, ['rancher-kubewarden-controller', 'rancher-kubewarden-crds'], 60000); + + // kubewardenPo.goTo(); + // kubewardenPo.waitForTitle('[data-testid="kw-dashboard-title"]', 'Welcome to Kubewarden'); + + // // 4 - add default policy server charts + // kubewardenPo.defaultPolicyServerInstallClick(); + // kubewardenPo.waitForInstallChartPage('kubewarden-charts', 'kubewarden-defaults'); + // kubewardenPo.chartInstallNext(); + // kubewardenPo.genericCheckboxByLabel('Enable recommended policies').set(); + // kubewardenPo.chartInstallClick(); + // kubewardenPo.chartInstallWaitForInstallationAndCloseTerminal(MAIN_EXTENSION_CHART_CREATION, ['rancher-kubewarden-defaults'], 30000); + + // installedApps.goTo(); + // installedApps.waitForPage(); + + // // 5 - Install Tracing parts + // // 5.1 - Open Telemetry Operator as per https://docs.kubewarden.io/next/howtos/telemetry/opentelemetry-qs#install-opentelemetry + // const addOTCommand = `helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts + + // helm install --wait \ + // --namespace open-telemetry \ + // --create-namespace \ + // --version 0.56.0 \ + // --set "manager.collectorImage.repository=otel/opentelemetry-collector-contrib" \ + // my-opentelemetry-operator open-telemetry/opentelemetry-operator`; + + // kubewardenPo.kubectlShell().openTerminal(); + // kubewardenPo.kubectlShell().executeCommand(addOTCommand, false); + // kubewardenPo.genericWaitForAppToInstall('my-opentelemetry-operator'); + + // // 5.2 - Jaeger Operator as per https://docs.kubewarden.io/next/howtos/telemetry/tracing-qs#install-jaeger + // const addJaegerOperatorCommand = `helm repo add jaegertracing https://jaegertracing.github.io/helm-charts + + // helm upgrade -i --wait \ + // --namespace jaeger \ + // --create-namespace \ + // --version 2.49.0 \ + // jaeger-operator jaegertracing/jaeger-operator \ + // --set rbac.clusterRole=true`; + + // kubewardenPo.kubectlShell().openTerminal(); + // kubewardenPo.kubectlShell().executeCommand(addJaegerOperatorCommand, false); + // kubewardenPo.genericWaitForAppToInstall('jaeger-operator'); + + // // 5.3 - Create Jaeger Resource as per https://docs.kubewarden.io/next/howtos/telemetry/tracing-qs#install-jaeger + // const createJaegerResource = `kubectl apply -f - < { + cy.intercept('POST', 'v1/namespaces').as(NAMESPACE_CREATION); + cy.intercept('POST', 'v1/policies.kubewarden.io.admissionpolicies/default').as(AP_CREATION); + // create a new namespace + // create an AP -> keep it protect mode + // prepare a resource to trigger that specific AP + // go to cron job and force run it + // go to a given namespace and check the compliance report to see the result + // projectsNamespacesPage.goTo(); + // projectsNamespacesPage.waitForPage(); + // projectsNamespacesPage.flatListClick(); // easier to trigger a namespace creation + // projectsNamespacesPage.createProjectNamespaceClick(); + // projectsNamespacesPage.name().set(DUMMY_NAMESPACE); + // projectsNamespacesPage.buttonSubmit().click(); + + // kubewardenPo.waitForNamespaceCreation(NAMESPACE_CREATION, DUMMY_NAMESPACE); + + kubewardenPo.goTo(); + kubewardenPo.waitForTitle('[data-testid="kw-dashboard-title"]', 'Welcome to Kubewarden'); + + kubewardenPo.sideMenuNavTo('AdmissionPolicies'); + kubewardenPo.waitForPage(); + + kubewardenPo.createClick(); + // kubewardenPo.addToArtifactHubClick(); + // // let's wait for the whitelisting to do it's thing + // cy.wait(10000); // eslint-disable-line cypress/no-unnecessary-waiting + + kubewardenPo.apOfficialPoliciesTableRowClick('Ingress Policy'); + + kubewardenPo.genericNamespaceInput().toggle(); + kubewardenPo.genericNamespaceInput().clickOptionWithLabel(DUMMY_NAMESPACE); + kubewardenPo.genericNameInput().set(INGRESS_POLICY_NAME); + kubewardenPo.clickGenericTab('[data-testid="btn-Settings"]'); + kubewardenPo.genericCheckboxByLabel('Require TLS').set(); + + // kubewardenPo.apCreateBtn().click(); + // kubewardenPo.waitForApCreation(AP_CREATION, INGRESS_POLICY_NAME); + + // HERE WE'LL NEED TO WAIT FOR THE POLICY TO COME UP! + + // sideNav.navToSideMenuGroupByLabel('Service Discovery'); + // sideNav.navToSideMenuEntryByLabel('Ingresses'); + + // ingressPagePo.waitForPage(); + // ingressPagePo.clickCreate(); + }); - // // make sure extension card is in the installed tab - // extensionsPo.extensionTabInstalledClick(); - // extensionsPo.extensionCardClick(EXTENSION_NAME); - // extensionsPo.extensionDetailsTitle().should('contain', EXTENSION_NAME); - // extensionsPo.extensionDetailsCloseClick(); + // it('Should create a Policy Server via YAML', () => { + // // create a working Policy Server via YAML // }); - it('Should setup all of the needed backend parts', () => { - cy.intercept('POST', 'v1/catalog.cattle.io.clusterrepos/kubewarden-charts?action=install').as(MAIN_EXTENSION_CHART_CREATION); - cy.intercept('POST', 'v1/catalog.cattle.io.clusterrepos/kubewarden-charts?action=upgrade').as(MAIN_EXTENSION_CHART_UPGRADE); - - // kubewardenPo.goTo(); - // kubewardenPo.waitForTitle('h1', 'Kubewarden'); - - // // we need to change the namespace picker in order for the install check on the list view - // namespacePicker.toggle(); - // namespacePicker.clickOptionByLabel('All Namespaces'); - // namespacePicker.closeDropdown(); - - // // start install steps - // kubewardenPo.startBackendInstallClick(); - - // // 1 - install cert manager - // kubewardenPo.openTerminalClick(); - // kubewardenPo.kubectlShell().executeCommand('kubectl apply -f https://github.com/jetstack/cert-manager/releases/latest/download/cert-manager.yaml', false); - // kubewardenPo.waitForCertManagerToInstall(); - // kubewardenPo.kubectlShell().closeTerminal(); - - // // 2 - Add kubewarden repository - // kubewardenPo.addKwRepoClick(); - // kubewardenPo.waitForKwRepoToBeAdded(); - - // // 3 - Install kubewarden operator - // kubewardenPo.installOperatorBtnClick(); - // kubewardenPo.waitForInstallChartPage('kubewarden-charts', 'kubewarden-controller'); - // kubewardenPo.chartInstallNext(); - // kubewardenPo.genericCheckboxByLabel('Enable Policy Reporter UI').set(); - // kubewardenPo.chartInstallClick(); - // kubewardenPo.chartInstallWaitForInstallationAndCloseTerminal(MAIN_EXTENSION_CHART_CREATION, ['rancher-kubewarden-controller', 'rancher-kubewarden-crds'], 40000); - - // kubewardenPo.goTo(); - // kubewardenPo.waitForTitle('[data-testid="kw-dashboard-title"]', 'Welcome to Kubewarden'); - - // // 4 - add default policy server charts - // kubewardenPo.defaultPolicyServerInstallClick(); - // kubewardenPo.waitForInstallChartPage('kubewarden-charts', 'kubewarden-defaults'); - // kubewardenPo.chartInstallNext(); - // kubewardenPo.genericCheckboxByLabel('Enable recommended policies').set(); - // kubewardenPo.chartInstallClick(); - // kubewardenPo.chartInstallWaitForInstallationAndCloseTerminal(MAIN_EXTENSION_CHART_CREATION, ['rancher-kubewarden-defaults']); - - // installedApps.goTo(); - // installedApps.waitForPage(); - - // // 5 - Install Tracing parts - // // 5.1 - Open Telemetry Operator as per https://docs.kubewarden.io/next/howtos/telemetry/opentelemetry-qs#install-opentelemetry - // const addOTCommand = `helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts - - // helm install --wait \ - // --namespace open-telemetry \ - // --create-namespace \ - // --version 0.56.0 \ - // --set "manager.collectorImage.repository=otel/opentelemetry-collector-contrib" \ - // my-opentelemetry-operator open-telemetry/opentelemetry-operator`; - - // kubewardenPo.kubectlShell().openTerminal(); - // kubewardenPo.kubectlShell().executeCommand(addOTCommand, false); - // kubewardenPo.genericWaitForAppToInstall('my-opentelemetry-operator'); - - // // 5.2 - Jaeger Operator as per https://docs.kubewarden.io/next/howtos/telemetry/tracing-qs#install-jaeger - // const addJaegerOperatorCommand = `helm repo add jaegertracing https://jaegertracing.github.io/helm-charts - - // helm upgrade -i --wait \ - // --namespace jaeger \ - // --create-namespace \ - // --version 2.49.0 \ - // jaeger-operator jaegertracing/jaeger-operator \ - // --set rbac.clusterRole=true`; - - // kubewardenPo.kubectlShell().openTerminal(); - // kubewardenPo.kubectlShell().executeCommand(addJaegerOperatorCommand, false); - // kubewardenPo.genericWaitForAppToInstall('jaeger-operator'); - - // // 5.3 - Create Jaeger Resource as per https://docs.kubewarden.io/next/howtos/telemetry/tracing-qs#install-jaeger - // const createJaegerResource = `kubectl apply -f - < { // const extensionsPo = new ExtensionsPagePo();