Skip to content

Commit

Permalink
saving WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
aalves08 committed Jul 24, 2024
1 parent e108b95 commit 887d38d
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 13 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/extensions-compatibility-tests.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
45 changes: 33 additions & 12 deletions scripts/e2e-docker-start
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 887d38d

Please sign in to comment.