Skip to content

Commit

Permalink
Run CI on Windows (#268)
Browse files Browse the repository at this point in the history
Fixes #265 
Closes #235
  • Loading branch information
illicitonion authored May 8, 2024
1 parent 7ecdd3c commit 01812dd
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ build --tool_java_language_version=17
test --verbose_failures
test --test_output=errors

import %workspace%/.bazelrc.windows

# Load any settings specific to the current user.
try-import %workspace%/.bazelrc.user
4 changes: 4 additions & 0 deletions .bazelrc.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Make things work on Windows
common --enable_platform_specific_config
startup --windows_enable_symlinks
build:windows --enable_runfiles
7 changes: 7 additions & 0 deletions .github/workflows/gazelle_examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ jobs:
matrix:
runs-on:
- ubuntu-latest
- windows-latest

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

steps:
- uses: actions/checkout@v3

# The windows-latest image comes with Java 8 but rules_jvm_external requires at least 11, so we install a newer JDK.
- uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: "21"

- uses: bazelbuild/setup-bazelisk@v2

- name: Mount bazel action cache
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
strategy:
matrix:
runs-on:
# Most of the tests don't run on Windows, so we have a separate job for running just the ones that do.
- ubuntu-latest
flags:
- ""
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/tests_windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Tests (Windows)

on:
push:
branches: [main]
pull_request:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
# 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.
test_windows:
strategy:
matrix:
runs-on:
- windows-latest

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

steps:
- uses: actions/checkout@v3

# The windows-latest image comes with Java 8 but rules_jvm_external requires at least 11, so we install a newer JDK.
- uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: "21"

- uses: bazelbuild/setup-bazelisk@v2

- name: Mount bazel action cache
uses: actions/cache@v2
with:
path: "~/.cache/bazel"
key: bazel

- name: Mount bazel repo cache
uses: actions/cache@v2
with:
path: "~/.cache/bazel-repo"
key: bazel-repo

- name: bzlmod gazelle
env:
# Bazelisk will download bazel to here, ensure it is cached between runs.
XDG_CACHE_HOME: ~/.cache/bazel-repo
run: bazelisk --bazelrc=.github/workflows/ci.bazelrc test //java/gazelle/...
6 changes: 6 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ bazel_dep(
version = "0.36.0",
repo_name = "bazel_gazelle",
)
git_override(
module_name = "gazelle",
commit = "ba2ce367a545e0bdd74a7abca40ef5e0a0cb8dcb",
remote = "https://github.com/bazelbuild/bazel-gazelle.git",
)

bazel_dep(
name = "protobuf",
version = PROTOBUF_VERSION,
Expand Down
6 changes: 1 addition & 5 deletions examples/gazelle/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
common --enable_platform_specific_config

# https://bazel.build/docs/windows#symlink
startup --windows_enable_symlinks
run:windows --enable_runfiles
import %workspace%/../../.bazelrc.windows
5 changes: 5 additions & 0 deletions examples/gazelle/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,8 @@ bazel_dep(
name = "gazelle",
version = "0.36.0",
)
git_override(
module_name = "gazelle",
commit = "ba2ce367a545e0bdd74a7abca40ef5e0a0cb8dcb",
remote = "https://github.com/bazelbuild/bazel-gazelle.git",
)
2 changes: 1 addition & 1 deletion examples/gazelle/src/test/com/example/gazelle/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@contrib_rules_jvm//java:defs.bzl", "java_test_suite")
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@contrib_rules_jvm//java:defs.bzl", "java_test_suite")

genquery(
name = "generated_targets",
Expand Down
1 change: 1 addition & 0 deletions examples/tests_and_lints/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import %workspace%/../../.bazelrc.windows
7 changes: 4 additions & 3 deletions repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ def contrib_rules_jvm_gazelle_deps():
],
)

# We need https://github.com/bazelbuild/bazel-gazelle/pull/1686
# We need https://github.com/bazelbuild/bazel-gazelle/pull/1798
maybe(
http_archive,
name = "bazel_gazelle",
sha256 = "75df288c4b31c81eb50f51e2e14f4763cb7548daae126817247064637fd9ea62",
url = "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz",
sha256 = "d1d72a9abd6dee362354274fa9b60ced8f50ee1f10f9b9fef90b4acfb98d477b",
strip_prefix = "bazel-gazelle-ba2ce367a545e0bdd74a7abca40ef5e0a0cb8dcb",
url = "https://github.com/bazelbuild/bazel-gazelle/archive/ba2ce367a545e0bdd74a7abca40ef5e0a0cb8dcb.zip",
)

maybe(
Expand Down

0 comments on commit 01812dd

Please sign in to comment.