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 1445fc79a01..1dfb47d31bc 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