Skip to content

#641 Upgrade deps/Kotlin/JVM/C++/Bazel/bzlmod. #640

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bzl-examples/
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14
build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.3.2
7.6.1
22 changes: 19 additions & 3 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
pull_request:
workflow_dispatch:
jobs:
bazel:
runs-on: ubuntu-latest
Expand All @@ -14,23 +15,38 @@ jobs:
with:
path: "/home/runner/.cache/bazel"
key: bazel
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Install bazelisk
run: |
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.1.0/bazelisk-linux-amd64"
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.26.0/bazelisk-linux-amd64"
mkdir -p "${GITHUB_WORKSPACE}/bin/"
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
- name: Build
uses: nick-invision/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: |
cd "${GITHUB_WORKSPACE}"
"${GITHUB_WORKSPACE}/bin/bazel" build //...
- name: Test
uses: nick-invision/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: |
cd "${GITHUB_WORKSPACE}"
"${GITHUB_WORKSPACE}/bin/bazel" test //...
- name: Build
- name: Test bzl-examples/bzlmod
uses: nick-invision/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: |
"${GITHUB_WORKSPACE}/bin/bazel" build //...
cd "${GITHUB_WORKSPACE}/bzl-examples/bzlmod"
"${GITHUB_WORKSPACE}/bin/bazel" test //...
19 changes: 11 additions & 8 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
# Local:
# $ act -P ubuntu-latest=catthehacker/ubuntu:act-latest -W .github/workflows/gradle.yml
name: Gradle Build
on:
push:
branches:
- master
pull_request:

workflow_dispatch:
jobs:
gradle:
strategy:
matrix:
os: [ubuntu-latest, macos-12]
os: [ubuntu-latest, macos-13]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
java-version: '11'
cache: 'gradle'

- uses: gradle/gradle-build-action@v3
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3

- name: Test on Mac
if: matrix.os == 'macos-12'
if: matrix.os == 'macos-13'
run: |
brew install docker
brew install docker colima
colima start --network-address
export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock
export TESTCONTAINERS_HOST_OVERRIDE=$(colima ls -j | jq -r '.address')
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '11'
cache: 'gradle'
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/gradle-build-action@v3
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3

