Skip to content

Commit

Permalink
run a separate workflow for forked PRs without write capable cache ke…
Browse files Browse the repository at this point in the history
…ys (#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
  • Loading branch information
hborawski authored and KVSRoyal committed Oct 28, 2022
1 parent 7a5ec61 commit e28bb46
Showing 1 changed file with 60 additions and 10 deletions.
70 changes: 60 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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 >> ]
Expand Down

0 comments on commit e28bb46

Please sign in to comment.