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

bzlmod #387

Merged
merged 31 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 13 additions & 153 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,164 +1,24 @@
---
bazel: 6.3.2

buildifier:
version: latest
version: 6.3.3

matrix:
platform: ["windows", "ubuntu1804", "rbe_ubuntu1604", "macos"]
working_directory: ["", "examples"]
strict_deps: ["--@rules_dotnet//dotnet/settings:strict_deps=true", "--@rules_dotnet//dotnet/settings:strict_deps=false"]
flag_combo: [["--enable_bzlmod", "--@rules_dotnet//dotnet/settings:strict_deps=true"], ["--enable_bzlmod", "--@rules_dotnet//dotnet/settings:strict_deps=false"], ["--noenable_bzlmod", "--@rules_dotnet//dotnet/settings:strict_deps=true"], ["--noenable_bzlmod", "--@rules_dotnet//dotnet/settings:strict_deps=false"]]

tasks:
windows:
name: Rules on Windows
platform: windows
include_json_profile:
- build
- test
build_targets:
- "//..."
test_targets:
- "//..."
build_flags:
- "--noenable_bzlmod"
test_flags:
- "--noenable_bzlmod"
ubuntu1804:
name: Rules on Linux
platform: ubuntu1804
include_json_profile:
- build
- test
build_targets:
- "//..."
test_targets:
- "//..."
build_flags:
- "--noenable_bzlmod"
test_flags:
- "--noenable_bzlmod"
rbe_ubuntu1604:
name: Rules on Linux (RBE)
platform: rbe_ubuntu1604
include_json_profile:
- build
- test
build_targets:
- "//..."
test_targets:
- "//..."
build_flags:
- "--config=remote"
- "--noenable_bzlmod"
test_flags:
- "--config=remote"
- "--noenable_bzlmod"
rbe_ubuntu1604_no_strict_deps:
name: Rules on Linux (RBE) without strict deps
platform: rbe_ubuntu1604
include_json_profile:
- build
- test
build_targets:
- "//..."
test_targets:
- "//..."
build_flags:
- "--@rules_dotnet//dotnet/settings:strict_deps=false"
- "--config=remote"
- "--noenable_bzlmod"
test_flags:
- "--@rules_dotnet//dotnet/settings:strict_deps=false"
- "--config=remote"
- "--noenable_bzlmod"
macos:
name: Rules on MacOS
platform: macos
include_json_profile:
- build
- test
build_targets:
- "//..."
test_targets:
- "//..."
build_flags:
- "--noenable_bzlmod"
test_flags:
- "--noenable_bzlmod"
examples-windows:
name: Examples on Windows
platform: windows
include_json_profile:
- build
- test
working_directory: examples
build_targets:
- "//..."
test_targets:
- "//..."
build_flags:
- "--noenable_bzlmod"
test_flags:
- "--noenable_bzlmod"
examples-ubuntu1804:
name: Examples on Ubuntu 18.04
platform: ubuntu1804
include_json_profile:
- build
- test
working_directory: examples
build_targets:
- "//..."
test_targets:
- "//..."
build_flags:
- "--noenable_bzlmod"
test_flags:
- "--noenable_bzlmod"
examples-macos:
name: Examples on macOS
platform: macos
include_json_profile:
- build
- test
working_directory: examples
build_targets:
- "//..."
test_targets:
- "//..."
build_flags:
- "--noenable_bzlmod"
test_flags:
- "--noenable_bzlmod"
examples-rbe_ubuntu1604:
name: Examples on Ubuntu 18.04 (RBE)
platform: rbe_ubuntu1604
include_json_profile:
- build
- test
working_directory: examples
build_targets:
- "//..."
test_targets:
- "//..."
build_flags:
- "--config=remote"
- "--noenable_bzlmod"
test_flags:
- "--config=remote"
- "--noenable_bzlmod"
examples-rbe_ubuntu1604_no_strict_deps:
name: Examples on Ubuntu 18.04 (RBE) without strict deps
platform: rbe_ubuntu1604
test_all:
name: Build and test
platform: ${{ platform }}
working_directory: ${{ working_directory }}
include_json_profile:
- build
- test
working_directory: examples
build_targets:
- "//..."
test_targets:
- "//..."
build_flags:
- "--config=remote"
- "--@rules_dotnet//dotnet/settings:strict_deps=false"
- "--noenable_bzlmod"
test_flags:
- "--config=remote"
- "--@rules_dotnet//dotnet/settings:strict_deps=false"
- "--noenable_bzlmod"
build_flags: ${{ flag_combo }}
test_flags: ${{ flag_combo }}
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
examples
e2e
49 changes: 9 additions & 40 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,46 +1,15 @@
startup --windows_enable_symlinks
build --enable_runfiles
build --incompatible_strict_action_env
test --test_output=errors

