Skip to content

Commit 01812dd

Browse files
authored
Run CI on Windows (#268)
Fixes #265 Closes #235
1 parent 7ecdd3c commit 01812dd

11 files changed

Lines changed: 80 additions & 9 deletions

File tree

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ build --tool_java_language_version=17
1515
test --verbose_failures
1616
test --test_output=errors
1717

18+
import %workspace%/.bazelrc.windows
19+
1820
# Load any settings specific to the current user.
1921
try-import %workspace%/.bazelrc.user

.bazelrc.windows

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Make things work on Windows
2+
common --enable_platform_specific_config
3+
startup --windows_enable_symlinks
4+
build:windows --enable_runfiles

.github/workflows/gazelle_examples.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,19 @@ jobs:
1414
matrix:
1515
runs-on:
1616
- ubuntu-latest
17+
- windows-latest
1718

1819
runs-on: ${{ matrix.runs-on }}
1920

2021
steps:
2122
- uses: actions/checkout@v3
2223

24+
# The windows-latest image comes with Java 8 but rules_jvm_external requires at least 11, so we install a newer JDK.
25+
- uses: actions/setup-java@v4
26+
with:
27+
distribution: "zulu"
28+
java-version: "21"
29+
2330
- uses: bazelbuild/setup-bazelisk@v2
2431

2532
- name: Mount bazel action cache

.github/workflows/tests.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
strategy:
1717
matrix:
1818
runs-on:
19+
# Most of the tests don't run on Windows, so we have a separate job for running just the ones that do.
1920
- ubuntu-latest
2021
flags:
2122
- ""
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Tests (Windows)
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
jobs:
12+
# We don't run the tests in the main test job because most of them don't work on Windows, but the Gazelle ones should, so we run those.
13+
test_windows:
14+
strategy:
15+
matrix:
16+
runs-on:
17+
- windows-latest
18+
19+
runs-on: ${{ matrix.runs-on }}
20+
21+
steps:
22+
- uses: actions/checkout@v3
23+
24+
# The windows-latest image comes with Java 8 but rules_jvm_external requires at least 11, so we install a newer JDK.
25+
- uses: actions/setup-java@v4
26+
with:
27+
distribution: "zulu"
28+
java-version: "21"
29+
30+
- uses: bazelbuild/setup-bazelisk@v2
31+
32+
- name: Mount bazel action cache
33+
uses: actions/cache@v2
34+
with:
35+
path: "~/.cache/bazel"
36+
key: bazel
37+
38+
- name: Mount bazel repo cache
39+
uses: actions/cache@v2
40+
with:
41+
path: "~/.cache/bazel-repo"
42+
key: bazel-repo
43+
44+
- name: bzlmod gazelle
45+
env:
46+
# Bazelisk will download bazel to here, ensure it is cached between runs.
47+
XDG_CACHE_HOME: ~/.cache/bazel-repo
48+
run: bazelisk --bazelrc=.github/workflows/ci.bazelrc test //java/gazelle/...

MODULE.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ bazel_dep(
3131
version = "0.36.0",
3232
repo_name = "bazel_gazelle",
3333
)
34+
git_override(
35+
module_name = "gazelle",
36+
commit = "ba2ce367a545e0bdd74a7abca40ef5e0a0cb8dcb",
37+
remote = "https://github.com/bazelbuild/bazel-gazelle.git",
38+
)
39+
3440
bazel_dep(
3541
name = "protobuf",
3642
version = PROTOBUF_VERSION,

examples/gazelle/.bazelrc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
common --enable_platform_specific_config
2-
3-
# https://bazel.build/docs/windows#symlink
4-
startup --windows_enable_symlinks
5-
run:windows --enable_runfiles
1+
import %workspace%/../../.bazelrc.windows

examples/gazelle/MODULE.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,8 @@ bazel_dep(
4343
name = "gazelle",
4444
version = "0.36.0",
4545
)
46+
git_override(
47+
module_name = "gazelle",
48+
commit = "ba2ce367a545e0bdd74a7abca40ef5e0a0cb8dcb",
49+
remote = "https://github.com/bazelbuild/bazel-gazelle.git",
50+
)

examples/gazelle/src/test/com/example/gazelle/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("@contrib_rules_jvm//java:defs.bzl", "java_test_suite")
21
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
2+
load("@contrib_rules_jvm//java:defs.bzl", "java_test_suite")
33

44
genquery(
55
name = "generated_targets",

examples/tests_and_lints/.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import %workspace%/../../.bazelrc.windows

0 commit comments

Comments
 (0)