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

Pipeline defined Bazel version #1141

Merged
merged 1 commit into from
Nov 14, 2019
Merged

Pipeline defined Bazel version #1141

merged 1 commit into from
Nov 14, 2019

Conversation

aherrmann
Copy link
Member

  • The bindists pipeline now defines the Bazel version it will use.
    Bazel is fetched as a single binary from GitHub.
  • The nixpkgs pipeline confirms that its Bazel version matches.
  • The bindists pipeline is defined in its own script file.
    This is to avoid shell escaping issues.
  • Enables strict action env in the bindists pipeline.
    This avoids changes in $PATH invalidating cached builds with
    use_default_action_env. This works with bindists targets, but the
    nixpkgs pipeline still contains some targets that are incompatible
    with strict action env.

@aherrmann aherrmann requested a review from flokli November 13, 2019 08:48
Comment on lines 7 to 18
echo "common:ci --build_tag_filters -requires_lz4,-requires_proto,-requires_zlib,-requires_doctest,-requires_c2hs,-requires_threaded_rts,-dont_test_with_bindist" > .bazelrc.local
# XXX: See .bazelrc [backward compatible options] for the the rational behind this flag
echo "build --incompatible_use_python_toolchains=false" >> .bazelrc.local
echo "build:ci --experimental_strict_action_env" >> .bazelrc.local
./tests/run-start-script.sh --use-bindists
bazel build --config ci //tests/...
Copy link
Member Author

@aherrmann aherrmann Nov 13, 2019

Choose a reason for hiding this comment

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

This bit is copied from .buildkite/pipeline.yml (except for --experimental_strict_action_env)

@@ -5,6 +5,8 @@ steps:
echo "build:ci --host_platform=@rules_haskell//haskell/platforms:linux_x86_64_nixpkgs" > .bazelrc.local
nix-shell --arg docTools false --pure --run '
set -e
# Ensure that the Nixpkgs and bindists Bazel versions match.
Copy link
Contributor

Choose a reason for hiding this comment

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

what about

Suggested change
# Ensure that the Nixpkgs and bindists Bazel versions match.
# Ensure that the Nixpkgs bazel version matches with what's specified in .buildkite/bazel-version

?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to run the same test in .buildkite/bindists-pipeline too?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, we don't have to, because we do the fetching there, so maybe update the comment to

Suggested change
# Ensure that the Nixpkgs and bindists Bazel versions match.
# Ensure that the Nixpkgs bazel version matches with what's specified in .buildkite/bazel-version and fetched in `.buildkite/bindists-pipeline` for the bindists version

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 version is used to construct the URL from which Bazel is fetch, so checking the version against that file once again is redundant.

I've expanded the comment as suggested.

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
Copy link
Contributor

Choose a reason for hiding this comment

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

This could have a comment stating it calls the fetch-bazel-bindist script, configures bazelrc, and adds fetched bazel to $PATH.

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've added a comment to that effect.

# converted to using `rules_sh`'s POSIX toolchain.
echo "build:ci --experimental_strict_action_env" >> .bazelrc.local
./tests/run-start-script.sh --use-bindists
bazel build --config ci //tests/...
Copy link
Contributor

Choose a reason for hiding this comment

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

If the environment changes propagate to the next buildkite step, we probably should move this to pipeline.yml, like in the nixpkgs case.

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 tried that initially and found that

  1. You have to be careful to escape variables. E.g. \$PATH instead of $PATH.
  2. export PATH=... didn't seem to be picked up and bazel called the globally installed version instead.

So, putting the steps into a dedicated script made things much easier and less error prone.

FWIW the examples recommend the same thing.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm mostly concerned about maintaining those three lines:

./tests/run-start-script.sh --use-(bindists,nix)
bazel build --config ci //tests:run-tests
./bazel-ci-bin/tests/run-tests

in two places.

What about moving that into a build.sh script, which assumes a right bazel to be in $PATH, and calling it from both pipelines?

We could have build.sh accepting the --use-? as a parameter.

Copy link
Member Author

Choose a reason for hiding this comment

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

Those lines are different between nixpkgs and bindists.

In the nixpkgs pipeline they are:

      ./tests/run-start-script.sh --use-nix
      bazel build --config ci //tests:run-tests
      ./bazel-ci-bin/tests/run-tests
      bazel coverage //tests/... --config ci --build_tag_filters "coverage-compatible" --test_tag_filters "coverage-compatible" --test_output=all

And in the bindists pipeline they are:

./tests/run-start-script.sh --use-bindists
bazel build --config ci //tests/...

Once we've fixed what's missing for the bindist so it can run the same steps as nixpkgs then we should indeed unify these steps into something like build.sh.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you create a followup issue for that?

Copy link
Member Author

@aherrmann aherrmann left a comment

Choose a reason for hiding this comment

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

@flokli Thanks for the review. I've addressed your comments. PTAL

@flokli
Copy link
Contributor

flokli commented Nov 14, 2019

I'd suggest to squash the commits into one, as the first one failed CI.

@aherrmann aherrmann mentioned this pull request Nov 14, 2019
@aherrmann aherrmann force-pushed the pipeline-bazel-version branch from d982e79 to e562d98 Compare November 14, 2019 15:03
@aherrmann aherrmann added the merge-queue merge on green CI label Nov 14, 2019
- The bindists pipeline now defines the Bazel version it will use.
    Bazel is fetched as a single binary from GitHub.
- The nixpkgs pipeline confirms that its Bazel version matches.
- The bindists pipeline is defined in its own script file.
    This is to avoid shell escaping issues.
- Enables strict action env in the bindists pipeline.
    This avoids changes in `$PATH` invalidating cached builds with
    `use_default_action_env`. This works with bindists targets, but the
    nixpkgs pipeline still contains some targets that are incompatible
    with strict action env.
@jwiegley jwiegley force-pushed the pipeline-bazel-version branch from e562d98 to 63218cd Compare November 14, 2019 15:15
@mergify mergify bot merged commit d1ba855 into master Nov 14, 2019
@mergify mergify bot removed the merge-queue merge on green CI label Nov 14, 2019
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.

3 participants