Skip to content

Migrate from sbt to bazel #615

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

Merged
merged 104 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from 97 commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
78af2a6
Migrate from sbt to bazel
agluszak Sep 27, 2023
ddeaece
Fix
agluszak Sep 27, 2023
e41b5d7
Fix documentation generation (#616)
KatKlo Sep 28, 2023
c326796
Revert java formatting
agluszak Oct 2, 2023
76b4ae9
Fixes
agluszak Oct 2, 2023
9c7c5f9
Fixes
agluszak Oct 2, 2023
6c0e2fb
Fix formatting
agluszak Oct 4, 2023
9fec740
Fix formatting
agluszak Oct 4, 2023
aa5a6da
Fix workspace
agluszak Oct 5, 2023
2b1a352
Fix
agluszak Oct 9, 2023
096e02b
Update to docusaurus 3
agluszak Nov 10, 2023
99535f3
Merge branch 'master' into agluszak/docusaurus-3
agluszak Nov 17, 2023
f50f2f7
Fix workspace
agluszak Nov 20, 2023
7707a1e
Bump
agluszak Nov 20, 2023
ce721c0
update according to bsp-generators (#628)
KatKlo Nov 24, 2023
2d3bd48
Merge remote-tracking branch 'origin/master' into agluszak/bazel
agluszak Nov 24, 2023
34233a6
WIP
agluszak Nov 24, 2023
1805a01
WIP
agluszak Nov 24, 2023
299b1c2
WIP
agluszak Nov 24, 2023
3b42487
Merge branch 'master' into agluszak/bazel
agluszak Feb 28, 2024
19600e8
Big update: migrate to bazel 7 & bzlmod, use new formatting rules
agluszak Feb 29, 2024
2b096b4
Merge remote-tracking branch 'origin/agluszak/docusaurus-3' into aglu…
agluszak Feb 29, 2024
587dea3
Fix
agluszak Feb 29, 2024
a987562
Fix
agluszak Feb 29, 2024
acd6b7f
WIP
agluszak Mar 7, 2024
c7e9f84
WIP
agluszak Mar 7, 2024
d6be090
WIP
agluszak Mar 7, 2024
c4688ff
WIP
agluszak Mar 7, 2024
2a567c7
WIP
agluszak Mar 7, 2024
4f03763
WIP
agluszak Mar 7, 2024
2060c1b
WIP
agluszak Mar 7, 2024
0b6be5d
WIP
agluszak Mar 7, 2024
dbb6a02
WIP
agluszak Mar 7, 2024
4c9bc60
WIP
agluszak Mar 7, 2024
d886a7f
WIP
agluszak Mar 8, 2024
7e7a602
WIP
agluszak Mar 8, 2024
b5026ef
WIP
agluszak Mar 8, 2024
903ebc9
WIP
agluszak Mar 8, 2024
5365deb
WIP
agluszak Mar 18, 2024
7b7517e
WIP
agluszak Mar 18, 2024
d81bf0c
WIP
agluszak Mar 18, 2024
397e1d0
WIP
agluszak Mar 18, 2024
96d468c
WIP
agluszak Mar 18, 2024
d2e0a5f
WIP
agluszak Mar 18, 2024
a32a858
WIP
agluszak Mar 18, 2024
c7139bf
WIP
agluszak Mar 18, 2024
391445b
WIP
agluszak Mar 18, 2024
7bfcf67
WIP
agluszak Mar 18, 2024
2543a0e
WIP
agluszak Mar 18, 2024
1e33921
WIP
agluszak Mar 18, 2024
d7cbfe8
WIP
agluszak Mar 18, 2024
facc8a0
WIP
agluszak Mar 18, 2024
882af81
WIP
agluszak Mar 18, 2024
c4e3216
WIP
agluszak Mar 18, 2024
6bfb056
WIP
agluszak Mar 18, 2024
dcda1e4
WIP
agluszak Mar 18, 2024
a73b157
WIP
agluszak Mar 18, 2024
ad4fba2
WIP
agluszak Mar 18, 2024
d972ddf
WIP
agluszak Mar 18, 2024
9c929a3
WIP
agluszak Mar 18, 2024
cd4e370
WIP
agluszak Mar 18, 2024
d72ed83
WIP
agluszak Mar 18, 2024
4edf259
WIP
agluszak Mar 18, 2024
0153a1b
WIP
agluszak Mar 18, 2024
e9d3b0b
WIP
agluszak Mar 18, 2024
29c5e27
WIP
agluszak Mar 18, 2024
cd9e004
WIP
agluszak Mar 19, 2024
8a8a8c0
WIP
agluszak Mar 19, 2024
d772aaa
WIP
agluszak Mar 19, 2024
df8fd51
WIP
agluszak Mar 19, 2024
f5f4740
WIP
agluszak Mar 19, 2024
c91c203
WIP
agluszak Mar 19, 2024
070aebe
WIP
agluszak Mar 30, 2024
27c1951
fix
agluszak Mar 30, 2024
650c7a1
Fix
agluszak Mar 30, 2024
c7d3a2c
Fix
agluszak Mar 30, 2024
b3d3da9
WIP
agluszak Apr 22, 2024
1eebd92
WIP
agluszak Apr 22, 2024
34780cf
WIP
agluszak Apr 22, 2024
955efd1
WIP
agluszak Apr 22, 2024
de90a95
WIP
agluszak Apr 22, 2024
1d490ca
WIP
agluszak Apr 22, 2024
97753d3
WIP
agluszak Apr 22, 2024
5c5e0f7
WIP
agluszak Apr 22, 2024
604a157
WIP
agluszak Apr 22, 2024
10fa033
WIP
agluszak Apr 22, 2024
00a5a87
Handle missing newline in private key
agluszak Apr 22, 2024
2f1631d
WIP
agluszak Apr 22, 2024
2b194fa
WIP
agluszak Apr 22, 2024
984ffb3
WIP
agluszak Apr 22, 2024
83ce535
WIP
agluszak Apr 22, 2024
6f933f2
WIP
agluszak Apr 23, 2024
7584e39
WIP
agluszak May 24, 2024
0ed03cc
Fix
agluszak May 28, 2024
381e22a
Fix
agluszak May 28, 2024
8b03a2d
Fix
agluszak May 28, 2024
fdf839d
Fix
agluszak May 28, 2024
d369cb2
Fix
agluszak May 28, 2024
b3846de
Fix
agluszak May 28, 2024
f19789b
Fix
agluszak May 28, 2024
d24d711
Fix
agluszak May 28, 2024
d11effa
Fix
agluszak May 28, 2024
63961de
Fix
agluszak May 28, 2024
45323e7
Empty-Commit
agluszak May 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
website/node_modules
bazel-out
bazel-bin
bazel-testlogs
152 changes: 152 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# https://docs.aspect.build/guides/bazelrc/

common --java_language_version=17
common --tool_java_language_version=17
common --java_runtime_version=remotejdk_17
common --tool_java_runtime_version=remotejdk_17

# Do not upload locally executed action results to the remote cache.
# This should be the default for local builds so local builds cannot poison the remote cache.
# It should be flipped to `--remote_upload_local_results` on CI
# by using `--bazelrc=.aspect/bazelrc/ci.bazelrc`.
# Docs: https://bazel.build/reference/command-line-reference#flag--remote_upload_local_results
build --noremote_upload_local_results

# Don't allow network access for build actions in the sandbox.
# Ensures that you don't accidentally make non-hermetic actions/tests which depend on remote
# services.
# Developers should tag targets with `tags=["requires-network"]` to opt-out of the enforcement.
# Docs: https://bazel.build/reference/command-line-reference#flag--sandbox_default_allow_network
build --sandbox_default_allow_network=false

# Warn if a test's timeout is significantly longer than the test's actual execution time.
# Bazel's default for test_timeout is medium (5 min), but most tests should instead be short (1 min).
# While a test's timeout should be set such that it is not flaky, a test that has a highly
# over-generous timeout can hide real problems that crop up unexpectedly.
# For instance, a test that normally executes in a minute or two should not have a timeout of
# ETERNAL or LONG as these are much, much too generous.
# Docs: https://bazel.build/docs/user-manual#test-verbose-timeout-warnings
test --test_verbose_timeout_warnings

# Allow the Bazel server to check directory sources for changes. Ensures that the Bazel server
# notices when a directory changes, if you have a directory listed in the srcs of some target.
# Recommended when using
# [copy_directory](https://github.com/aspect-build/bazel-lib/blob/main/docs/copy_directory.md) and
# [rules_js](https://github.com/aspect-build/rules_js) since npm package are source directories
# inputs to copy_directory actions.
# Docs: https://bazel.build/reference/command-line-reference#flag--host_jvm_args
startup --host_jvm_args=-DBAZEL_TRACK_SOURCE_DIRECTORIES=1

# Allow exclusive tests to run in the sandbox. Fixes a bug where Bazel doesn't enable sandboxing for
# tests with `tags=["exclusive"]`.
# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_exclusive_test_sandboxed
test --incompatible_exclusive_test_sandboxed

# Use a static value for `PATH` and does not inherit `LD_LIBRARY_PATH`. Doesn't let environment
# variables like `PATH` sneak into the build, which can cause massive cache misses when they change.
# Use `--action_env=ENV_VARIABLE` if you want to inherit specific environment variables from the
# client, but note that doing so can prevent cross-user caching if a shared cache is used.
# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_strict_action_env
build --incompatible_strict_action_env

# Propagate tags from a target declaration to the actions' execution requirements.
# Ensures that tags applied in your BUILD file, like `tags=["no-remote"]`
# get propagated to actions created by the rule.
# Without this option, you rely on rules authors to manually check the tags you passed
# and apply relevant ones to the actions they create.
# See https://github.com/bazelbuild/bazel/issues/8830 for details.
# Docs: https://bazel.build/reference/command-line-reference#flag--experimental_allow_tags_propagation
build --experimental_allow_tags_propagation
fetch --experimental_allow_tags_propagation
query --experimental_allow_tags_propagation

# Do not automatically create `__init__.py` files in the runfiles of Python targets. Fixes the wrong
# default that comes from Google's internal monorepo by using `__init__.py` to delimit a Python
# package. Precisely, when a `py_binary` or `py_test` target has `legacy_create_init` set to `auto (the
# default), it is treated as false if and only if this flag is set. See
# https://github.com/bazelbuild/bazel/issues/10076.
# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_default_to_explicit_init_py
build --incompatible_default_to_explicit_init_py

# Set default value of `allow_empty` to `False` in `glob()`. This prevents a common mistake when
# attempting to use `glob()` to match files in a subdirectory that is opaque to the current package
# because it contains a BUILD file. See https://github.com/bazelbuild/bazel/issues/8195.
# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_disallow_empty_glob
common --incompatible_disallow_empty_glob

# Always download coverage files for tests from the remote cache. By default, coverage files are not
# downloaded on test result cahce hits when --remote_download_minimal is enabled, making it impossible
# to generate a full coverage report.
# Docs: https://bazel.build/reference/command-line-reference#flag--experimental_fetch_all_coverage_outputs
# detching remote cache results
test --experimental_fetch_all_coverage_outputs

# Attempt to build & test every target whose prerequisites were successfully built.
# Docs: https://bazel.build/docs/user-manual#keep-going
build --keep_going

# Output test errors to stderr so users don't have to `cat` or open test failure log files when test
# fail. This makes the log noiser in exchange for reducing the time-to-feedback on test failures for
# users.
# Docs: https://bazel.build/docs/user-manual#test-output
test --test_output=errors

# Show the output files created by builds that requested more than one target. This helps users
# locate the build outputs in more cases
# Docs: https://bazel.build/docs/user-manual#show-result
build --show_result=20

# Bazel picks up host-OS-specific config lines from bazelrc files. For example, if the host OS is
# Linux and you run bazel build, Bazel picks up lines starting with build:linux. Supported OS
# identifiers are `linux`, `macos`, `windows`, `freebsd`, and `openbsd`. Enabling this flag is
# equivalent to using `--config=linux` on Linux, `--config=windows` on Windows, etc.
# Docs: https://bazel.build/reference/command-line-reference#flag--enable_platform_specific_config
common --enable_platform_specific_config

# Output a heap dump if an OOM is thrown during a Bazel invocation
# (including OOMs due to `--experimental_oom_more_eagerly_threshold`).
# The dump will be written to `<output_base>/<invocation_id>.heapdump.hprof`.
# You may need to configure CI to capture this artifact and upload for later use.
# Docs: https://bazel.build/reference/command-line-reference#flag--heap_dump_on_oom
common --heap_dump_on_oom

# Don't apply `--noremote_upload_local_results` and `--noremote_accept_cached` to the disk cache.
# If you have both `--noremote_upload_local_results` and `--disk_cache`, then this fixes a bug where
# Bazel doesn't write to the local disk cache as it treats as a remote cache.
# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_remote_results_ignore_disk
build --incompatible_remote_results_ignore_disk

# Directories used by sandboxed non-worker execution may be reused to avoid unnecessary setup costs.
# Save time on Sandbox creation and deletion when many of the same kind of action run during the
# build.
# No longer experimental in Bazel 6: https://github.com/bazelbuild/bazel/commit/c1a95501a5611878e5cc43a3cc531f2b9e47835b
# Docs: https://bazel.build/reference/command-line-reference#flag--reuse_sandbox_directories
build --experimental_reuse_sandbox_directories

# Speed up all builds by not checking if external repository files have been modified.
# Docs: https://github.com/bazelbuild/bazel/blob/1af61b21df99edc2fc66939cdf14449c2661f873/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java#L244
build --noexperimental_check_external_repository_files
fetch --noexperimental_check_external_repository_files
query --noexperimental_check_external_repository_files

# Directories used by sandboxed non-worker execution may be reused to avoid unnecessary setup costs.
# Save time on Sandbox creation and deletion when many of the same kind of action run during the
# build.
# Docs: https://bazel.build/reference/command-line-reference#flag--reuse_sandbox_directories
build --reuse_sandbox_directories

# Avoid this flag being enabled by remote_download_minimal or remote_download_toplevel
# See https://meroton.com/blog/bazel-6-errors-build-without-the-bytes/
build --noexperimental_action_cache_store_output_metadata

# Speed up all builds by not checking if output files have been modified. Lets you make changes to
# the output tree without triggering a build for local debugging. For example, you can modify
# [rules_js](https://github.com/aspect-build/rules_js) 3rd party npm packages in the output tree
# when local debugging.
# Docs: https://github.com/bazelbuild/bazel/blob/1af61b21df99edc2fc66939cdf14449c2661f873/src/main/java/com/google/devtools/build/lib/pkgcache/PackageOptions.java#L185
# NB: This flag is in bazel6.bazelrc as when used in Bazel 7 is has been observed to break
# "build without the bytes" --remote_download_outputs=toplevel. See https://github.com/aspect-build/bazel-lib/pull/711
# for more info.
build --noexperimental_check_output_files
fetch --noexperimental_check_output_files
query --noexperimental_check_output_files
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.1.1
4 changes: 3 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
website/generated/**/* linguist-generated=true
bsp4j/src/**/* linguist-generated=true
bsp4s/src/**/* linguist-generated=true
website/generated/**/* linguist-generated=true
3 changes: 0 additions & 3 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ body:
I have a use case where...
validations:
required: true

- type: textarea
id: what
attributes:
label: What do you propose
description: Your proposal to address the "Why" from up above
placeholder: |
In order to address this an idea I have is...

- type: checkboxes
id: check
attributes:
Expand All @@ -27,7 +25,6 @@ body:
options:
- label: I've checked the existing protocol and there isn't a way to do this currently
required: true

- type: checkboxes
id: maintainers
attributes:
Expand Down
1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ updates:
dev-dependencies:
patterns:
- "*" # All updates are grouped in 1 PR

- package-ecosystem: "npm"
directory: "/website"
schedule:
Expand Down
63 changes: 50 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,54 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
- name: Mount bazel cache
uses: actions/cache@v4
with:
distribution: "temurin"
java-version: "11"
cache: "sbt"
- name: Publish ${{ github.ref }}
run: sbt ci-release docs/docusaurusPublishGhpages
env:
GIT_DEPLOY_KEY: ${{ secrets.GIT_DEPLOY_KEY }}
GIT_USER: [email protected]
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
path: '/home/runner/.cache/bazel'
key: bazel
save-always: true
- uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.PGP_SECRET }}
passphrase: ${{ secrets.PGP_PASSPHRASE }}
- name: Generate docs
run: bazel run //website:docusaurus-build
- name: Upload Build Artifact
uses: actions/upload-pages-artifact@v3
with:
path: bazel-out/k8-fastbuild/bin/website/docusaurus-build.sh.runfiles/_main/website/build
- name: Publish bsp4j artifacts
run: |
bazel run \
--define "maven_repo=https://oss.sonatype.org/service/local" \
--define "maven_user=$MAVEN_USER" \
--define "maven_password=$MAVEN_PASSWORD" \
//bsp4j:bsp4j.publish
- name: Publish bsp4s artifacts
run: |
bazel run \
--define "maven_repo=https://oss.sonatype.org/service/local" \
--define "maven_user=$MAVEN_USER" \
--define "maven_password=$MAVEN_PASSWORD" \
//bsp4s:bsp4s.publish
deploy:
name: Deploy to GitHub Pages
needs: publish
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
env:
GIT_DEPLOY_KEY: ${{ secrets.GIT_DEPLOY_KEY }}
GIT_USER: [email protected]
MAVEN_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
MAVEN_USER: ${{ secrets.SONATYPE_USERNAME }}
87 changes: 19 additions & 68 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,80 +14,31 @@ jobs:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "11"
cache: "sbt"

- name: generate
run: sbt generate

distribution: 'temurin'
java-version: '17'
- name: Mount bazel cache
uses: actions/cache@v4
with:
path: '/home/runner/.cache/bazel'
key: bazel
- name: Generate
# Generate libraries and the website
run: bazel run //:generate
- name: Build
run: bazel build //...
- name: Test
run: bazel test //...
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v17
uses: tj-actions/verify-changed-files@v19
id: verify-changed-files
with:
files: |
**/*.java
**/*.scala
**/*.md

bsp4s/src
bsp4j/src
website/generated
- name: Fail if we detect changed files
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
echo "Detected changed files: ${{ steps.verify-changed-files.outputs.changed_files }}"
echo "Make sure to run 'sbt generate' before pushing."
echo "Make sure to run 'bazel run //:generate' before pushing."
Copy link
Member

Choose a reason for hiding this comment

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

will we be able to avoid checking in generated files in the future?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

why?

Copy link
Contributor

Choose a reason for hiding this comment

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

If they can be automatically generated, they should, unless there are good reasons not to (e.g. the tooling needs some remote resources temporarily unavailable or unstable).

exit 1

test:
name: Run tests
needs: check-generation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "11"
cache: "sbt"

- name: compile
run: sbt +compile +package

- name: test
run: sbt +test

docs:
name: Generate docs site
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "11"
cache: "sbt"
- run: sbt docs/docusaurusCreateSite

code-format-check:
name: Check Scala formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "11"
cache: "sbt"
- run: sbt checkScalaFormat

website-format-check:
name: Check website formatting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Prettify code
uses: creyD/[email protected]
with:
dry: true
prettier_options: --ignore-path website/.prettierignore --check .
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,20 @@ out/
.bloop
.metals/
.vscode
.bsp

website/.docusaurus
website/build
website/project

docs-gen
*.xtend

.aspect
bazel-*

# bsp specific
.bsp
.bazelbsp
projectview.bazelproject

__pycache__/
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.bsp/
bazel-*
Loading