From e28bb46a82d45134961a85b43fafede0792c0ccc Mon Sep 17 00:00:00 2001 From: Harris Borawski Date: Thu, 27 Oct 2022 16:04:38 -0700 Subject: [PATCH] run a separate workflow for forked PRs without write capable cache keys (#97) * try to run a separate workflow for forked PRs with read only cache keys * fix regex * use fork version of applitools keys * write out bazelrc.local for origin builds * remove flag from commands now that is in bazelrc.local * fix indentation * set flags in rc specifically because common can break shutdown command --- .circleci/config.yml | 70 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 17e15a28d..21e84325c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -57,13 +57,27 @@ jobs: paths: - . + bazelrc: + executor: base + steps: + - attach_workspace: + at: ~/player + - run: | + echo "build --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY}" >> .bazelrc.local + echo "test --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY}" >> .bazelrc.local + echo "coverage --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY}" >> .bazelrc.local + - persist_to_workspace: + root: . + paths: + - . + build: executor: base steps: - attach_workspace: at: ~/player - - run: bazel build --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY} --config=ci --config=skip-ios -- //... + - run: bazel build --config=ci --config=skip-ios -- //... - save_cache: paths: @@ -131,13 +145,13 @@ jobs: - run: | BUNDLE_TARGETS=$(bazel query "attr(name, '_Bundles', //...)" --output label 2>/dev/null | tr '\n' ' ') - bazel build --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY} --config=ci $BUNDLE_TARGETS + bazel build --config=ci $BUNDLE_TARGETS - run: bazel shutdown - run: cd xcode && bundle exec pod install - - run: bazel build --config=ci --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY} -- //:PlayerUI //:PlayerUI-Demo //:PlayerUI_Pod + - run: bazel build --config=ci -- //:PlayerUI //:PlayerUI-Demo //:PlayerUI_Pod # TODO: the timeout should be added to the test itself - - run: bazel test --test_env=APPLITOOLS_API_KEY=${APPLITOOLS_API_KEY} --test_env=APPLITOOLS_BATCH_ID=${CIRCLE_SHA1} --test_env=APPLITOOLS_PR_NUMBER=${CIRCLE_PULL_REQUEST##*/} --test_timeout=600 --jobs=1 --verbose_failures --config=ci --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY} -- //:PlayerUI-Unit-Unit //:PlayerUI-UI-ViewInspectorTests //:PlayerUI-UI-XCUITests + - run: bazel test --test_env=APPLITOOLS_API_KEY=${APPLITOOLS_API_KEY} --test_env=APPLITOOLS_BATCH_ID=${CIRCLE_SHA1} --test_env=APPLITOOLS_PR_NUMBER=${CIRCLE_PULL_REQUEST##*/} --test_timeout=600 --jobs=1 --verbose_failures --config=ci -- //:PlayerUI-Unit-Unit //:PlayerUI-UI-ViewInspectorTests //:PlayerUI-UI-XCUITests - run: when: always @@ -158,7 +172,7 @@ jobs: - attach_workspace: at: ~/player - - run: bazel test --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY} --config=skip-ios --config=ci -- //... -//docs/site -//android/demo:android_instrumentation_test + - run: bazel test --config=skip-ios --config=ci -- //... -//docs/site -//android/demo:android_instrumentation_test - run: when: always @@ -207,7 +221,7 @@ jobs: command: | circle-android wait-for-boot - - run: bazel test --define=APPLITOOLS_API_KEY=${APPLITOOLS_API_KEY} --define=APPLITOOLS_BATCH_ID=${CIRCLE_SHA1} --define=APPLITOOLS_PR_NUMBER=${CIRCLE_PULL_REQUEST##*/} --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY} --config=ci -- //android/demo:android_instrumentation_test + - run: bazel test --define=APPLITOOLS_API_KEY=${APPLITOOLS_API_KEY} --define=APPLITOOLS_BATCH_ID=${CIRCLE_SHA1} --define=APPLITOOLS_PR_NUMBER=${CIRCLE_PULL_REQUEST##*/} --config=ci -- //android/demo:android_instrumentation_test - store_artifacts: path: screenshots @@ -226,7 +240,7 @@ jobs: - run: | BUNDLE_TARGETS=$(bazel query "kind(nodejs_test, //...)" --output label 2>/dev/null | tr '\n' ' ') - bazel coverage --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY} --config=ci -- $BUNDLE_TARGETS + bazel coverage --config=ci -- $BUNDLE_TARGETS - codecov/upload: file: ./bazel-out/_coverage/_coverage_report.dat @@ -275,25 +289,31 @@ workflows: ignore: - main - /version-.*/ + - /pull\/.*/ tags: ignore: /.*/ + - bazelrc: + context: + - Build + requires: + - setup - applitools_init: context: - applitools requires: - - setup + - bazelrc - build: requires: - - setup + - bazelrc - build_ios: context: - applitools requires: - applitools_init - - setup + - bazelrc - test: requires: @@ -317,6 +337,36 @@ workflows: - android_test - build_ios + build_and_test_pr_fork: + jobs: + - setup: + filters: + branches: + only: + - /pull\/.*/ + tags: + ignore: /.*/ + + - build: + requires: + - setup + + - build_ios: + requires: + - setup + + - test: + requires: + - build + + - android_test: + requires: + - build + + - coverage: + requires: + - build + build_and_test_main: when: equal: [ "", << pipeline.parameters.GHA_Action >> ]