- name: release
env:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ build
local.properties
*.iml
/bazel-*
MODULE.bazel.lock
*/bin/*
34 changes: 34 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module(
name = "com_github_grpc_grpc_kotlin",
version = "2.1.0",
)

bazel_dep(name = "protobuf", repo_name = "com_google_protobuf", version = "30.2")
bazel_dep(name = "rules_kotlin", repo_name = "io_bazel_rules_kotlin", version = "2.1.3")
bazel_dep(name = "rules_java", version = "8.11.0")
bazel_dep(name = "rules_jvm_external", version = "6.7")
bazel_dep(name = "grpc-java", repo_name = "io_grpc_grpc_java", version = "1.71.0")

grpc_kotlin_maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
grpc_kotlin_maven.install(
name = "grpc_kotlin_maven",
# Rerun whenever adding new artifacts.
# $ REPIN=1 bazelisk run @grpc_kotlin_maven//:pin
artifacts = [
"com.google.jimfs:jimfs:1.3.0",
"com.google.truth:truth:1.4.2",
"com.google.truth.extensions:truth-proto-extension:1.4.2",
"com.google.protobuf:protobuf-java:4.30.2",
"com.google.protobuf:protobuf-kotlin:4.30.2",
"com.google.guava:guava:33.3.1-android",
"com.squareup:kotlinpoet:1.14.2",
"junit:junit:4.13.2",
"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1",
"org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.10.1",
],
fetch_sources = False,
lock_file = "//:grpc_kotlin_maven_install.json",
generate_compat_repositories = True,
strict_visibility = True,
)
use_repo(grpc_kotlin_maven, "grpc_kotlin_maven")
70 changes: 0 additions & 70 deletions WORKSPACE

This file was deleted.

6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ subprojects {
version = rootProject.version

tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
sourceCompatibility = JavaVersion.VERSION_17.toString()
targetCompatibility = JavaVersion.VERSION_17.toString()
}

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = JavaVersion.VERSION_1_8.toString()
jvmTarget = JavaVersion.VERSION_17.toString()
}
}

Expand Down
1 change: 1 addition & 0 deletions bzl-examples/bzlmod/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
1 change: 1 addition & 0 deletions bzl-examples/bzlmod/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.6.1
2 changes: 2 additions & 0 deletions bzl-examples/bzlmod/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bazel-*
MODULE.bazel.lock
16 changes: 16 additions & 0 deletions bzl-examples/bzlmod/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@aspect_rules_lint//format:defs.bzl", "format_multirun")
load("@rules_java//java:defs.bzl", "java_binary")

java_binary(
name = "ktfmt",
main_class = "com.facebook.ktfmt.cli.Main",
runtime_deps = ["@ktfmt//jar"],
)

format_multirun(
name = "format",
kotlin = ":ktfmt",
protocol_buffer = "@rules_buf_toolchains//:buf",
starlark = "@buildifier_prebuilt//:buildifier",
visibility = ["//visibility:public"],
)
41 changes: 41 additions & 0 deletions bzl-examples/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module(
name = "bzlmod",
version = "1.0",
)

bazel_dep(name = "protobuf", version = "30.2")
bazel_dep(name = "rules_kotlin", version = "2.1.3")
bazel_dep(name = "com_github_grpc_grpc_kotlin", version = "0.0.0")
bazel_dep(name = "rules_jvm_external", version = "6.7")
bazel_dep(name = "aspect_rules_lint", version = "1.3.4")
bazel_dep(name = "rules_java", version = "8.11.0")
bazel_dep(name = "buildifier_prebuilt", version = "8.0.3")
bazel_dep(name = "rules_buf", version = "0.3.0")

local_path_override(
module_name = "com_github_grpc_grpc_kotlin",
path = "../../",
)

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
# Rerun whenever adding new artifacts.
# $ REPIN=1 bazelisk run @maven//:pin
artifacts = [
"com.google.truth:truth:1.4.2",
"junit:junit:4.13.2",
"com.google.truth.extensions:truth-proto-extension:1.4.4",
"io.grpc:grpc-testing:1.71.0",
],
fetch_sources = False,
generate_compat_repositories = True,
lock_file = "//:maven_install.json",
strict_visibility = True,
)
use_repo(maven, "maven", "grpc_kotlin_maven")

install_ktfmt = use_extension("//:extensions.bzl", "install_ktfmt")
use_repo(install_ktfmt, "ktfmt")

buf = use_extension("@rules_buf//buf:extensions.bzl", "buf")
use_repo(buf, "rules_buf_toolchains")
6 changes: 6 additions & 0 deletions bzl-examples/bzlmod/extensions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
load("@aspect_rules_lint//format:repositories.bzl", "fetch_ktfmt")

def _install_ktfmt_impl(module_ctx):
fetch_ktfmt()

install_ktfmt = module_extension(_install_ktfmt_impl)
31 changes: 31 additions & 0 deletions bzl-examples/bzlmod/java/io/grpc/examples/bzlmod/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
load("@com_github_grpc_grpc_kotlin//:kt_jvm_grpc.bzl", "kt_jvm_grpc_library", "kt_jvm_proto_library")
load("@protobuf//bazel:proto_library.bzl", "proto_library")
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")

package(default_visibility = ["//javatests/io/grpc/examples/bzlmod:__subpackages__"])

proto_library(
name = "fibonacci_proto",
srcs = ["fibonacci.proto"],
deps = [],
)

kt_jvm_proto_library(
name = "fibonacci_kt_proto",
deps = [":fibonacci_proto"],
)

kt_jvm_grpc_library(
name = "fibonacci_kt_grpc",
srcs = [":fibonacci_proto"],
deps = [":fibonacci_kt_proto"],
)

kt_jvm_library(
name = "fibonacci",
srcs = ["Fibonacci.kt"],
deps = [
":fibonacci_kt_grpc",
":fibonacci_kt_proto",
],
)
19 changes: 19 additions & 0 deletions bzl-examples/bzlmod/java/io/grpc/examples/bzlmod/Fibonacci.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.grpc.examples.bzlmod

/** A simple implementation of a Fibonacci service. */
class Fibonacci : FibonacciServiceGrpcKt.FibonacciServiceCoroutineImplBase() {
override suspend fun query(request: QueryRequest): QueryResponse {
if (request.nth <= 1) {
return queryResponse { nthFibonacci = request.nth }
}
var prv = 0L
var cur = 1L
var nxt = 1L
for (i in 2..request.nth) {
prv = cur
cur = nxt
nxt = (prv + cur) % request.mod
}
return queryResponse { nthFibonacci = cur }
}
}
Loading
Loading