From 9b1326134d90cf876f944833d6757cb77d641f90 Mon Sep 17 00:00:00 2001 From: Hector Ramos Date: Wed, 11 Oct 2017 18:47:57 -0700 Subject: [PATCH 1/5] Restore Danger on Circle CI 2.0 --- .circleci/config.yml | 142 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 120 insertions(+), 22 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cfc1eb70187d99..634a5008fa8e63 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -19,15 +19,16 @@ aliases: - website/node_modules key: v1-website-dependencies-{{ .Branch }}-{{ checksum "website/package.json" }} - - &restore-cache-danger + - &restore-cache-analysis keys: - - v1-danger-dependencies-{{ .Branch }}-{{ checksum "danger/package.json" }} + - v1-analysis-dependencies-{{ .Branch }}-{{ checksum "package.json" }}{{ checksum "danger/package.json" }} # Fallback in case checksum fails - - v1-danger-dependencies-{{ .Branch }}- - - &save-cache-danger + - v1-analysis-dependencies-{{ .Branch }}- + - &save-cache-analysis paths: - danger/node_modules - key: v1-danger-dependencies-{{ .Branch }}-{{ checksum "danger/package.json" }} + - node_modules + key: v1-analysis-dependencies-{{ .Branch }}-{{ checksum "package.json" }}{{ checksum "danger/package.json" }} - &restore-cache-android-packages keys: @@ -90,21 +91,16 @@ jobs: - image: circleci/node:8 steps: - checkout - - run: npm install --no-package-lock + - run: + name: Install Dependencies + command: | + npm config set spin=false + npm config set progress=false + npm install --no-package-lock - run: | npm test -- --maxWorkers=2 npm run lint npm run flow -- check -# eslint - doesn't run on non-PR builds - - run: - name: Analyze Code - command: | - if [ -n "$CIRCLE_PR_NUMBER" ]; then - npm install github@0.2.4 - cat <(echo eslint; npm run lint --silent -- --format=json; echo flow; npm run flow --silent -- check --json) | GITHUB_TOKEN="af6ef0d15709bc91d""06a6217a5a826a226fb57b7" CI_USER=$CIRCLE_PROJECT_USERNAME CI_REPO=$CIRCLE_PROJECT_REPONAME PULL_REQUEST_NUMBER=$CIRCLE_PR_NUMBER node bots/code-analysis-bot.js - else - echo "Skipping code analysis." - fi test-node-6: <<: *defaults @@ -112,7 +108,12 @@ jobs: - image: circleci/node:6.11.0 steps: - checkout - - run: npm install + - run: + name: Install Dependencies + command: | + npm config set spin=false + npm config set progress=false + npm install - run: | npm test -- --maxWorkers=2 npm run lint @@ -124,12 +125,17 @@ jobs: - image: circleci/node:4.8.4 steps: - checkout - - run: npm install + - run: + name: Install Dependencies + command: | + npm config set spin=false + npm config set progress=false + npm install - run: | npm test -- --maxWorkers=2 npm run lint npm run flow -- check - + test-website: <<: *defaults docker: @@ -140,6 +146,8 @@ jobs: name: Install Dependencies command: | cd website + npm config set spin=false + npm config set progress=false npm install --no-package-lock - run: name: Test Website @@ -160,6 +168,8 @@ jobs: name: Install Dependencies command: | cd website + npm config set spin=false + npm config set progress=false npm install --no-package-lock - run: name: Build and Deploy Static Website @@ -168,7 +178,6 @@ jobs: git config --global user.email "reactjs-bot@users.noreply.github.com" git config --global user.name "Website Deployment Script" echo "machine github.com login reactjs-bot password $GITHUB_TOKEN" > ~/.netrc - echo "Deploying website..." cd website && GIT_USER=reactjs-bot npm run gh-pages else @@ -181,7 +190,12 @@ jobs: - image: circleci/node:8 steps: - checkout - - run: npm install --no-package-lock + - run: + name: Install Dependencies + command: | + npm config set spin=false + npm config set progress=false + npm install --no-package-lock - run: name: Build JavaScript Bundle command: node local-cli/cli.js bundle --max-workers 2 --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js @@ -258,7 +272,12 @@ jobs: command: | curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt-get install -y nodejs - - run: npm install + - run: + name: Install Dependencies + command: | + npm config set spin=false + npm config set progress=false + npm install --no-package-lock # - restore-cache: *restore-cache-watchman # - run: # name: Install Watchman Dependencies @@ -346,6 +365,70 @@ jobs: - store_artifacts: path: ~/junit + analyze-pull-request: + <<: *defaults + docker: + - image: circleci/node:8 + steps: + - checkout + - restore-cache: *restore-cache-analysis + - run: + name: Install Dependencies + command: | + if [ -n "$CIRCLE_PULL_REQUEST" ]; then + npm config set spin=false + npm config set progress=false + npm install --no-package-lock + npm install github@0.2.4 + cd danger + npm install --no-package-lock + else + echo "Skipping dependency installation." + fi + - save-cache: *save-cache-analysis + - run: + name: Analyze Pull Request + command: | + if [ -n "$CIRCLE_PULL_REQUEST" ]; then + cd danger &&DANGER_GITHUB_API_TOKEN="e622517d9f1136ea8900""07c6373666312cdfaa69" npm run danger + else + echo "Skipping pull request analysis." + fi + when: always + - run: + name: Analyze Code + command: | + if [ -n "$CIRCLE_PULL_REQUEST" ]; then + cat <(echo eslint; npm run lint --silent -- --format=json; echo flow; npm run flow --silent -- check --json) | GITHUB_TOKEN="af6ef0d15709bc91d""06a6217a5a826a226fb57b7" CI_USER=$CIRCLE_PROJECT_USERNAME CI_REPO=$CIRCLE_PROJECT_REPONAME PULL_REQUEST_NUMBER=$CIRCLE_PR_NUMBER node bots/code-analysis-bot.js + else + echo "Skipping code analysis." + fi + + publish-npm: + <<: *defaults + docker: + - image: circleci/node:8 + steps: + - checkout + - run: + name: Install Dependencies + command: | + npm config set spin=false + npm config set progress=false + npm install --no-package-lock + - run: + name: Publish React Native Package + command: | + if [ -z "$CIRCLE_PULL_REQUEST" ]; then + echo "//registry.npmjs.org/:_authToken=${CIRCLE_NPM_TOKEN}" > ~/.npmrc + git config --global user.email "reactjs-bot@users.noreply.github.com" + git config --global user.name "Website Deployment Script" + echo "machine github.com login reactjs-bot password $GITHUB_TOKEN" > ~/.netrc + node ./scripts/publish-npm.js + else + echo "Skipping publication." + fi + # Workflows enables us to run multiple jobs in parallel workflows: version: 2 @@ -366,6 +449,21 @@ workflows: only: - /.*-stable/ - master + deploy: + jobs: + - publish-npm + branches: + only: + - /.*-stable/ + - master + analyze: + jobs: + - analyze-pull-request + branches: + ignore: + - master + - gh-pages + - /.*-stable/ test_android: jobs: - build-js-bundle: From 348bf679ace1dfa23e792879e7de91ae14d8ad96 Mon Sep 17 00:00:00 2001 From: Hector Ramos Date: Thu, 12 Oct 2017 10:28:18 -0700 Subject: [PATCH 2/5] Dummy commit to force Circle to run --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 634a5008fa8e63..51b38f44e06069 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -273,7 +273,7 @@ jobs: curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt-get install -y nodejs - run: - name: Install Dependencies + name: Install Node Dependencies command: | npm config set spin=false npm config set progress=false From c3e15e30a21794c12aaa6b881ad6c01445a642a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= <165856+hramos@users.noreply.github.com> Date: Thu, 12 Oct 2017 10:58:05 -0700 Subject: [PATCH 3/5] Another dummy commit --- .circleci/config.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 51b38f44e06069..008d8e791afcfc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -385,7 +385,8 @@ jobs: else echo "Skipping dependency installation." fi - - save-cache: *save-cache-analysis +# Run Danger +- save-cache: *save-cache-analysis - run: name: Analyze Pull Request command: | @@ -395,6 +396,7 @@ jobs: echo "Skipping pull request analysis." fi when: always +# Run eslint - run: name: Analyze Code command: | From c17e9bea23ab75cafa50ba097414bb59f7d592a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= <165856+hramos@users.noreply.github.com> Date: Thu, 12 Oct 2017 10:59:36 -0700 Subject: [PATCH 4/5] Fix spacing in danger call --- .circleci/config.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 008d8e791afcfc..a02ab22a332d85 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -385,18 +385,16 @@ jobs: else echo "Skipping dependency installation." fi -# Run Danger -- save-cache: *save-cache-analysis + - save-cache: *save-cache-analysis - run: name: Analyze Pull Request command: | if [ -n "$CIRCLE_PULL_REQUEST" ]; then - cd danger &&DANGER_GITHUB_API_TOKEN="e622517d9f1136ea8900""07c6373666312cdfaa69" npm run danger + cd danger && DANGER_GITHUB_API_TOKEN="e622517d9f1136ea8900""07c6373666312cdfaa69" npm run danger else echo "Skipping pull request analysis." fi when: always -# Run eslint - run: name: Analyze Code command: | From 624b9d6ff25a1c210d01eb98a066054c5b8c0ea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= <165856+hramos@users.noreply.github.com> Date: Thu, 12 Oct 2017 11:01:09 -0700 Subject: [PATCH 5/5] Dummy --- .circleci/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index a02ab22a332d85..6ceb4870e87b4d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -386,6 +386,7 @@ jobs: echo "Skipping dependency installation." fi - save-cache: *save-cache-analysis +# Run Danger - run: name: Analyze Pull Request command: | @@ -395,6 +396,7 @@ jobs: echo "Skipping pull request analysis." fi when: always +# Run eslint - run: name: Analyze Code command: |