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

Make compat tests work on windows #5732

Merged
merged 2 commits into from
Apr 28, 2020
Merged

Make compat tests work on windows #5732

merged 2 commits into from
Apr 28, 2020

Conversation

cocreature
Copy link
Contributor

@cocreature cocreature commented Apr 27, 2020

This required some changes to the daml_sdk rule since the read-only
installation by the assistant breaks Bazel completely. We could only
apply those changes on Windows but I think I prefer the consistency
across platforms here over trying to stay close to how the SDK is
installed on user machines given that the SDK installation is not
something we’ve had issues with.

I’ve excluded the postgresql tests for now. I don’t expect them to be
particularly hard to fix but I’ve already spent almost 2 days on this
and having some tests run on Windows seems like a clear improvement
over running no tests on Windows :)

changelog_begin
changelog_end

Pull Request Checklist

  • Read and understand the contribution guidelines
  • Include appropriate tests
  • Set a descriptive title and thorough description
  • Add a reference to the issue this PR will solve, if appropriate
  • Include changelog additions in one or more commit message bodies between the CHANGELOG_BEGIN and CHANGELOG_END tags
  • Normal production system change, include purpose of change in description

NOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with /AzurePipelines run to
trigger the build.

@cocreature cocreature force-pushed the compat-windows branch 11 times, most recently from f57ba5d to 63e1481 Compare April 28, 2020 12:21
@cocreature cocreature changed the title Try to make compat tests work on windows Make compat tests work on windows Apr 28, 2020
@cocreature cocreature marked this pull request as ready for review April 28, 2020 12:39
This required some changes to the daml_sdk rule since the read-only
installation by the assistant breaks Bazel completely. We could only
apply those changes on Windows but I think I prefer the consistency
across platforms here over trying to stay close to how the SDK is
installed on user machines given that the SDK installation is not
something we’ve had issues with.

I’ve excluded the postgresql tests for now. I don’t expect them to be
particularly hard to fix but I’ve already spent almost 2 days on this
and having some tests run on Windows seems like a clear improvement
over running no tests on Windows :)

changelog_begin
changelog_end
Copy link
Contributor

@aherrmann-da aherrmann-da left a comment

Choose a reason for hiding this comment

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

Thank you for making this work!

Comment on lines +16 to +23
# Note (MK): This is a fun one: Let’s say $TEST_WORKSPACE is "compatibility"
# and the argument points to a target from an external workspace, e.g.,
# @daml-sdk-0.0.0//:daml. Then the short path will point to
# ../daml-sdk-0.0.0/daml. Putting things together we end up with
# compatibility/../daml-sdk-0.0.0/daml. On Linux and MacOS this works
# just fine. However, on windows we need to normalize the path
# or rlocation will fail to find the path in the manifest file.
rlocation $(realpath -L -s -m --relative-to=$PWD $TEST_WORKSPACE/$1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this is a very unfortunate aspect of the runfiles mechanism. Another solution is to pass in the rootpath instead of the short path. Sadly that requires extra hoops to jump through. In this case it looks like all those are Targets and have Labels. So, you could call expand_location to obtain the $(rootpath).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’ll leave it for now since this seems to work and I’m scared to touch it now 😨

stripPrefix = "sdk-{}".format(ctx.attr.version),
)
elif ctx.attr.sdk_sha256:
ctx.download_and_extract(
output = "extracted-sdk",
output = out_dir,
# TODO (MK) Make this work on other platforms.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can that todo note be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦 removed

Comment on lines +19 to +24
# The DAML assistant will mark the installed SDK read-only.
# This breaks Bazel horribly on Windows to the point where
# even `bazel clean --expunge` fails because it cannot remove
# the installed SDK. Therefore, we do not use the assistant to
# install the SDK but instead simply extract the SDK to the right
# location and set the symlink ourselves.
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, isn't there a risk of these tests testing something else than what users what experience? E.g. if the DAML assistant performs some configuration at installation at some point. Would it work to remove the read-only flag after install? Maybe in a trap to avoid leaving the bazel tree in a bad state if installation fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes there is a small risk here but after having spend way too much time trying to make this work otherwise, this seemed like the most reasonable option to me. Testing the SDK installation isn’t really a compatibility thing anyway and we do still have the actual SDK integration tests for that (at least for now).

changelog_begin
changelog_end
@cocreature cocreature merged commit 49e19eb into master Apr 28, 2020
@cocreature cocreature deleted the compat-windows branch April 28, 2020 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants