Skip to content

Add test_dependency_versions, update test_runner #1729

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mbland
Copy link
Contributor

@mbland mbland commented Apr 29, 2025

Description

Adds test_dependency_versions.sh to validate the minimum Bazel and dependency versions required by rules_scala, with and without the precompiled protocol compiler toolchain. Extracts setup, run, and teardown helpers from test/shell/test_bzlmod_helpers.sh into test_runner.sh for reuse by test_dependency_versions.sh. Part of #1482.

Also:

  • Adds test files supporting test_dependency_versions.sh in deps/test.

  • Adds a mechanism to skip tests by prefixing their name with _ to run_test_local and run_test_ci.

  • Adds the RULES_SCALA_TEST_REGEX environment variable to test_runner.sh.

  • Adds documentation for RULES_SCALA_TEST_{ONLY,REGEX,VERBOSE} to the header comment of test_runner.sh.

  • Adds ./test_dependency_versions jobs to .bazelci/presubmit.yml.

Motivation

Continuation of the previous change to ensure we don't force users to upgrade their dependencies beyond the minimum versions supported by rules_scala. Only builds using Bzlmod, as WORKSPACE is considered legacy.

Inspired by a thread in the #bzlmod channel of the Bazel Slack workspace on 2025-01-01 indicating that rules should require the minumum versions possible:

Adds `test_dependency_versions.sh` to validate the minimum Bazel and
dependency versions required by `rules_scala`, with and without the
precompiled protocol compiler toolchain. Extracts setup, run, and
teardown helpers from `test/shell/test_bzlmod_helpers.sh` into
`test_runner.sh` for reuse by `test_dependency_versions.sh`.

Also:

- Adds test files supporting `test_dependency_versions.sh` in
  `deps/test`.

- Adds a mechanism to skip tests by prefixing their name with `_` to
  `run_test_local` and `run_test_ci`.

- Adds the `RULES_SCALA_TEST_REGEX` environment variable to
  `test_runner.sh`.

- Adds documentation for `RULES_SCALA_TEST_{ONLY,REGEX,VERBOSE}` to the
  header comment of `test_runner.sh`.

- Adds `./test_dependency_versions` jobs to `.bazelci/presubmit.yml`.

---

Continuation of the previous change to ensure we don't force users to
upgrade their dependencies beyond the minimum versions supported by
`rules_scala`. Only builds using Bzlmod, as `WORKSPACE` is considered
legacy.

Inspired by a thread in the #bzlmod channel of the Bazel Slack workspace
on 2025-01-01 indicating that rules should require the minumum versions
possible:

- https://bazelbuild.slack.com/archives/C014RARENH0/p1743597941149639
@mbland mbland requested review from liucijus and simuons as code owners April 29, 2025 12:02
mbland added 3 commits April 29, 2025 08:16
Copied the setup for the Windows `test_rules_scala` job to the Windows
`test_dependency_versions` job. Replaced `cp "${test_files[@]}" .` with
copying the list of files directly instead of keeping them in an array.

The Linux job passed. The Windows job didn't run the script at all. The
macOS build broke in a way I've not seen while developing locally:

```txt
cp:
(/Users/buildkite/builds/bk-macos-intel-m3q2/bazel/rules-scala-scala/deps/test/*.bzl
/Users/buildkite/builds/bk-macos-intel-m3q2/bazel/rules-scala-scala/examples/testing/multi_frameworks_toolchain/example/*.scala
/Users/buildkite/builds/bk-macos-intel-m3q2/bazel/rules-scala-scala/test/jmh/data.txt
/Users/buildkite/builds/bk-macos-intel-m3q2/bazel/rules-scala-scala/test/proto/standalone.proto
/Users/buildkite/builds/bk-macos-intel-m3q2/bazel/rules-scala-scala/test/src/main/scala/scalarules/test/twitter_scrooge/thrift/thrift2/thrift3/Thrift3.thrift):
No such file or directory
```
The script expects a directory path at the beginning of
`${BASH_SOURCE[0]}`, else the following error occurs:

```txt
test_dependency_versions.sh: line 18: cd: test_dependency_versions.sh:
  Not a directory
```

This is because `${BASH_SOURCE[0]%/*}` will return the original
`${BASH_SOURCE[0]}` without a leading path.

This failure in the Linux `test_dependency_versions` job looks like a
fluke, since the previous run succeeded, as did other current runs:

```
WARNING: Download from
https://github.com/bazelbuild/bazel-skylib/releases/download/1.6.0/bazel-skylib-1.6.0.tar.gz
failed: class java.io.IOException GET returned 618 jwt:jwt-not-provided
``
Works around the following `test_dependency_version.sh` failure:

```txt
FATAL:
  ExecuteProgram(C:\tools\msys64\home\b\_bazel_b\...\ScalafmtTest.format-test)
  failed: ERROR: src/main/native/windows/process.cc(202):
  CreateProcessW("C:\tools\msys64\home\b\_bazel_b\...\ScalafmtTest.format-test"):
  %1 is not a valid Win32 application.
 (error: 193)
  Test "test_precompiled_protoc_rules_java_7" failed  (49 sec)
```
@mbland
Copy link
Contributor Author

mbland commented Apr 29, 2025

@simuons @liucijus Note that this adds three new CI jobs. Of the three, the macOS version is dog slow for some reason. So if you want to only run a Linux job, Linux and Windows, or leave test_dependency_versions.sh out of the CI build altogether (like dt_patches/dt_patch_test.sh) let me know.

Also note that I updated the PR to prevent the bazel run //:ScalafmtTest.format-test step on Windows. As noted in #1482 (comment), I have a Windows ARM64 VM available, but not Windows x86_64, so I can't debug it right now. If bazel-contrib/rules_python#2276 resolves, I can take a stab at that point.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant