-
Notifications
You must be signed in to change notification settings - Fork 67
OU-1472: run only changed tests #1134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,62 @@ | ||||||
| #!/bin/bash | ||||||
|
|
||||||
| CHANGED_FILES=$(git diff --name-only origin/main...HEAD) | ||||||
|
|
||||||
| RUN_ALL=false | ||||||
| declare -A TAGS_TO_RUN | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might need to change this into something POSIX compatible, I got the following issue while trying to run on mac: |
||||||
|
|
||||||
| # Create frontend folder to tag map | ||||||
| declare -A FEATURE_MAP | ||||||
| FEATURE_MAP["incidents"]="@cluster-health-analyzer" | ||||||
| FEATURE_MAP["alerts"]="@alerting" | ||||||
| FEATURE_MAP["legacy-dashboards"]="@legacy-dashboards" | ||||||
| FEATURE_MAP["metrics"]="@metrics" | ||||||
| FEATURE_MAP["perses-dashboards"]="@perses-dashboards" | ||||||
| FEATURE_MAP["targets"]="@targets" | ||||||
|
|
||||||
| for FILE in $CHANGED_FILES; do | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure if we have file paths with white spaces, but this will split on white space |
||||||
|
|
||||||
| # Check if any file is outside of web/src/features/ | ||||||
| if [[ ! "$FILE" =~ ^web/src/features/ ]]; then | ||||||
| echo "Global or shared file changed: $FILE" | ||||||
| RUN_ALL=true | ||||||
| break | ||||||
| fi | ||||||
|
|
||||||
| # File is in features and looks like: web/src/features/incidents/components/App.tsx | ||||||
| # awk splits by '/' and grabs the 4th segment | ||||||
| FEATURE_DIR=$(echo "$FILE" | awk -F'/' '{print $4}') | ||||||
| CYPRESS_TAG=${FEATURE_MAP[$FEATURE_DIR]} | ||||||
|
|
||||||
| if [ -n "$CYPRESS_TAG" ]; then | ||||||
| TAGS_TO_RUN["$CYPRESS_TAG"]=1 | ||||||
| else | ||||||
| echo "Error: Unmapped feature directory changed: $FEATURE_DIR" | ||||||
| exit 1 | ||||||
| fi | ||||||
| done | ||||||
|
|
||||||
| if [ "$RUN_ALL" = true ]; then | ||||||
| echo "Changes affect global scope or unmapped features. Running ALL monitoring tests..." | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unmapped features already exits
Suggested change
|
||||||
|
|
||||||
| DEFAULT_TAGS="@alerting @legacy-dashboards @metrics @targets acm-alerting @cluster-health-analyzer @perses-dashboards --@flaky --@xfail" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| npm run test-cypress-monitoring:base -- --env grepTags="${DEFAULT_TAGS}" | ||||||
| else | ||||||
| UNIQUE_TAGS=("${!TAGS_TO_RUN[@]}") | ||||||
|
|
||||||
| if [ ${#UNIQUE_TAGS[@]} -eq 0 ]; then | ||||||
| echo "No relevant source files changed. Skipping tests." | ||||||
| exit 0 | ||||||
| fi | ||||||
|
|
||||||
| FEATURE_TAGS=$( | ||||||
| IFS=" " | ||||||
| echo "${UNIQUE_TAGS[*]}" | ||||||
| ) | ||||||
|
|
||||||
| GREP_TAGS="${FEATURE_TAGS} --@flaky --@xfail" | ||||||
|
|
||||||
| echo "Running specific tests for tags: $GREP_TAGS" | ||||||
|
|
||||||
| npm run test-cypress-monitoring:base -- --env grepTags="${GREP_TAGS}" | ||||||
| fi | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,22 +28,8 @@ | |
| "test:unit": "TZ=UTC jest --config jest.config.js --passWithNoTests", | ||
| "test:unit:ci": "TZ=UTC jest --config jest.config.js --passWithNoTests --maxWorkers=2", | ||
| "test": "npm run cypress:run:ci", | ||
| "test-cypress-console": "./node_modules/.bin/cypress open --browser chrome", | ||
| "test-cypress-console-headless": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless", | ||
| "test-cypress-monitoring": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless --env grepTags='@alerting+@legacy-dashboards+@metrics+@targets --@flaky --@xfail'", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to update the cypress docs with these removals? |
||
| "test-cypress-monitoring-dev": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless --env grepTags='@alerting+@legacy-dashboards+@metrics+@targets --@xfail'", | ||
| "test-cypress-monitoring-bvt": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless --env grepTags='@alerting+@legacy-dashboards+@metrics+@targets --@xfail'", | ||
| "test-cypress-monitoring-regression": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless --env grepTags='@alerting+@legacy-dashboards+@metrics+@targets --@flaky --@xfail'", | ||
| "test-cypress-alerts": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless --env grepTags='@alerting --@flaky --@xfail'", | ||
| "test-cypress-metrics": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless --env grepTags='@metrics --@flaky --@xfail'", | ||
| "test-cypress-dashboards": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless --env grepTags='@legacy-dashboards --@flaky --@xfail'", | ||
| "test-cypress-coo": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless --env grepTags='@acm-alerting+@perses-dashboards+@cluster-health-analyzer --@flaky --@xfail'", | ||
| "test-cypress-coo-bvt": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless --env grepTags='@acm-alerting+@perses-dashboards+@cluster-health-analyzer --@xfail'", | ||
| "test-cypress-incidents": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless --env grepTags='@cluster-health-analyzer --@flaky --@xfail'", | ||
| "test-cypress-incidents-e2e": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless --env grepTags='@cluster-health-analyzer --@flaky --@xfail'", | ||
| "test-cypress-perses-dev": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless --env grepTags='@perses-dashboards --@xfail'", | ||
| "test-cypress-perses": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless --env grepTags='@perses-dashboards --@smoke --@flaky --@xfail'", | ||
| "test-cypress-perses-ivt": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless --env grepTags='@perses-dashboards --@smoke --@flaky --@xfail'", | ||
| "test-cypress-monitoring": "../scripts/run-selective-e2e.sh", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this script in a different PR or should be |
||
| "test-cypress-monitoring:base": "node --max-old-space-size=4096 ./node_modules/.bin/cypress run --browser chrome --headless", | ||
| "ts-node": "ts-node -O '{\"module\":\"commonjs\"}'" | ||
| }, | ||
| "dependencies": { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The target branch might be different we should provide it from env defaulting to main
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should add error handling, in shallow checkouts the main branch might not exist.