Protocol Buffers - Google's data interchange format (grpc依赖) https://developers.google.com/protocol-buffers/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
4.0 KiB

name: Python Source Distribution Tests
on:
push:
branches:
- main
- '[0-9]+.x'
pull_request:
branches:
- main
- '[0-9]+.x'
workflow_dispatch:
jobs:
build_wheels:
name: Build Wheels
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.head.repo.full_name == 'protocolbuffers/upb' }}
env:
DOCKER_IMAGE: gcr.io/protobuf-build/bazel/linux@sha256:9dba7773926bb6dce839de098948055c9e80260d7470a7fefb94b6a4fed363ba
steps:
- uses: actions/checkout@v2
- name: Set up Cloud SDK
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
export_environment_variables: true
- name: Use gcloud CLI
run: gcloud info
- name: Configure Docker
run: gcloud auth configure-docker
- name: Pull Docker Image
run: docker pull $DOCKER_IMAGE
- name: Build Wheels
run: cd ${{ github.workspace }} && docker run -e GOOGLE_APPLICATION_CREDENTIALS=/workspace/$(basename $GOOGLE_APPLICATION_CREDENTIALS) -v$PWD:/workspace $DOCKER_IMAGE build $BAZEL_CACHE --crosstool_top=@com_google_protobuf//toolchain:clang_suite --symlink_prefix=/ -c dbg python/dist:source_wheel python/dist:test_wheel
- name: Move Wheels
run: mkdir wheels && find _build/out -name 'protobuf*.whl' -o -name 'protobuf*.tar.gz' -exec mv '{}' wheels ';'
- uses: actions/upload-artifact@v3
with:
name: python-wheels
path: wheels/
test_wheels:
name: Test Wheels
needs: build_wheels
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
matrix:
include:
# Test on all supported operating systems and using the oldest and
# newest versions of python we support
- { os: ubuntu-18.04, python-version: "3.7", architecture: x64 }
- { os: ubuntu-20.04, python-version: "3.10", architecture: x64 }
- { os: macos-11, python-version: "3.7", architecture: x64 }
- { os: macos-12, python-version: "3.10", architecture: x64 }
- { os: windows-2019, python-version: "3.7", architecture: x86 }
- { os: windows-2019, python-version: "3.10", architecture: x86 }
- { os: windows-2019, python-version: "3.7", architecture: x64 }
- { os: windows-2019, python-version: "3.10", architecture: x64 }
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Download Wheels
uses: actions/download-artifact@v3
with:
name: python-wheels
path: ${{ github.workspace }}
- name: Extract tar
run: tar -xzvf *.tar.gz
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
- name: Setup Python venv
run: |
python -m pip install --upgrade pip
python -m venv env
# Windows uses 'Scripts' instead of 'bin'
source env/bin/activate || source env/Scripts/activate
echo "VIRTUAL ENV:" $VIRTUAL_ENV
- name: Install tzdata
run: pip install tzdata
# Only needed on Windows, Linux ships with tzdata.
if: ${{ contains(matrix.os, 'windows') }}
- name: Install numpy
run: pip install numpy
- name: Install Protobuf Test wheel
run: pip install -vvv --no-index --find-links . protobuftests
- name: Install python source
run: cd protobuf-*/ && python setup.py install
- name: Test that module is importable
run: python -v -c 'from google._upb import _message; assert "google._upb._message.MessageMeta" in str(_message.MessageMeta)'
if: ${{ !matrix.pure_python }}
- name: Run the unit tests
run: |
TESTS=$(pip show -f protobuftests | grep pb_unit_tests.*py$ | sed 's,/,.,g' | sed 's,\\,.,g' | sed -E 's,.py$,,g')
for test in $TESTS; do
python -m unittest -v $test
done