diff --git a/.circleci/config.yml b/.circleci/config.yml index 59d0a86634dd2..0e0d47e205f44 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -167,6 +167,16 @@ jobs: - e2e-test: test_path: e2e-tests/production-runtime + starters_validate: + executor: node + steps: + - checkout + - run: ./scripts/assert-changed-files.sh "starters/*|.circleci/*" + - <<: *restore_cache + - <<: *install_node_modules + - <<: *persist_cache + - run: sh ./scripts/clone-and-validate.sh starters false + starters_publish: executor: node steps: @@ -210,6 +220,8 @@ workflows: <<: *e2e-test-workflow - e2e_tests_production_runtime: <<: *e2e-test-workflow + - starters_validate: + <<: *ignore_master - starters_publish: filters: branches: diff --git a/scripts/clone-folder.sh b/scripts/clone-and-validate.sh similarity index 58% rename from scripts/clone-folder.sh rename to scripts/clone-and-validate.sh index 21e8fa52a7a30..7280ddc731ccd 100755 --- a/scripts/clone-folder.sh +++ b/scripts/clone-and-validate.sh @@ -1,8 +1,14 @@ #!/bin/bash FOLDER=$1 +CLONE=$2 +IS_CI="${CI:-false}" BASE=$(pwd) COMMIT_MESSAGE=$(git log -1 --pretty=%B) +if [ "$IS_CI" = true ]; then + sudo apt-get update && sudo apt-get install jq +fi + for folder in $FOLDER/*; do [ -d "$folder" ] || continue # only directories cd $BASE @@ -15,10 +21,22 @@ for folder in $FOLDER/*; do git clone --depth 1 https://$GITHUB_API_TOKEN@github.com/gatsbyjs/$NAME.git $CLONE_DIR cd $CLONE_DIR find . | grep -v ".git" | grep -v "^\.*$" | xargs rm -rf # delete all files (to handle deletions in monorepo) - cp -r $BASE/$folder/. . # copy all content - git add . - git commit --message "$COMMIT_MESSAGE" - git push origin master + cp -r $BASE/$folder/. . + + # validate + npm audit + npm install + npm run build + + # sync to read-only clones + if [ "$CLONE" != false ]; then + rm -rf yarn.lock + yarn import # generate a new yarn.lock file based on package-lock.json + + git add . + git commit --message "$COMMIT_MESSAGE" + git push origin master + fi cd $BASE done