Repository navigation
135 lines (123 loc) · 5.42 KB
/
Copy pathtest_python.yml
File metadata and controls
135 lines (123 loc) · 5.42 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
name: Python 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:
linux:
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
matrix:
type: [ Pure, C++]
version: ["3.11", "3.12", "3.13", "3.14"]
include:
- type: Pure
targets: //python/... //python:python_version_test
flags: --define=use_fast_cpp_protos=false
- type: C++
targets: //python/... //python:python_version_test
flags: --define=use_fast_cpp_protos=true
# Test using WORKSPACE with our oldest support Python version.
- version: "3.11"
- version: "3.12"
continuous-only: true
- version: "3.13"
continuous-only: true
- version: "3.14"
kokoro_python_version: "3.14.4"
- type: C++
version: aarch64
targets: //python/... //python:aarch64_test
# TODO Enable this once conformance tests are fixed.
flags: --define=use_fast_cpp_protos=true --test_tag_filters=-conformance
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:8.7.0-aarch64-5bb1a8fdfc30f8c21c1b38cf053d2db9fca865a7
name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} Linux ${{ matrix.type }} ${{ matrix.version }} ${{ matrix.nobzlmod && 'No Bzlmod' || '' }}
runs-on: ubuntu-24.04
steps:
- name: Checkout pending changes
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
uses: protocolbuffers/protobuf-ci/checkout@v7
with:
ref: ${{ inputs.safe-checkout }}
- name: Run tests
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
uses: protocolbuffers/protobuf-ci/bazel-docker@v7
with:
image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/python:9.2.0-{0}-5bb1a8fdfc30f8c21c1b38cf053d2db9fca865a7 ', matrix.version) }}
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: python_linux/${{ matrix.type }}_${{ matrix.version }}
bazel: >-
test ${{ matrix.targets }} ${{ matrix.flags }}
${{ matrix.nobzlmod && '--noenable_bzlmod' || '' }}
--//python:use_hermetic_python=true
--@rules_python//python/config_settings:python_version=${{ matrix.version != 'aarch64' && matrix.version || '3.11' }}
--test_env=KOKORO_PYTHON_VERSION=${{ matrix.kokoro_python_version || (matrix.version != 'aarch64' && matrix.version || '') }}
macos:
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
matrix:
type: [ Pure, C++]
version: [ "3.12", "3.13", "3.14" ]
include:
- type: Pure
targets: //python/... //python:python_version_test
- type: C++
targets: //python/... //python:python_version_test
flags: --define=use_fast_cpp_protos=true
- version: "3.13"
continuous-only: true
- version: "3.14"
continuous-only: true
name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} MacOS ${{ matrix.type }} ${{ matrix.version }}
runs-on: macos-15
steps:
- name: Checkout pending changes
uses: protocolbuffers/protobuf-ci/checkout@v7
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
with:
ref: ${{ inputs.safe-checkout }}
- name: Pin Python version
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
with:
python-version: ${{ matrix.version }}
cache: pip
cache-dependency-path: 'python/requirements.txt'
- name: Validate version
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
run: python3 --version | grep ${{ matrix.version }} || (echo "Invalid Python version - $(python3 --version)" && exit 1)
- name: Create and start virtual environment
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
run: |
python3 -m venv venv
source venv/bin/activate
- name: Run tests
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
uses: protocolbuffers/protobuf-ci/bazel@v7
env:
KOKORO_PYTHON_VERSION: ${{ matrix.version }}
with:
version: 9.2.0 # Bazel version
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: python_macos/${{ matrix.type }}_${{ matrix.version }}
bazel: >-
test ${{ matrix.targets }} ${{ matrix.flags }}
--//python:use_hermetic_python=true
--@rules_python//python/config_settings:python_version=${{ matrix.version }}
--test_env=KOKORO_PYTHON_VERSION=${{ matrix.version }}
--macos_minimum_os=12.0