File: test_python.yml

package info (click to toggle)
protobuf 3.25.4-4
  • links: PTS
  • area: main
  • in suites: experimental
  • size: 45,992 kB
  • sloc: cpp: 204,199; java: 87,622; ansic: 81,204; objc: 58,434; cs: 27,303; python: 22,799; php: 11,340; ruby: 8,637; pascal: 3,324; xml: 2,333; sh: 1,331; makefile: 538; lisp: 86; awk: 17
file content (100 lines) | stat: -rw-r--r-- 3,668 bytes parent folder | download
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
name: Python Tests

on:
  workflow_call:
    inputs:
      safe-checkout:
        required: true
        description: "The SHA key for the commit we want to run over"
        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.8", "3.9", "3.10", "3.11" ]
        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
          - 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:aarch64-63dd26c0c7a808d92673a3e52e848189d4ab0f17

    name: Linux ${{ matrix.type }} ${{ matrix.version }}
    runs-on: ubuntu-latest
    steps:
      - name: Checkout pending changes
        uses: protocolbuffers/protobuf-ci/checkout@v2
        with:
          ref: ${{ inputs.safe-checkout }}
      - name: Run tests
        uses: protocolbuffers/protobuf-ci/bazel-docker@v2
        with:
          image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/python:{0}-63dd26c0c7a808d92673a3e52e848189d4ab0f17', matrix.version) }}
          credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
          bazel-cache: python_linux/${{ matrix.type }}_${{ matrix.version }}
          bazel: test ${{ matrix.targets }} ${{ matrix.flags }} --test_env=KOKORO_PYTHON_VERSION
          exclude-targets: -//python/pb_unit_tests/...


  macos:
    strategy:
      fail-fast: false   # Don't cancel all jobs if one fails.
      matrix:
        type: [ Pure, C++]
        # TODO Consider expanding this set of versions.
        version: [ "3.11" ]
        include:
          - type: Pure
            targets: //python/... //python:python_version_test
          - type: C++
            targets: //python/... //python:python_version_test
            flags: --define=use_fast_cpp_protos=true

    name: MacOS ${{ matrix.type }} ${{ matrix.version }}
    runs-on: macos-12
    steps:
      - name: Checkout pending changes
        uses: protocolbuffers/protobuf-ci/checkout@v2
        with:
          ref: ${{ inputs.safe-checkout }}

      - name: Pin Python version
        uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
        with:
          python-version: ${{ matrix.version }}
          cache: pip
          cache-dependency-path: 'python/requirements.txt'

      - name: Validate version
        run: python3 --version | grep ${{ matrix.version }} || (echo "Invalid Python version - $(python3 --version)" && exit 1)

      - name: Create and start virtual environment
        run: |
          python3 -m venv venv
          source venv/bin/activate

      - name: Run tests
        uses: protocolbuffers/protobuf-ci/bazel@v2
        env:
          KOKORO_PYTHON_VERSION: ${{ matrix.version }}
        with:
          credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
          bazel-cache: python_macos/${{ matrix.type }}_${{ matrix.version }}
          bazel: >-
            test ${{ matrix.targets }} ${{ matrix.flags }}
            --test_env=KOKORO_PYTHON_VERSION=${{ matrix.version }}
            --macos_minimum_os=10.9
          exclude-targets: -//python/pb_unit_tests/...