Skip to content

Commit 33096d5

Browse files
committed
Use cypress/package.json for CI instead of the full monorepo
The root workspace install pulls in Vue, webpack, @rancher/components and hundreds of transitive deps that tests never use, and regularly triggers yarn hoisting bugs on release branches. This switches to installing from cypress/package.json which only has what the test runner actually needs. A symlink from the project root lets Cypress 11 find ts-node and typescript for config transpilation. The overlay now brings cypress/package.json and qase.ts from master but leaves cypress/support alone so release branches keep their own API commands and page objects. Also adds an ERR trap to all three scripts so failures log the exact command and line number instead of dying silently.
1 parent 0e59d4d commit 33096d5

5 files changed

Lines changed: 498 additions & 140 deletions

File tree

cypress/jenkins/cypress.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
#!/bin/bash
22

33
set -e
4+
trap 'echo "FAILED at line $LINENO: $BASH_COMMAND (exit $?)"' ERR
45

56
# Source shared utilities relative to the script's location
67
source "$(dirname "$0")/utils.sh"
78

89
pwd
910
cd "dashboard"
1011

12+
# Use test deps from cypress/node_modules
13+
export NODE_PATH="${PWD}/cypress/node_modules:${NODE_PATH:-}"
14+
export PATH="${PWD}/cypress/node_modules/.bin:${PATH}"
15+
1116
kubectl version --client=true
1217
kubectl get nodes
1318

@@ -46,9 +51,9 @@ fi
4651
set +e
4752

4853
if [ -n "$PERCY_TOKEN" ]; then
49-
npx --no-install percy exec -q -- cypress run --browser chrome --config-file cypress/jenkins/cypress.config.jenkins.ts "${SPEC_ARG[@]}"
54+
percy exec -q -- cypress run --browser chrome --config-file cypress/jenkins/cypress.config.jenkins.ts "${SPEC_ARG[@]}"
5055
else
51-
npx --no-install cypress run --browser chrome --config-file cypress/jenkins/cypress.config.jenkins.ts "${SPEC_ARG[@]}"
56+
cypress run --browser chrome --config-file cypress/jenkins/cypress.config.jenkins.ts "${SPEC_ARG[@]}"
5257
fi
5358
EXIT_CODE=$?
5459
set -e

cypress/jenkins/init.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

33
set -e
4+
trap 'echo "FAILED at line $LINENO: $BASH_COMMAND (exit $?)"' ERR
45

56
# Source shared utilities
67
source cypress/jenkins/utils.sh

cypress/jenkins/run.sh

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
shopt -s extglob
44
set -e
5+
trap 'echo "FAILED at line $LINENO: $BASH_COMMAND (exit $?)"' ERR
56

67
# Source the local configuration file to generate .env
78
source cypress/jenkins/configure.sh
@@ -63,7 +64,7 @@ build_image() {
6364
if [ "${target_branch}" != "master" ]; then
6465
echo "Overlaying cypress/jenkins and dependencies from master onto ${target_branch}"
6566
git fetch origin master
66-
git checkout origin/master -- cypress/jenkins cypress/support package.json yarn.lock cypress.config.ts || true
67+
git checkout origin/master -- cypress/jenkins cypress/package.json cypress/support/qase.ts package.json yarn.lock cypress.config.ts || true
6768
fi
6869
cd "${HOME}"
6970

@@ -92,16 +93,24 @@ build_image() {
9293
cd "${HOME}"/dashboard
9394

9495
npm install -g yarn@"${YARN_VERSION}"
95-
yarn config set ignore-engines true --silent
9696

97-
yarn install --frozen-lockfile
97+
# Install only test dependencies from cypress/package.json
98+
# This skips the full dashboard monorepo (Vue, webpack, @rancher/components)
99+
cd cypress
100+
echo "Installing deps from $(pwd)/package.json"
101+
yarn install
102+
cd ..
103+
104+
# Symlink so Cypress 11 can resolve ts-node/typescript from the project root
105+
# (Cypress uses require.resolve with { paths: [projectRoot] } which ignores NODE_PATH)
106+
ln -sf cypress/node_modules node_modules
98107

99108
# Debugging node_modules
100-
if [ -d "node_modules/cypress-multi-reporters" ]; then
101-
echo "Reporter found in dashboard/node_modules"
109+
if [ -d "cypress/node_modules/cypress-multi-reporters" ]; then
110+
echo "Reporter found in cypress/node_modules"
102111
else
103-
echo "ERROR: Reporter NOT found in dashboard/node_modules"
104-
for module_path in node_modules/*cypress*; do
112+
echo "ERROR: Reporter NOT found in cypress/node_modules"
113+
for module_path in cypress/node_modules/*cypress*; do
105114
[ -e "${module_path}" ] || continue
106115
basename "${module_path}"
107116
done
@@ -234,7 +243,7 @@ elif [ "${RANCHER_TYPE:-existing}" = "recurring" ]; then
234243
fi
235244

236245
cd "${HOME}/dashboard" || exit 1
237-
./node_modules/.bin/jrm "${HOME}/dashboard/results.xml" "cypress/jenkins/reports/junit/junit-*" || true
246+
./cypress/node_modules/.bin/jrm "${HOME}/dashboard/results.xml" "cypress/jenkins/reports/junit/junit-*" || true
238247

239248
if [ -s "${HOME}/dashboard/results.xml" ]; then
240249
echo "cypress_exit_code=${exit_code}"

cypress/package.json

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
},
3030
"dependencies": {
3131
"@cypress/code-coverage": "3.10.4",
32-
"@cypress/grep": "3.1.5",
32+
"@cypress/grep": "4.1.1",
3333
"@cypress/vue": "5.0.5",
3434
"@cypress/webpack-dev-server": "3.4.1",
35-
"@percy/cli": "1.30.7",
35+
"@percy/cli": "1.31.8",
3636
"@percy/cypress": "3.1.6",
3737
"axe-core": "4.10.2",
3838
"axe-html-reporter": "2.2.11",
@@ -41,15 +41,22 @@
4141
"cypress-axe": "1.6.0",
4242
"cypress-delete-downloads-folder": "0.0.4",
4343
"cypress-mochawesome-reporter": "3.8.2",
44+
"cypress-multi-reporters": "1.6.4",
45+
"cypress-qase-reporter": "3.0.0",
4446
"cypress-real-events": "1.14.0",
4547
"cypress-terminal-report": "^7.2.0",
4648
"dotenv": "^10.0.0",
4749
"dotenv-expand": "^5.1.0",
48-
"sha.js": "^2.4.12"
49-
},
50-
"devDependencies": {
51-
"typescript": "^5.9.3"
50+
"find-test-names": "1.29.19",
51+
"globby": "11.1.0",
52+
"junit-report-merger": "9.0.3",
53+
"mocha-junit-reporter": "2.2.1",
54+
"sha.js": "^2.4.12",
55+
"ts-node": "10.9.2",
56+
"typescript": "^5.9.3",
57+
"ws": "8.18.0"
5258
},
59+
"devDependencies": {},
5360
"repository": {
5461
"type": "git",
5562
"url": "https://github.com/rancher/dashboard.git",

0 commit comments

Comments
 (0)