# Remote config
build:remote --remote_download_minimal
build:remote --action_env=DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
common --enable_runfiles
common --incompatible_strict_action_env
common --test_output=errors

# Profiling flags
build --noslim_profile
query --noslim_profile
build --experimental_profile_include_target_label
query --experimental_profile_include_target_label
build --experimental_profile_include_primary_output
query --experimental_profile_include_primary_output
build --experimental_collect_load_average_in_profiler
query --experimental_collect_load_average_in_profiler
build --experimental_collect_system_network_usage
query --experimental_collect_system_network_usage
build --experimental_collect_worker_data_in_profiler
query --experimental_collect_worker_data_in_profiler

# Bazel 7.0 flags
# These flags will be flipped in 7.0 so we set them to be compatible when it's released
build --incompatible_config_setting_private_default_visibility
build --incompatible_disable_starlark_host_transitions

# Docker RBE setup, useful for debugging RBE issues
build:docker-sandbox --java_runtime_version=rbe_jdk
build:docker-sandbox --tool_java_runtime_version=rbe_jdk
build:docker-sandbox --extra_toolchains=@buildkite_config//java:all
build:docker-sandbox --crosstool_top=@buildkite_config//cc:toolchain
build:docker-sandbox --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
build:docker-sandbox --extra_toolchains=@buildkite_config//config:cc-toolchain
build:docker-sandbox --extra_execution_platforms=@buildkite_config//config:platform
build:docker-sandbox --host_platform=@buildkite_config//config:platform
build:docker-sandbox --platforms=@buildkite_config//config:platform
build:docker-sandbox --spawn_strategy=docker --strategy=Javac=docker --genrule_strategy=docker
build:docker-sandbox --define=EXECUTOR=remote
build:docker-sandbox --experimental_docker_verbose
build:docker-sandbox --experimental_enable_docker_sandbox
build:docker-sandbox --experimental_docker_image=gcr.io/bazel-public/ubuntu1804-bazel-java11@sha256:2d50853a7edbe59a99bc4141d7a03cb1068157b9766077302b46c4ec94eef151
common --noslim_profile
common --experimental_profile_include_target_label
common --experimental_profile_include_primary_output
common --experimental_collect_load_average_in_profiler
common --experimental_collect_system_network_usage
common --experimental_collect_worker_data_in_profiler

# Load any settings specific to the current user.
# .bazelrc.user should appear in .gitignore so that settings are not shared with team members
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.3.2
7.0.0rc4
9 changes: 9 additions & 0 deletions .bcr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Bazel Central Registry

When the ruleset is released, we want it to be published to the
Bazel Central Registry automatically:
<https://registry.bazel.build>

This folder contains configuration files to automate the publish step.
See <https://github.com/bazel-contrib/publish-to-bcr/blob/main/templates/README.md>
for authoritative documentation about these files.
4 changes: 4 additions & 0 deletions .bcr/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# See https://github.com/bazel-contrib/publish-to-bcr#a-note-on-release-automation
fixedReleaser:
login: purkhusid
email: purkhusid@gmail.com
15 changes: 15 additions & 0 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"homepage": "https://github.com/bazelbuild/rules_dotnet",
"maintainers": [
{
"name": "Daníel Poul Purkhús",
"email": "purkhusid@gmail.com",
"github": "purkhusid"
}
],
"repository": [
"github:bazelbuild/rules_dotnet"
],
"versions": [],
"yanked_versions": {}
}
10 changes: 10 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
bcr_test_module:
module_path: "e2e/smoke"
matrix:
platform: ["debian10", "macos", "ubuntu2004", "windows"]
tasks:
run_tests:
name: "Run smoke test"
platform: ${{ platform }}
test_targets:
- "//..."
5 changes: 5 additions & 0 deletions .bcr/source.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"integrity": "**leave this alone**",
"strip_prefix": "{REPO}-{VERSION}",
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/rules_dotnet-{TAG}.tar.gz"
}
Empty file added .github/workflows/BUILD.bazel
Empty file.
15 changes: 15 additions & 0 deletions .github/workflows/ci.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file contains Bazel settings to apply on CI only.
# It is referenced with a --bazelrc option in the call to bazel in ci.yaml

