Speed-up testing time for Cypress in CI/CD (#4042)

* Added an environment variable to disable projects cleanup on CI/CD, improve performances

* revert DISABLE_PROJECT_CLEANUP to be 0 by default

Co-authored-by: Kush Trivedi <44091822+kushthedude@users.noreply.github.com>
This commit is contained in:
Florian Giroud 2021-07-08 14:13:55 +02:00 committed by GitHub
parent 21759b4565
commit 1df51b6b58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 3 deletions

View File

@ -179,6 +179,8 @@ Cypress execution can be configured with environment variables, they can be decl
Available variables are Available variables are
- OPENREFINE_URL, determine on which scheme://url:port to access OpenRefine, default to http://localhost:333 - OPENREFINE_URL, determine on which scheme://url:port to access OpenRefine, default to http://localhost:333
- DISABLE_PROJECT_CLEANUP, If set to 1, projects will not be deleted after each run. Default to 0 to keep the OpenRefine instance clean
Cypress contains [exaustive documentation](https://docs.cypress.io/guides/guides/environment-variables.html#Setting) about configuration, but here are two simple ways to configure the execution of the tests: Cypress contains [exaustive documentation](https://docs.cypress.io/guides/guides/environment-variables.html#Setting) about configuration, but here are two simple ways to configure the execution of the tests:

View File

@ -6,6 +6,8 @@
"openMode": 0 "openMode": 0
}, },
"env": { "env": {
"OPENREFINE_URL": "http://localhost:3333" "OPENREFINE_URL": "http://localhost:3333",
"DISABLE_PROJECT_CLEANUP": 0
} }
} }

View File

@ -33,7 +33,11 @@ beforeEach(() => {
}); });
afterEach(() => { afterEach(() => {
// DISABLE_PROJECT_CLEANUP is used to disable projects deletion
// Mostly used in CI/CD for performances
if(parseInt(Cypress.env('DISABLE_PROJECT_CLEANUP')) != 1){
cy.cleanupProjects(); cy.cleanupProjects();
}
}); });
before(() => { before(() => {

2
refine
View File

@ -526,7 +526,7 @@ ui_tests() {
# Cypress needs a unique group id # Cypress needs a unique group id
# We're hashing the list of files to generate such Group Id # We're hashing the list of files to generate such Group Id
CYPRESS_GROUP=$(echo $CYPRESS_BROWSER$CYPRESS_SPECS | shasum) CYPRESS_GROUP=$(echo $CYPRESS_BROWSER$CYPRESS_SPECS | shasum)
CYPRESS_RUN_CMD="yarn --cwd ./main/tests/cypress run cypress run --spec "$CYPRESS_SPECS" --browser $CYPRESS_BROWSER --group "$CYPRESS_GROUP" --headless --quiet --reporter list --env OPENREFINE_URL=http://$REFINE_HOST_INTERNAL:$REFINE_PORT" CYPRESS_RUN_CMD="yarn --cwd ./main/tests/cypress run cypress run --spec "$CYPRESS_SPECS" --browser $CYPRESS_BROWSER --group "$CYPRESS_GROUP" --headless --quiet --reporter list --env DISABLE_PROJECT_CLEANUP=1,OPENREFINE_URL=http://$REFINE_HOST_INTERNAL:$REFINE_PORT"
if [ "$CYPRESS_RECORD" = "1" ] ; then if [ "$CYPRESS_RECORD" = "1" ] ; then
# if tests are recorded, project id is added to env vars, and --record flag is added to the cmd-line # if tests are recorded, project id is added to env vars, and --record flag is added to the cmd-line
export CYPRESS_PROJECT_ID=$CYPRESS_PROJECT_ID export CYPRESS_PROJECT_ID=$CYPRESS_PROJECT_ID