Skip to content
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

feat(ci): add a validation step for starters #10696

Merged
merged 8 commits into from
Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -210,6 +220,8 @@ workflows:
<<: *e2e-test-workflow
- e2e_tests_production_runtime:
<<: *e2e-test-workflow
- starters_validate:
<<: *ignore_master
- starters_publish:
filters:
branches:
Expand Down
26 changes: 22 additions & 4 deletions scripts/clone-folder.sh → scripts/clone-and-validate.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -15,10 +21,22 @@ for folder in $FOLDER/*; do
git clone --depth 1 https://[email protected]/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