# Debug where options came from
build --announce_rc
# This directory is configured in GitHub actions to be persisted between runs.
# We do not enable the repository cache to cache downloaded external artifacts
# as these are generally faster to download again than to fetch them from the
# GitHub actions cache.
build --disk_cache=~/.cache/bazel
# Don't rely on test logs being easily accessible from the test runner,
# though it makes the log noisier.
test --test_output=errors
# Allows tests to run bazelisk-in-bazel, since this is the cache folder used
test --test_env=XDG_CACHE_HOME
19 changes: 4 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,7 @@ on:
- "v*.*.*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prepare workspace snippet
run: .github/workflows/workspace_snippet.sh ${{ env.GITHUB_REF_NAME }} > release_notes.txt
- name: Release
uses: softprops/action-gh-release@v1
with:
# Use GH feature to populate the changelog automatically
generate_release_notes: true
body_path: release_notes.txt
fail_on_unmatched_files: true
files: rules_dotnet-*.tar.gz
release:
uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v4
with:
release_files: rules_dotnet-*.tar.gz
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,45 @@ set -o errexit -o nounset -o pipefail
# Set by GH actions, see
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
TAG=${GITHUB_REF_NAME}

# The prefix is chosen to match what GitHub generates for source archives
# This guarantees that users can easily switch from a released artifact to a source archive
# with minimal differences in their code (e.g. strip_prefix remains the same)
PREFIX="rules_dotnet-${TAG:1}"
ARCHIVE="rules_dotnet-$TAG.tar.gz"

# NB: configuration for 'git archive' is in /.gitattributes
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')

cat << EOF
## Using Bzlmod with Bazel 7 (We require Bazel 7 and above)

1. Add to your \`MODULE.bazel\` file:

\`\`\`starlark
bazel_dep(name = "rules_dotnet", version = "${TAG:1}")

dotnet = use_extension("@rules_dotnet//dotnet:extensions.bzl", "dotnet")
dotnet.toolchain(dotnet_version = "7.0.101")
use_repo(dotnet, "dotnet_toolchains")

register_toolchains("@dotnet_toolchains//:all")

rules_dotnet_nuget_packages_extension = use_extension("@rules_dotnet//dotnet:paket.rules_dotnet_nuget_packages_extension.bzl", "rules_dotnet_nuget_packages_extension")
use_repo(rules_dotnet_nuget_packages_extension, "paket.rules_dotnet_nuget_packages")
\`\`\`

## Using WORKSPACE

Paste this snippet into your \`WORKSPACE\` file:
Paste this snippet into your `WORKSPACE.bazel` file:

\`\`\`starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_dotnet",
sha256 = "${SHA}",
strip_prefix = "${PREFIX}",
url = "https://github.com/bazelbuild/rules_dotnet/releases/download/${TAG}/rules_dotnet-${TAG}.tar.gz",
url = "https://github.com/bazelbuild/rules_dotnet/releases/download/${TAG}/${ARCHIVE}",
)

load(
Expand All @@ -40,7 +57,7 @@ rules_dotnet_dependencies()
# Here you can specify the version of the .NET SDK to use.
dotnet_register_toolchains("dotnet", "7.0.101")

load("@rules_dotnet//dotnet:rules_dotnet_nuget_packages.bzl", "rules_dotnet_nuget_packages")
load("@rules_dotnet//dotnet:paket.rules_dotnet_nuget_packages.bzl", "rules_dotnet_nuget_packages")

rules_dotnet_nuget_packages()
\`\`\`
Expand Down
Loading