diff --git a/.github/workflows/ci.bazelrc b/.github/workflows/ci.bazelrc new file mode 100644 index 0000000..7257cd0 --- /dev/null +++ b/.github/workflows/ci.bazelrc @@ -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 +# Don't rely on test logs being easily accessible from the test runner, +# though it makes the log noisier. +test --test_output=errors +# This directory is configured in GitHub actions to be persisted between runs. +build --disk_cache=$HOME/.cache/bazel +build --repository_cache=$HOME/.cache/bazel-repo +# Allows tests to run bazelisk-in-bazel, since this is the cache folder used +test --test_env=XDG_CACHE_HOME +# Keep until @io_bazel_rules_scala is upgraded +build --incompatible_java_common_parameters=false diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..7f69011 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,48 @@ +name: CI + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: [master] + pull_request: + branches: [master] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + test: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - uses: actions/checkout@v3 + + - uses: bazelbuild/setup-bazelisk@v2 + + - name: Mount bazel action cache + uses: actions/cache@v3 + if: always() + with: + path: "~/.cache/bazel" + key: bazel + + - name: Mount bazel repo cache + uses: actions/cache@v3 + if: always() + with: + path: "~/.cache/bazel-repo" + key: bazel-repo + + - name: bazel test + env: + # Bazelisk will download bazel to here, ensure it is cached between runs. + XDG_CACHE_HOME: ~/.cache/bazel-repo + run: >- + bazel + --bazelrc=.github/workflows/ci.bazelrc + --bazelrc=.bazelrc + test + ... diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..8e5db1b --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,69 @@ +# Cut a release whenever a new tag is pushed to the repo. +# You should use an annotated tag, like `git tag -a v1.2.3` +# and put the release notes into the commit message for the tag. +name: Release + +on: + push: + tags: + - "v*.*.*" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set output + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + + - name: Mount bazel action cache + uses: actions/cache@v3 + if: always() + with: + path: "~/.cache/bazel" + key: bazel + + - name: Mount bazel repo cache + uses: actions/cache@v3 + if: always() + with: + path: "~/.cache/bazel-repo" + key: bazel-repo + + - name: build release binaries + env: + # Bazelisk will download bazel to here + XDG_CACHE_HOME: ~/.cache/bazel-repo + run: >- + bazel + --bazelrc=.github/workflows/ci.bazelrc + --bazelrc=.bazelrc + build + //cmd/grpc-starlark:all + + - name: Prepare release assets + env: + # Bazelisk will download bazel to here + RELEASE_VERSION: ${{ steps.vars.outputs.tag }} + run: >- + cp bazel-bin/cmd/grpc-starlark/grpc-starlark_darwin_amd64.zip grpc-starlark_darwin_amd64.${{ env.RELEASE_VERSION }}.zip && + cp bazel-bin/cmd/grpc-starlark/grpc-starlark_darwin_arm64.zip grpc-starlark_darwin_arm64.${{ env.RELEASE_VERSION }}.zip && + cp bazel-bin/cmd/grpc-starlark/grpc-starlark_linux_amd64.zip grpc-starlark_linux_amd64.${{ env.RELEASE_VERSION }}.zip && + cp bazel-bin/cmd/grpc-starlark/grpc-starlark_linux_arm64.zip grpc-starlark_linux_arm64.${{ env.RELEASE_VERSION }}.zip && + cp bazel-bin/cmd/grpc-starlark/grpc-starlark_windows_amd64.zip grpc-starlark_windows_amd64.${{ env.RELEASE_VERSION }}.zip && + echo "done" + + - name: Release + env: + RELEASE_VERSION: ${{ steps.vars.outputs.tag }} + uses: softprops/action-gh-release@v1 + with: + files: | + grpc-starlark_darwin_amd64.${{ env.RELEASE_VERSION }}.zip + grpc-starlark_darwin_arm64.${{ env.RELEASE_VERSION }}.zip + grpc-starlark_linux_amd64.${{ env.RELEASE_VERSION }}.zip + grpc-starlark_linux_arm64.${{ env.RELEASE_VERSION }}.zip + grpc-starlark_windows_amd64.${{ env.RELEASE_VERSION }}.zip diff --git a/example/routeguide/BUILD.bazel b/example/routeguide/BUILD.bazel index 9c7568a..658d014 100644 --- a/example/routeguide/BUILD.bazel +++ b/example/routeguide/BUILD.bazel @@ -33,10 +33,15 @@ sh_test( genrule( name = "grpcurl_tool", srcs = select({ - "@bazel_tools//src/conditions:darwin_x86_64": ["@github_com_fullstorydev_grpcurl_releases_download_v1_8_7_grpcurl_1_8_7_osx_arm64_tar_gz//:file"], - "@bazel_tools//src/conditions:linux_x86_64": ["@github_com_fullstorydev_grpcurl_releases_download_v1_8_7_grpcurl_1_8_7_osx_arm64_tar_gz//:file"], - "@bazel_tools//src/conditions:windows": ["@github_com_fullstorydev_grpcurl_releases_download_v1_8_7_grpcurl_1_8_7_osx_arm64_tar_gz//:file"], - "//conditions:default": ["@github_com_fullstorydev_grpcurl_releases_download_v1_8_7_grpcurl_1_8_7_osx_arm64_tar_gz//:file"], + "@bazel_tools//src/conditions:darwin_x86_64": [ + "@github_com_fullstorydev_grpcurl_releases_download_v1_8_7_grpcurl_1_8_7_osx_x86_64_tar_gz//:file", + ], + "@bazel_tools//src/conditions:darwin_arm64": [ + "@github_com_fullstorydev_grpcurl_releases_download_v1_8_7_grpcurl_1_8_7_osx_arm64_tar_gz//:file", + ], + "//conditions:default": [ + "@github_com_fullstorydev_grpcurl_releases_download_v1_8_7_grpcurl_1_8_7_linux_x86_64_tar_gz//:file", + ], }), outs = ["grpcurl.exe"], cmd = "cp $(SRCS) $@", diff --git a/repositories.bzl b/repositories.bzl index 220d180..b0f79de 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -144,9 +144,9 @@ def com_google_protobuf(): def grpcurl_deps(): _maybe( http_archive, - name = "github_com_fullstorydev_grpcurl_releases_download_v1_8_7_grpcurl_1_8_7_linux_arm64_tar_gz", - sha256 = "9859ba9e1855748ef76c47673e033a374fe3a8d5f0d516baa6befd00b4de0b43", - urls = ["https://github.com/fullstorydev/grpcurl/releases/download/v1.8.7/grpcurl_1.8.7_linux_arm64.tar.gz"], + name = "github_com_fullstorydev_grpcurl_releases_download_v1_8_7_grpcurl_1_8_7_linux_x86_64_tar_gz", + sha256 = "b50a9c9cdbabab03c0460a7218eab4a954913d696b4d69ffb720f42d869dbdd5", + urls = ["https://github.com/fullstorydev/grpcurl/releases/download/v1.8.7/grpcurl_1.8.7_linux_x86_64.tar.gz"], build_file_content = """ filegroup( name = "file", @@ -155,7 +155,6 @@ filegroup( ) """, ) - _maybe( http_archive, name = "github_com_fullstorydev_grpcurl_releases_download_v1_8_7_grpcurl_1_8_7_osx_arm64_tar_gz", @@ -166,6 +165,19 @@ filegroup( name = "file", srcs = ["grpcurl"], visibility = ["//visibility:public"], +) + """, + ) + _maybe( + http_archive, + name = "github_com_fullstorydev_grpcurl_releases_download_v1_8_7_grpcurl_1_8_7_osx_x86_64_tar_gz", + sha256 = "1add67199bd114dc1a4fb8dcd129ab7709f54be0235e6ae683498783bb98242e", + urls = ["https://github.com/fullstorydev/grpcurl/releases/download/v1.8.7/grpcurl_1.8.7_osx_x86_64.tar.gz"], + build_file_content = """ +filegroup( + name = "file", + srcs = ["grpcurl"], + visibility = ["//visibility:public"], ) """, )