From b96ebb0d7a1248e522f2197e9238e694e6d4ad68 Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Fri, 26 Jun 2020 17:52:17 -0400 Subject: [PATCH 1/5] trying to halt Applitools job if env variable is not set --- circle.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 6930bcbb..4c61902d 100644 --- a/circle.yml +++ b/circle.yml @@ -220,7 +220,15 @@ workflows: - Install # each example installs "cypress-react-unit-test" as a local dependency (symlink) install-command: npm install - verify-command: echo 'Already verified' + # to correctly run this job, we need Applitools token + # external pull requests do not have environment variables set + # thus the job will always fail. Let's skip this job if the + # environment variable is missing + verify-command: | + if [ -n "$APPLITOOLS_API_KEY_FOO" ]; then + echo "Skipping Applitools test job, missing environment variable APPLITOOLS_API_KEY" + circleci-agent step halt + fi no-workspace: true working_directory: examples/visual-testing-with-applitools command: npm test From ce4e71c651356f203da900530d869ce88944305d Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Fri, 26 Jun 2020 18:22:23 -0400 Subject: [PATCH 2/5] move env variable check to the command --- circle.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/circle.yml b/circle.yml index 4c61902d..c7b099f6 100644 --- a/circle.yml +++ b/circle.yml @@ -220,18 +220,19 @@ workflows: - Install # each example installs "cypress-react-unit-test" as a local dependency (symlink) install-command: npm install + verify-command: echo 'Already verified' + no-workspace: true + working_directory: examples/visual-testing-with-applitools # to correctly run this job, we need Applitools token # external pull requests do not have environment variables set # thus the job will always fail. Let's skip this job if the # environment variable is missing - verify-command: | + command: | if [ -n "$APPLITOOLS_API_KEY_FOO" ]; then echo "Skipping Applitools test job, missing environment variable APPLITOOLS_API_KEY" circleci-agent step halt fi - no-workspace: true - working_directory: examples/visual-testing-with-applitools - command: npm test + npm test store_artifacts: true - cypress/run: From ed0b99011f60684f7c68d9a19a582a9398575dbe Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Fri, 26 Jun 2020 18:40:12 -0400 Subject: [PATCH 3/5] use -z --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index c7b099f6..600b147d 100644 --- a/circle.yml +++ b/circle.yml @@ -228,7 +228,7 @@ workflows: # thus the job will always fail. Let's skip this job if the # environment variable is missing command: | - if [ -n "$APPLITOOLS_API_KEY_FOO" ]; then + if [ -z "$APPLITOOLS_API_KEY_FOO" ]; then echo "Skipping Applitools test job, missing environment variable APPLITOOLS_API_KEY" circleci-agent step halt fi From 7ccba7ac1ec174cfcba815456cc7894b8a4ff2db Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Sat, 27 Jun 2020 07:03:48 -0400 Subject: [PATCH 4/5] skip npm test --- circle.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/circle.yml b/circle.yml index 600b147d..bdf86bfb 100644 --- a/circle.yml +++ b/circle.yml @@ -230,9 +230,9 @@ workflows: command: | if [ -z "$APPLITOOLS_API_KEY_FOO" ]; then echo "Skipping Applitools test job, missing environment variable APPLITOOLS_API_KEY" - circleci-agent step halt + else + npm test fi - npm test store_artifacts: true - cypress/run: From ed7e84b24665d1e67c85b2a57751e5c5da3e386e Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Sat, 27 Jun 2020 08:05:40 -0400 Subject: [PATCH 5/5] use correct var --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index bdf86bfb..4dbe3615 100644 --- a/circle.yml +++ b/circle.yml @@ -228,7 +228,7 @@ workflows: # thus the job will always fail. Let's skip this job if the # environment variable is missing command: | - if [ -z "$APPLITOOLS_API_KEY_FOO" ]; then + if [ -z "$APPLITOOLS_API_KEY" ]; then echo "Skipping Applitools test job, missing environment variable APPLITOOLS_API_KEY" else npm test