Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not watch .netrc in read_netrc #22125

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions MODULE.bazel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2884,7 +2884,7 @@
"bzlTransitiveDigest": "tunTSmgwd2uvTzkCLtdbuCp0AI+WR+ftiPNqZ0rmcZk=",
"recordedFileInputs": {
"@@//MODULE.bazel": "41e97ab73eab5fafef6cd8f9b4696823e31384219a6356a052cab52245e1193c",
"@@//src/test/tools/bzlmod/MODULE.bazel.lock": "e6b22f35c7bce99c0677f24a19c7aee829f97e7b1b5cc31e600c7cc9b408a292"
"@@//src/test/tools/bzlmod/MODULE.bazel.lock": "24f151a4b72d795d8290fe7b2f1a0a6d0a20110d644bc9d804ea881baadb8c52"
},
"recordedDirentsInputs": {},
"envVariables": {},
Expand Down Expand Up @@ -3436,7 +3436,7 @@
},
"//tools/android:android_extensions.bzl%android_sdk_proxy_extensions": {
"general": {
"bzlTransitiveDigest": "VNI4MfItl2Hd4Mu0mePTyUs1yt86logmR5+f2bQ00g8=",
"bzlTransitiveDigest": "JQoCqdz3xQGJ+/ILJLx/pnLPCjAYRvq3Tmj3wkpmflI=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
"envVariables": {},
Expand All @@ -3452,7 +3452,7 @@
},
"//tools/android:android_extensions.bzl%remote_android_tools_extensions": {
"general": {
"bzlTransitiveDigest": "VNI4MfItl2Hd4Mu0mePTyUs1yt86logmR5+f2bQ00g8=",
"bzlTransitiveDigest": "JQoCqdz3xQGJ+/ILJLx/pnLPCjAYRvq3Tmj3wkpmflI=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
"envVariables": {},
Expand All @@ -3479,7 +3479,7 @@
},
"//tools/test:extensions.bzl%remote_coverage_tools_extension": {
"general": {
"bzlTransitiveDigest": "3sNMqgli78Zf+NkeJ1Bdz8O35yzta+wO/Iw/qiWY+pE=",
"bzlTransitiveDigest": "kcwMubtgxBru6ttbkwo5IjUmLeSz0AODaQoox5L4zVU=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
"envVariables": {},
Expand Down
10 changes: 9 additions & 1 deletion src/test/shell/bazel/starlark_repository_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1963,6 +1963,7 @@ EOF
cat > def.bzl <<'EOF'
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "read_netrc", "use_netrc")
def _impl(ctx):
print("authrepo is being evaluated")
rc = read_netrc(ctx, ctx.attr.path)
auth = use_netrc(rc, ctx.attr.urls, {"oauthlife.com": "Bearer <password>",})
ctx.file("data.bzl", "auth = %s" % (auth,))
Expand Down Expand Up @@ -2044,9 +2045,16 @@ genrule(
cmd = "echo %s > $@" % (check_equal_expected(),)
)
EOF
bazel build //:check_expected
bazel build //:check_expected &> $TEST_log || fail "Expected success"
grep 'OK' `bazel info bazel-bin`/check_expected.txt \
|| fail "Authentication merged incorrectly"
expect_log "authrepo is being evaluated"

echo "modified" > .netrc
bazel build //:check_expected &> $TEST_log || fail "Expected success"
grep 'OK' `bazel info bazel-bin`/check_expected.txt \
|| fail "Authentication information should not have been reevaluated"
expect_not_log "authrepo is being evaluated"
}

function test_disallow_unverified_http() {
Expand Down
16 changes: 8 additions & 8 deletions src/test/tools/bzlmod/MODULE.bazel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@
},
"@@bazel_tools//tools/android:android_extensions.bzl%android_sdk_proxy_extensions": {
"general": {
"bzlTransitiveDigest": "VNI4MfItl2Hd4Mu0mePTyUs1yt86logmR5+f2bQ00g8=",
"bzlTransitiveDigest": "JQoCqdz3xQGJ+/ILJLx/pnLPCjAYRvq3Tmj3wkpmflI=",
"usagesDigest": "x7fdOxuT/Cd/ZXZa8OyoLFxU34+IE1KtcbASixO3XJM=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
Expand All @@ -1122,7 +1122,7 @@
},
"@@bazel_tools//tools/android:android_extensions.bzl%remote_android_tools_extensions": {
"general": {
"bzlTransitiveDigest": "VNI4MfItl2Hd4Mu0mePTyUs1yt86logmR5+f2bQ00g8=",
"bzlTransitiveDigest": "JQoCqdz3xQGJ+/ILJLx/pnLPCjAYRvq3Tmj3wkpmflI=",
"usagesDigest": "LPw+9iUcnRY1k89ZEMEZ/AtOYIK2LgSeKnaiYVCDaag=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
Expand Down Expand Up @@ -1215,7 +1215,7 @@
},
"@@bazel_tools//tools/test:extensions.bzl%remote_coverage_tools_extension": {
"general": {
"bzlTransitiveDigest": "3sNMqgli78Zf+NkeJ1Bdz8O35yzta+wO/Iw/qiWY+pE=",
"bzlTransitiveDigest": "kcwMubtgxBru6ttbkwo5IjUmLeSz0AODaQoox5L4zVU=",
"usagesDigest": "O3U7dkKl24l4dKwsK8Y1uf1SAa/eEwLfw4BRsHGugwc=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
Expand Down Expand Up @@ -1280,7 +1280,7 @@
},
"@@rules_java~//java:extensions.bzl%toolchains": {
"general": {
"bzlTransitiveDigest": "LgqWLGQ6rTbpJ/JJA+kR6TERkCxUUPRWyIxst0RKRLk=",
"bzlTransitiveDigest": "vVD15tu/rctjxFcmEY/kGV8BU29Wa5EgvggNQpJVYrE=",
"usagesDigest": "1/Dwy6r0Nf/YUE94OFi5Yy0Mo+TrPxA3U8hBaEzYH5s=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
Expand Down Expand Up @@ -1846,7 +1846,7 @@
},
"@@rules_jvm_external~//:extensions.bzl%maven": {
"general": {
"bzlTransitiveDigest": "8KUKrTHssAwnL6tCSKx4a3dfMZdLxcAvVujtpYra5C4=",
"bzlTransitiveDigest": "B3lrNG2za+3c/y7Bldx38hxzAkTa6uYaesdEicYzZes=",
"usagesDigest": "L+U25+BzBiliO0i3XrvqC5up0f210dPakCjqg5MBrp4=",
"recordedFileInputs": {
"@@rules_jvm_external~//rules_jvm_external_deps_install.json": "10442a5ae27d9ff4c2003e5ab71643bf0d8b48dcf968b4173fa274c3232a8c06"
Expand Down Expand Up @@ -2870,7 +2870,7 @@
},
"@@rules_jvm_external~//:non-module-deps.bzl%non_module_deps": {
"general": {
"bzlTransitiveDigest": "WX7j7+l47KFuIt7b25LRYxd1D0Ab6UO+qOi8wzlD4Ro=",
"bzlTransitiveDigest": "4OsuF/ozYz/n2U+6GGxM/3IzzX+qvQtjlY1fXeg2jE0=",
"usagesDigest": "HWGzpnxaDzDwBkFxYvT/plvwcfNrPZGTg9ZYibwxNGw=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
Expand Down Expand Up @@ -2898,7 +2898,7 @@
},
"@@rules_python~//python/extensions:python.bzl%python": {
"general": {
"bzlTransitiveDigest": "5V1HDNZURraXQPyvUA10ca2nPQWBMQ2b+x0QsZnKoPs=",
"bzlTransitiveDigest": "f/rffFOqp0Y5r6QNmElWpkVrIk/9b0pfhd/j+JtG0YM=",
"usagesDigest": "2dLy/xmv7+TD8WRYYIxtxZMeS4nrJZGIDSMkYRE0elw=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
Expand Down Expand Up @@ -2928,7 +2928,7 @@
},
"@@rules_python~//python/extensions/private:internal_deps.bzl%internal_deps": {
"general": {
"bzlTransitiveDigest": "YwTzsQ2KJ7JxfzweeE6c08mDlx3CK2fbTlbw6+Pe22w=",
"bzlTransitiveDigest": "2QkuIItPQyACdxi2VVWUF2DrUHZ4M8To5Q5TMr6R+CU=",
"usagesDigest": "MZDuELgGnEk5m0vRt+s02bhPv0B21Oi1jm1KuRqZ5FY=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
Expand Down
5 changes: 4 additions & 1 deletion tools/build_defs/repo/utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ def read_netrc(ctx, filename):
dict mapping a machine names to a dict with the information provided
about them
"""
contents = ctx.read(filename)

# Do not cause the repo rule to rerun due to changes to auth info when it is
# successful. Failures are not cached.
contents = ctx.read(filename, watch = "no")
return parse_netrc(contents, filename)

def parse_netrc(contents, filename = None):
Expand Down