-
Notifications
You must be signed in to change notification settings - Fork 2
50 lines (49 loc) · 1.74 KB
/
test-bazel.yaml
File metadata and controls
50 lines (49 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
name: test
on:
workflow_call:
inputs:
bazel-config:
description: Bazel config to pass to bazel run and bazel test (e.g. "remote")
type: string
runs-on:
description: Operating system to test against
type: string
default: ubuntu-latest
secrets:
BUILDBUDDY_API_KEY:
description: BuildBuddy API key for remote caching
required: false
permissions:
contents: read
jobs:
test:
name: Run tests
runs-on: ${{ inputs.runs-on }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: bazel-contrib/setup-bazel@0.19.0
with:
bazelisk-cache: true
disk-cache: ${{ inputs.bazel-config == '' && github.workflow || false }}
repository-cache: true
bazelrc: |
${{ secrets.BUILDBUDDY_API_KEY != '' && format('build:remote --remote_header=x-buildbuddy-api-key={0}', secrets.BUILDBUDDY_API_KEY) || '' }}
- name: Determine base SHA
id: base_sha
run: |
if [ "${{ github.event.pull_request != null }}" = "true" ]; then
echo "sha=${{ github.event.pull_request.base.sha }}" >> $GITHUB_OUTPUT
else
echo "sha=${{ github.event.before }}" >> $GITHUB_OUTPUT
fi
- name: Run tests
run: |
config=${{ inputs.bazel-config != '' && format('--config={0}', inputs.bazel-config) || '' }}
files="$(git diff --name-only ${{ steps.base_sha.outputs.sha }}..HEAD)"
# Run tests for targets that depend on the changed files. This includes
# all dependent tests, not just the tests for the changed files.
bazel $config run //:buildifier
bazel $config test $(bazel query --keep_going "tests(rdeps(//..., set($files)))" 2>/dev/null)