Repository navigation
142 lines (132 loc) · 5.96 KB
/
Copy pathtest_bazel.yml
File metadata and controls
142 lines (132 loc) · 5.96 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Bazel Tests
on:
workflow_call:
inputs:
continuous-run:
required: true
description: "Boolean string denoting whether this run is continuous --
empty string for presubmit, non-empty string for continuous."
type: string
safe-checkout:
required: true
description: "The SHA key for the commit we want to run over"
type: string
continuous-prefix:
required: true
description: "The string continuous-only tests should be prefixed with when displaying test results."
type: string
permissions:
contents: read
jobs:
examples:
strategy:
fail-fast: false
matrix:
runner: [ ubuntu-24.04, windows-2022, macos-15 ]
bazelversion: [ '8.7.0', '9.2.0' ]
bzlmod: [ true, false ]
toolchain_resolution:
# Default flags (uses prebuilt protoc on release tags, or falls back to source on -dev)
- ""
# Locally populates tool_integrity.bzl and strictly requires prebuilt protoc.
- "--@com_google_protobuf//bazel/flags:internal_do_not_use_require_prebuilt_protoc=true"
# Legacy proto_compiler flag path (uses protoc from source)
- "--incompatible_enable_proto_toolchain_resolution=false"
# Uses protoc from source via toolchain resolution.
- "--@com_google_protobuf//bazel/flags:prefer_prebuilt_protoc=false"
include:
- runner: macos-15
continuous-only: true
exclude:
- bazelversion: '9.2.0'
bzlmod: false
- bzlmod: false
toolchain_resolution: "--@com_google_protobuf//bazel/flags:internal_do_not_use_require_prebuilt_protoc=true"
runs-on: ${{ matrix.runner }}
name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} Examples ${{ matrix.runner }} ${{ matrix.bazelversion }}${{ matrix.bzlmod && ' (bzlmod)' || '' }} ${{ matrix.toolchain_resolution && ' (toolchain resolution)' || '' }}
steps:
- name: Checkout pending changes
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
uses: protocolbuffers/protobuf-ci/checkout@v7
with:
ref: ${{ inputs.safe-checkout }}
# rules_jvm_external doesn't support Java 8, which is the default version
# on some github runners. When this is selected, it results in some
# opaque errors about coursier (see
# https://github.com/bazel-contrib/rules_jvm_external/issues/1337).
- name: Pin to Java 11
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
with:
distribution: 'temurin'
java-version: '11'
- name: Windows startup flags
if: ${{ runner.os == 'Windows' && (!matrix.continuous-only || inputs.continuous-run) }}
shell: bash
run: |
echo "startup --output_user_root=C:/ --windows_enable_symlinks" >> .bazelrc
echo "startup --output_user_root=C:/ --windows_enable_symlinks" >> examples/.bazelrc
- name: Configure Bazel version
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
shell: bash
run: |
echo "${{ matrix.bazelversion }}" > .bazelversion
echo "${{ matrix.bazelversion }}" > examples/.bazelversion
- name: Update prebuilts
if: ${{ (!matrix.continuous-only || inputs.continuous-run) && contains(matrix.toolchain_resolution, 'internal_do_not_use_require_prebuilt_protoc=true') }}
uses: protocolbuffers/protobuf-ci/bazel@v7
with:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: examples-${{ matrix.bazelversion }}-${{ matrix.bzlmod }}-${{ matrix.toolchain_resolution }}
version: ${{ matrix.bazelversion }}
bazel: run pkg:update_prebuilts
- name: Run tests
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
uses: protocolbuffers/protobuf-ci/bazel@v7
with:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: examples-${{ matrix.bazelversion }}-${{ matrix.bzlmod }}-${{ matrix.toolchain_resolution }}
version: ${{ matrix.bazelversion }}
bash: >
cd examples;
bazel build //... @com_google_protobuf-examples-with-hyphen//... $BAZEL_FLAGS --enable_bzlmod=${{ matrix.bzlmod }} --enable_workspace=${{ !matrix.bzlmod }} --incompatible_enable_proto_toolchain_resolution=true ${{ matrix.toolchain_resolution }};
bazel-tests-ubuntu:
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
name: Bazel Tests ubuntu
runs-on: ubuntu-24.04
steps:
- name: Checkout pending changes
uses: protocolbuffers/protobuf-ci/checkout@v7
with:
ref: ${{ inputs.safe-checkout }}
- name: Run tests
uses: protocolbuffers/protobuf-ci/bazel-docker@v7
with:
image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:9.2.0-4d8e80ef93b0219fb907af9dd4596b92946995d8
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: "bazel-tests"
bazel: test //bazel/...
bazel-tests-windows-macos:
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
matrix:
runner: [ windows-2022, macos-15 ]
name: Bazel Tests ${{ matrix.runner }}
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout pending changes
uses: protocolbuffers/protobuf-ci/checkout@v7
with:
ref: ${{ inputs.safe-checkout }}
- name: Windows startup flags
if: ${{ runner.os == 'Windows' }}
shell: bash
run: echo "startup --output_user_root=C:/ --windows_enable_symlinks" >> .bazelrc
- name: Run tests
uses: protocolbuffers/protobuf-ci/bazel@v7
with:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: "bazel-tests-${{ matrix.runner }}"
bazel: test //bazel/...
version: 8.7.0