Skip to content

Commit

Permalink
Add github workflows (#1)
Browse files Browse the repository at this point in the history
* Add github workflows
* Update select for grpcurl
  • Loading branch information
pcj authored May 31, 2023
1 parent 112066c commit a3c87dc
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 8 deletions.
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
# 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
48 changes: 48 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -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
...
69 changes: 69 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 9 additions & 4 deletions example/routeguide/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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) $@",
Expand Down
20 changes: 16 additions & 4 deletions repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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"],
)
""",
)

0 comments on commit a3c87dc

Please sign in to comment.