From 6f6084db69de372cbc6dcec259389e4b7dfd7fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Fri, 16 Mar 2018 16:48:36 -0700 Subject: [PATCH] Explicitly set path to yarn Summary: Due to issues with Circle's Docker images ([link](https://twitter.com/circleci/status/974694807091073024)), jobs are failing with an error "yarn not found". Test Plan Run on Circle Release Notes [GENERAL][MINOR][.circleci] - Fix Circle issue Closes https://github.com/facebook/react-native/pull/18419 Differential Revision: D7312052 Pulled By: hramos fbshipit-source-id: 2768b9c69046a2f80518430024d3e7afbbd7de65 --- .circleci/config.yml | 10 +++++++--- scripts/circleci/analyze_code.sh | 12 ++++++++++++ scripts/circleci/exec_swallow_error.sh | 13 +++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) create mode 100755 scripts/circleci/analyze_code.sh create mode 100755 scripts/circleci/exec_swallow_error.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 100bc1276ff..4006882af1b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -157,10 +157,11 @@ aliases: - &run-js-tests name: JavaScript Test Suite command: yarn test-ci - + + # eslint sometimes runs into trouble generating the reports - &run-lint-checks name: Lint code - command: yarn lint --format junit -o ~/react-native/reports/junit/js-lint-results.xml + command: scripts/circleci/exec_swallow_error.sh yarn lint --format junit -o ~/react-native/reports/junit/js-lint-results.xml when: always - &run-flow-checks @@ -251,6 +252,8 @@ js_defaults: &js_defaults <<: *defaults docker: - image: circleci/node:8 + environment: + - PATH: "/opt/yarn/yarn-v1.5.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" android_defaults: &android_defaults <<: *defaults @@ -258,6 +261,7 @@ android_defaults: &android_defaults - image: circleci/android:api-26-alpha resource_class: "large" environment: + - PATH: "/opt/yarn/yarn-v1.5.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" - TERM: "dumb" - ADB_INSTALL_TIMEOUT: 10 - _JAVA_OPTIONS: "-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap" @@ -539,7 +543,7 @@ jobs: command: | # GITHUB_TOKEN=eslint-bot public_repo access token if [ -n "$CIRCLE_PR_NUMBER" ]; then - cat <(echo eslint; yarn --silent lint --format=json; echo flow; yarn --silent flow 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 + GITHUB_TOKEN="af6ef0d15709bc91d""06a6217a5a826a226fb57b7" CI_USER=$CIRCLE_PROJECT_USERNAME CI_REPO=$CIRCLE_PROJECT_REPONAME PULL_REQUEST_NUMBER=$CIRCLE_PR_NUMBER scripts/circleci/analyze_code.sh else echo "Skipping code analysis." fi diff --git a/scripts/circleci/analyze_code.sh b/scripts/circleci/analyze_code.sh new file mode 100755 index 00000000000..9569a4fa8e7 --- /dev/null +++ b/scripts/circleci/analyze_code.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +cat <(echo eslint; yarn --silent lint --format=json; echo flow; yarn --silent flow check --json) | GITHUB_TOKEN=$GITHUB_TOKEN CI_USER=$CI_USER CI_REPO=$CI_REPO PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER node bots/code-analysis-bot.js + +# check status +STATUS=$? +if [ $STATUS == 0 ]; then + echo "Code analyzed successfully" +else + echo "Code analyzis failed, error status $STATUS" +fi + diff --git a/scripts/circleci/exec_swallow_error.sh b/scripts/circleci/exec_swallow_error.sh new file mode 100755 index 00000000000..297cf5b0121 --- /dev/null +++ b/scripts/circleci/exec_swallow_error.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# execute command +$@ + +# check status +STATUS=$? +if [ $STATUS == 0 ]; then + echo "Command '$@' completed successfully" +else + echo "Command '$@' exited with error status $STATUS" +fi +