From a5ec8eb455e6cd3be3508cef6267d5614bde1c2e Mon Sep 17 00:00:00 2001 From: endiliey Date: Thu, 5 Jul 2018 13:57:29 +0800 Subject: [PATCH 01/10] Only test/build website if docs/website are changed --- .circleci/config.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 13d26caf46fd..19c5704c25c1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,6 +13,11 @@ aliases: - &website command: | + WEBSITE_CHANGED=$(git diff-tree --no-commit-id --name-only -r HEAD | grep -E -c "(^docs\/.*)|(^website\/.*)") + if [[ $WEBSITE_CHANGED == 0 ]]; then + echo "No relevant website files has changed" + exit 0; + fi if [[ $CIRCLE_PROJECT_USERNAME == "facebook" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then # configure Docusaurus bot git config --global user.email "docusaurus-bot@users.noreply.github.com" From 56dfdd243405e8bac4bb83c995f3f346bc21c7f7 Mon Sep 17 00:00:00 2001 From: endiliey Date: Thu, 5 Jul 2018 14:46:55 +0800 Subject: [PATCH 02/10] Refactor into website.sh --- .circleci/config.yml | 34 +++------------------------------- .circleci/website.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 31 deletions(-) create mode 100644 .circleci/website.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 19c5704c25c1..94d9d4cdc314 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,36 +10,6 @@ aliases: - node_modules - website/node_modules key: v2-dependencies-{{ .Branch }}-{{ checksum "yarn.lock" }} - - - &website - command: | - WEBSITE_CHANGED=$(git diff-tree --no-commit-id --name-only -r HEAD | grep -E -c "(^docs\/.*)|(^website\/.*)") - if [[ $WEBSITE_CHANGED == 0 ]]; then - echo "No relevant website files has changed" - exit 0; - fi - if [[ $CIRCLE_PROJECT_USERNAME == "facebook" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then - # configure Docusaurus bot - git config --global user.email "docusaurus-bot@users.noreply.github.com" - git config --global user.name "Website Deployment Script" - echo "machine github.com login docusaurus-bot password $DOCUSAURUS_PUBLISH_TOKEN" > ~/.netrc - # install Docusaurus and generate file of English strings - yarn && cd website && yarn write-translations - # crowdin install - sudo apt-get update - sudo apt-get install default-jre rsync - wget https://artifacts.crowdin.com/repo/deb/crowdin.deb -O crowdin.deb - sudo dpkg -i crowdin.deb - sleep 5 - # translations upload/download - yarn crowdin-upload - yarn crowdin-download - # build and publish website - GIT_USER=docusaurus-bot USE_SSH=false yarn publish-gh-pages - else - echo "Skipping deploy. Test website build" - cd website && yarn && yarn build - fi - &filter-ignore-gh-pages branches: @@ -145,7 +115,9 @@ jobs: - restore-cache: *restore-cache - run: yarn --no-progress - save-cache: *save-cache - - run: *website + - run: + command: | + .circleci/website.sh # Workflows enables us to run multiple jobs in parallel workflows: diff --git a/.circleci/website.sh b/.circleci/website.sh new file mode 100644 index 000000000000..43fa2ae99f61 --- /dev/null +++ b/.circleci/website.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +WEBSITE_CHANGED=$(git diff-tree --no-commit-id --name-only -r HEAD | grep -E -c "(^docs\/.*)|(^website\/.*)") +if [[ $WEBSITE_CHANGED == 0 ]]; then + echo "No relevant website files has changed" + exit 0; +else + if [[ $CIRCLE_PROJECT_USERNAME == "facebook" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then + # configure Docusaurus bot + git config --global user.email "docusaurus-bot@users.noreply.github.com" + git config --global user.name "Website Deployment Script" + echo "machine github.com login docusaurus-bot password $DOCUSAURUS_PUBLISH_TOKEN" > ~/.netrc + # install Docusaurus and generate file of English strings + yarn && cd website && yarn write-translations + # crowdin install + sudo apt-get update + sudo apt-get install default-jre rsync + wget https://artifacts.crowdin.com/repo/deb/crowdin.deb -O crowdin.deb + sudo dpkg -i crowdin.deb + sleep 5 + # translations upload/download + yarn crowdin-upload + yarn crowdin-download + # build and publish website + GIT_USER=docusaurus-bot USE_SSH=false yarn publish-gh-pages + else + echo "Skipping deploy. Test website build" + cd website && yarn && yarn build + fi +fi \ No newline at end of file From 234b52b73feedc169ec7c73e29bde492c24c796f Mon Sep 17 00:00:00 2001 From: endiliey Date: Thu, 5 Jul 2018 14:56:56 +0800 Subject: [PATCH 03/10] nits --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 94d9d4cdc314..c2858568fc17 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -115,9 +115,9 @@ jobs: - restore-cache: *restore-cache - run: yarn --no-progress - save-cache: *save-cache - - run: - command: | - .circleci/website.sh + - run: + name: Test or Deploy Jest Website + command: ./.circleci/website.sh # Workflows enables us to run multiple jobs in parallel workflows: From f14584bcc4fac63331b84d6fc255236f12775a32 Mon Sep 17 00:00:00 2001 From: endiliey Date: Thu, 5 Jul 2018 15:07:52 +0800 Subject: [PATCH 04/10] chmod executable :) --- .circleci/website.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 .circleci/website.sh diff --git a/.circleci/website.sh b/.circleci/website.sh old mode 100644 new mode 100755 index 43fa2ae99f61..4f5f76ec981f --- a/.circleci/website.sh +++ b/.circleci/website.sh @@ -23,8 +23,8 @@ else yarn crowdin-download # build and publish website GIT_USER=docusaurus-bot USE_SSH=false yarn publish-gh-pages - else + else echo "Skipping deploy. Test website build" cd website && yarn && yarn build - fi + fi fi \ No newline at end of file From a4de210c506b8796dbbd35157a6b2307cc96f831 Mon Sep 17 00:00:00 2001 From: endiliey Date: Thu, 5 Jul 2018 22:16:46 +0800 Subject: [PATCH 05/10] add more echo strings --- .circleci/website.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/website.sh b/.circleci/website.sh index 4f5f76ec981f..974ebf26bbde 100755 --- a/.circleci/website.sh +++ b/.circleci/website.sh @@ -2,7 +2,7 @@ WEBSITE_CHANGED=$(git diff-tree --no-commit-id --name-only -r HEAD | grep -E -c "(^docs\/.*)|(^website\/.*)") if [[ $WEBSITE_CHANGED == 0 ]]; then - echo "No relevant website files has changed" + echo "Skipping deploy & test. No relevant website files has changed" exit 0; else if [[ $CIRCLE_PROJECT_USERNAME == "facebook" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then From 36d421b637f41bb1aea1a6bd0ae0af203280e80e Mon Sep 17 00:00:00 2001 From: endiliey Date: Thu, 5 Jul 2018 22:30:30 +0800 Subject: [PATCH 06/10] review --- .circleci/website.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.circleci/website.sh b/.circleci/website.sh index 974ebf26bbde..8d772544ae01 100755 --- a/.circleci/website.sh +++ b/.circleci/website.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + WEBSITE_CHANGED=$(git diff-tree --no-commit-id --name-only -r HEAD | grep -E -c "(^docs\/.*)|(^website\/.*)") if [[ $WEBSITE_CHANGED == 0 ]]; then echo "Skipping deploy & test. No relevant website files has changed" @@ -27,4 +29,4 @@ else echo "Skipping deploy. Test website build" cd website && yarn && yarn build fi -fi \ No newline at end of file +fi From 6eb2de159184c56fa54d775a313e56e91358ccc3 Mon Sep 17 00:00:00 2001 From: endiliey Date: Thu, 5 Jul 2018 22:35:02 +0800 Subject: [PATCH 07/10] refactor --- .circleci/website.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.circleci/website.sh b/.circleci/website.sh index 8d772544ae01..32d405a2b35e 100755 --- a/.circleci/website.sh +++ b/.circleci/website.sh @@ -2,10 +2,9 @@ set -e -WEBSITE_CHANGED=$(git diff-tree --no-commit-id --name-only -r HEAD | grep -E -c "(^docs\/.*)|(^website\/.*)") -if [[ $WEBSITE_CHANGED == 0 ]]; then +FILES_CHANGED=$(git diff-tree --no-commit-id --name-only -r HEAD) +if grep -E "(^docs\/.*)|(^website\/.*)" $FILES_CHANGED; then echo "Skipping deploy & test. No relevant website files has changed" - exit 0; else if [[ $CIRCLE_PROJECT_USERNAME == "facebook" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then # configure Docusaurus bot From f677bafb8e56d168f444f273915b47640afe9638 Mon Sep 17 00:00:00 2001 From: endiliey Date: Thu, 5 Jul 2018 22:52:09 +0800 Subject: [PATCH 08/10] fix & nits --- .circleci/website.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.circleci/website.sh b/.circleci/website.sh index 32d405a2b35e..78e4f162df7c 100755 --- a/.circleci/website.sh +++ b/.circleci/website.sh @@ -2,10 +2,11 @@ set -e -FILES_CHANGED=$(git diff-tree --no-commit-id --name-only -r HEAD) -if grep -E "(^docs\/.*)|(^website\/.*)" $FILES_CHANGED; then - echo "Skipping deploy & test. No relevant website files has changed" +git diff-tree --no-commit-id --name-only -r HEAD > files_changed.txt +if ! grep -E "(^docs\/.*)|(^website\/.*)" files_changed.txt; then + echo "Skipping deploy & test. No relevant website files have changed" else + echo "Relevant website files have changed" if [[ $CIRCLE_PROJECT_USERNAME == "facebook" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then # configure Docusaurus bot git config --global user.email "docusaurus-bot@users.noreply.github.com" From 031b646ae9d34a17d6a5bc7009961adf122a0946 Mon Sep 17 00:00:00 2001 From: endiliey Date: Thu, 5 Jul 2018 23:29:32 +0800 Subject: [PATCH 09/10] rm -rf sleep 5 --- .circleci/website.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/website.sh b/.circleci/website.sh index 78e4f162df7c..2c3e5a3c7b75 100755 --- a/.circleci/website.sh +++ b/.circleci/website.sh @@ -19,7 +19,6 @@ else sudo apt-get install default-jre rsync wget https://artifacts.crowdin.com/repo/deb/crowdin.deb -O crowdin.deb sudo dpkg -i crowdin.deb - sleep 5 # translations upload/download yarn crowdin-upload yarn crowdin-download From 4cb2bc334a4a2a667ce6bafa1c7f5631d2445605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Thu, 5 Jul 2018 22:28:00 +0200 Subject: [PATCH 10/10] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1755a44ac9c0..eb4161f43554 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - `[tests]` Improve stability of `yarn test` on Windows ([#6534](https://github.com/facebook/jest/pull/6534)) - `[*]` Transpile object shorthand into Node 4 compatible syntax ([#6582](https://github.com/facebook/jest/pull/6582)) - `[*]` Update all legacy links to jestjs.io ([#6622](https://github.com/facebook/jest/pull/6622)) +- `[website]` Only test/deploy website if relevant files are changed ([#6626](https://github.com/facebook/jest/pull/6626)) ## 23.2.0