Skip to content

Commit 423b282

Browse files
author
David Freese
committed
Add github actions to test against a matrix of bazel versions
Brought up in the discussion of bazelbuild#463, was that testing against multiple bazel versions with bazelci didn't seem possible without a fair bit of work. Judging based on usage that I have seen, we probably moved too quickly on bumping the minimum version to 3.0.0, but until we can actually test against our minimum version, we won't be able to reasonably version breaking changes as suggested by bazelbuild#415. This initial PR leaves a lot of on the table in terms of potential optimizations, and is fixed on Ubuntu 20.04 LTS for the moment.
1 parent 29eb232 commit 423b282

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

.github/actions/bazel/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM ubuntu:focal-20200423
2+
3+
COPY bazel.sh /bazel.sh
4+
5+
RUN apt-get update \
6+
&& apt-get install -y \
7+
curl \
8+
gnupg2 \
9+
wget
10+
11+
RUN curl https://bazel.build/bazel-release.pub.gpg | apt-key add - \
12+
&& echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" > /etc/apt/sources.list.d/bazel.list \
13+
&& curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - \
14+
&& echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" > /etc/apt/sources.list.d/google-cloud-sdk.list
15+
16+
RUN apt-get update
17+
18+
ENTRYPOINT ["/bazel.sh"]

.github/actions/bazel/action.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "Bazel"
2+
description: "Run a bazel command on a particular directory"
3+
author: "David Freese"
4+
inputs:
5+
version:
6+
description: "The version of bazel to use"
7+
required: true
8+
command:
9+
description: "The bazel command to run"
10+
required: true
11+
arguments:
12+
description: "Arguments to pass to bazel after the bazel command"
13+
required: false
14+
directory:
15+
description: "The directory in which to run the command"
16+
required: false
17+
targets:
18+
description: "Targets on which to run the command"
19+
required: false
20+
query:
21+
description: "A Bazel query describing which"
22+
required: false
23+
runs:
24+
using: "docker"
25+
image: "Dockerfile"

.github/actions/bazel/bazel.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash -eux
2+
3+
if [[ -n "${INPUT_ARGUMENTS:-""}" ]]; then
4+
INPUT_COMMAND+=(" ${INPUT_ARGUMENTS}")
5+
fi
6+
7+
apt-get install -y "bazel-${INPUT_VERSION}"
8+
9+
if [[ -n "${INPUT_DIRECTORY:-""}" ]]; then
10+
cd "${INPUT_DIRECTORY}"
11+
fi
12+
13+
if [[ -n "${INPUT_TARGETS:-""}" ]]; then
14+
INPUT_TARGETS="//..."
15+
fi
16+
if [[ -n "${INPUT_QUERY:-""}" ]]; then
17+
INPUT_TARGETS=$("bazel-${INPUT_VERSION}" query -- "${INPUT_QUERY}")
18+
fi
19+
20+
# leave targets unquoted to allow multi-line query output to be a single-line
21+
# input here.
22+
"bazel-${INPUT_VERSION}" "${INPUT_COMMAND}" -- ${INPUT_TARGETS}

.github/workflows/ci.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: CI
2+
on:
3+
push:
4+
5+
jobs:
6+
bazel:
7+
name: Build/Test
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
# The two most recent versions and the current min supported version
12+
version: ["3.0.0", "3.6.0", "3.7.0"]
13+
command: ["build", "test"]
14+
steps:
15+
- name: Checkout
16+
uses: verily-src/checkout@v2
17+
- name: Run Bazel
18+
uses: "./.github/actions/bazel"
19+
with:
20+
version: ${{ matrix.version }}
21+
command: ${{ matrix.command }}
22+
query: "//... - @examples//... - attr('tags', 'manual', //...)"

0 commit comments

Comments
 (0)