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

chore: add a macro for duplicating an e2e for bazel-lib 2.x #1366

Closed
wants to merge 1 commit into from

Conversation

kormide
Copy link
Member

@kormide kormide commented Nov 19, 2023

⚠️ EXPERIMENTAL. I'm not sold on this approach but wanted to get some feedback.

This adds a macro that will take any e2e, swap bazel-lib 1.x for 2.x, and write it to the source tree. The goal here is to make it easy to run the same e2e against bazel-lib 2.x while reducing the test maintenance burden of keeping both version of the test identical.

It uses the buildozer toolchain to modify version in the WORKSPACE and MODULE files of e2es.

I don't think we need to test every e2e with bazel-lib 2.x since our matrix is already large. This just adds a couple.

Related to #1363.

Type of change

  • Chore (any other change that doesn't affect source or test files, such as configuration)

Test plan

  • Covered by existing test cases

@kormide kormide force-pushed the auto-bazel-lib2-e2e branch 3 times, most recently from 1973e59 to 89d35f4 Compare November 19, 2023 09:36
Comment on lines +1 to +35
e2e/bzlmod
e2e/bzlmod_bazel_lib_2
e2e/git_dep_metadata
e2e/gyp_no_install_script
e2e/js_image_docker
e2e/js_image_oci
e2e/js_run_devserver
e2e/npm_link_package
e2e/npm_link_package-esm
e2e/npm_translate_lock
e2e/npm_translate_lock_auth
e2e/npm_translate_lock_empty
e2e/npm_translate_lock_git+ssh
e2e/npm_translate_lock_multi
e2e/npm_translate_lock_partial_clone
e2e/npm_translate_lock_subdir_patch
e2e/npm_translate_package_lock
e2e/npm_translate_yarn_lock
e2e/package_json_module
e2e/patch_from_repo
e2e/pnpm_repo_install
e2e/pnpm_workspace
e2e/pnpm_workspace_bazel_lib_2
e2e/pnpm_workspace_deps
e2e/pnpm_workspace_rerooted
e2e/rules_foo
e2e/update_pnpm_lock
e2e/update_pnpm_lock_with_import
e2e/vendored_node
e2e/vendored_tarfile
e2e/verify_patches
e2e/webpack_devserver
e2e/webpack_devserver_esm
e2e/worker
e2e/workspace
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can no longer just ignore e2e because the write_source_files target which writes the duplicate e2e with bazel-lib 2.x will puke on the analysis phase test where it globs to check for existence.

However I added some additional tests to ensure all e2es are added here.

Comment on lines 1 to 15
diff --git a/lib/private/write_source_file.bzl b/lib/private/write_source_file.bzl
index f177118..db25c72 100644
--- a/lib/private/write_source_file.bzl
+++ b/lib/private/write_source_file.bzl
@@ -219,8 +219,8 @@ else
echo "Copying directory $in to $out in $PWD"
rm -Rf "$out"/*
mkdir -p "$out"
- cp -fRL "$in"/* "$out"
- chmod -R ug+w "$out"/*
+ cp -fRL "$in"/. "$out"
+ chmod -R ug+w "$out"/.
{executable_dir}
fi
""".format(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a bug in write_source_files while working on this. It doesn't copy over hidden files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch itself has a bug though where it doesn't preserve executable bits.

@kormide kormide force-pushed the auto-bazel-lib2-e2e branch 4 times, most recently from 19edb29 to 7f37a30 Compare November 19, 2023 09:56

aspect_bazel_lib_dependencies()

register_coreutils_toolchains()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I shouldn't have to add this to the bazel-lib 1.x e2e, but it is needed for the bazel-lib 2.x version of the e2e. So flipping the version isn't always the only thing needed to test both. Perhaps this is a good enough reason not to go with this approach..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could add an input to the e2e copying macro that takes buildozer commands to apply to the WORKSPACE and the 2.0 version could be modified that way..

@kormide kormide marked this pull request as ready for review November 19, 2023 10:01
@kormide
Copy link
Member Author

kormide commented Nov 19, 2023

My overall take is that it's simpler to just make a couple copies of e2es manually and point them to use bazel-lib 2.x This seems like overkill.

@kormide kormide force-pushed the auto-bazel-lib2-e2e branch 2 times, most recently from 193ff5b to a64bed4 Compare November 19, 2023 10:26
@@ -279,7 +283,7 @@ jobs:
# still bootstraps Aspect CLI from configuration in .bazeliskrc. Aspect CLI will
# then use .bazelversion to determine which Bazel version to use
run: |
echo "${{ matrix.bazelversion }}" > .bazelversion
find . -name ".bazelversion" -type f -exec echo "${{ matrix.bazelversion }}" > {}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .bazelversion symlinks in bazel-lib 2 e2es that are written back to the source tree are not preserved. Find all non-symlink .bazelversion files and replace them.

@kormide kormide force-pushed the auto-bazel-lib2-e2e branch 3 times, most recently from f921ac0 to 7398231 Compare November 19, 2023 10:44
@alexeagle
Copy link
Member

Yeah this does feel like a bunch of complexity for a case that we don't care that much about, and in 6mo or something we'll expect most users to be on bazel-lib 2.0 simply because there will be some rulesets that take that as a lower-bound (e.g. rules_distroless to get the tar toolchain)

I think we should just mix-and-match for now, most e2e on bazel-lib 2 and a couple on bazel-lib 1. We won't have comprehensive test coverage, so there's some risk, but it will be a smoke test to catch some obvious things. WDYT?

@kormide
Copy link
Member Author

kormide commented Nov 20, 2023

Yeah this does feel like a bunch of complexity for a case that we don't care that much about, and in 6mo or something we'll expect most users to be on bazel-lib 2.0 simply because there will be some rulesets that take that as a lower-bound (e.g. rules_distroless to get the tar toolchain)

I think we should just mix-and-match for now, most e2e on bazel-lib 2 and a couple on bazel-lib 1. We won't have comprehensive test coverage, so there's some risk, but it will be a smoke test to catch some obvious things. WDYT?

Yeah I agree. I'll just select a few and flip them to use bazel-lib 2.x.

@kormide
Copy link
Member Author

kormide commented Nov 21, 2023

Closing in favour of #1369.

@kormide kormide closed this Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants