Skip to content

Commit

Permalink
Improve error for PRs from forks (#159)
Browse files Browse the repository at this point in the history
This has confused us a few times.
  • Loading branch information
drigz authored Jul 24, 2023
1 parent 07eddfa commit 26b037f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
File renamed without changes.
9 changes: 1 addition & 8 deletions .github/ci/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@ set -o xtrace # print command traces before executing command

# Wraps the common Bazel flags for CI for brevity.
function bazel_ci {
BAZELRC="${DIR}/rbe.bazelrc"
# GitHub does not give non-org members access to repo secrets.
# If that is the case, fall back to a non-RBE (ie slow) build.
if ! jq -e . >/dev/null 2>&1 < robco_integration_test_credentials.json; then
echo "Failed to parse RBE credentials, this is expected iff this is a PR from an external contributor/bot" >&2
BAZELRC="/dev/null"
fi
bazel --bazelrc="${BAZELRC}" "$@"
bazel --bazelrc="${DIR}/.bazelrc" "$@"
}

function generate_build_id() {
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/check-bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,18 @@ jobs:
env:
ROBCO_INTEGRATION_TEST_GITHUB_ROBOT_JSON_KEY: ${{ secrets.ROBCO_INTEGRATION_TEST_GITHUB_ROBOT_JSON_KEY }}
run: |
if [[ -z "$ROBCO_INTEGRATION_TEST_GITHUB_ROBOT_JSON_KEY" ]] ; then
echo >&2 "This PR appears to be from a fork or authored by a non-org member, rather than from the primary repo."
echo >&2 "This means it can't run the presubmit, which requires access to GCR."
echo >&2 "If you are a project member, please push your branch to github.com/googlecloudrobotics/core instead."
echo >&2 "https://docs.github.com/en/actions/managing-workflow-runs/approving-workflow-runs-from-public-forks#about-workflow-runs-from-public-forks"
exit 1
fi
echo "$ROBCO_INTEGRATION_TEST_GITHUB_ROBOT_JSON_KEY" > robco_integration_test_credentials.json
- name: Run .github/ci/presubmit.sh
env:
USE_BAZEL_VERSION: "6.2.0"
run: ./.github/ci/presubmit.sh
- name: Get bazel server logs
if: success() || failure()
run: cat ~/.cache/bazel/_bazel_*/*/java.log
run: cat ~/.cache/bazel/_bazel_*/*/java.log || true

0 comments on commit 26b037f

Please sign in to comment.