Update references to upb to point to the new location

I also deleted upb's `.github` directory since this is no longer used.

PiperOrigin-RevId: 561119238
pull/13766/head
Adam Cozzette 1 year ago committed by Copybara-Service
parent bf0451983d
commit fa75cd454f
  1. 21
      upb/.github/actions/setup-bazel-cache/action.yml
  2. 107
      upb/.github/workflows/bazel_tests.yml
  3. 22
      upb/.github/workflows/clang_format.yml
  4. 24
      upb/.github/workflows/generate_files.yml
  5. 15
      upb/.github/workflows/mergeable.yml
  6. 173
      upb/.github/workflows/python_tests.yml
  7. 11
      upb/docs/vs-cpp-protos.md
  8. 4
      upb/python/descriptor.c
  9. 8
      upb/python/message.c

@ -1,21 +0,0 @@
name: "Setup Bazel Caching"
description: "Sets up Bazel caching"
inputs:
cache_url:
description: "URL of the Bazel cache to read/write"
required: false
default: https://storage.googleapis.com/protobuf-bazel-cache/upb
read_only:
description: "If true, we can read from the cache but not write it."
required: false
default: ${{ github.event.pull_request.head.repo.full_name != 'protocolbuffers/upb' }}
outputs:
cache_args:
description: "Caching related arguments to pass to 'bazel build"
value: --remote_cache=${{ inputs.cache_url }} ${{ steps.set_auth_arg.outputs.auth_arg }}
runs:
using: "composite"
steps:
- id: set_auth_arg
run: echo auth_arg=${{ inputs.read_only == 'true' && '--remote_upload_local_results=false' || '--google_default_credentials' }} >> $GITHUB_OUTPUT
shell: bash

@ -1,107 +0,0 @@
name: Bazel Tests
on:
push:
branches:
- main
- '[0-9]+.x'
pull_request:
branches:
- main
- '[0-9]+.x'
workflow_dispatch:
jobs:
ubuntu:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
matrix:
include:
- { NAME: "Fastbuild", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "" }
- { NAME: "Optimized", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "-c opt" } # Some warnings only fire with -c opt
- { NAME: "GCC Optimized", BAZEL: bazel, CC: gcc-12, os: ubuntu-22.04, flags: "-c opt" }
- { NAME: "FastTable", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "--//:fasttable_enabled=true -- -cmake:test_generated_files" }
- { NAME: "ASAN", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "--config=asan -c dbg -- -benchmarks:benchmark -python/..." }
- { NAME: "UBSAN", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "--config=ubsan -c dbg -- -benchmarks:benchmark -python/... -lua/...", install: "libunwind-dev" }
- { NAME: "32-bit", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "--copt=-m32 --linkopt=-m32 -- benchmarks:benchmark -python/...", install: "g++-multilib" }
- { NAME: "32-bit ASAN", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "--config=asan -c dbg --copt=-m32 --linkopt=-m32 -- -//benchmarks/... -//python/... -//upb/message:copy_test -//upb/message:promote_test -//upb/message:test -//upb/test:test_generated_code", install: "g++-multilib" }
- { NAME: "Windows", BAZEL: bazel, os: windows-2019, startup-flags: "--output_user_root=C:/tmp", flags: "--config=cpp17_msvc", targets: "upb/... upbc/... python/... protos/... protos_generator/..." }
- { NAME: "macOS", BAZEL: bazel, CC: clang, os: macos-11 }
# Current github runners are all Intel based, so just build/compile for Apple Silicon to detect issues there.
- { NAME: "macOS ARM (build only)", BAZEL: bazel, BAZEL_CMD: build, CC: clang, os: macos-11, flags: "--cpu=darwin_arm64"}
# We support two Bazel versions back per https://opensource.google/documentation/policies/cplusplus-support
- { NAME: "Bazel 5.3.0", BAZEL: bazel-5.3.0-linux-x86_64, CC: clang, os: ubuntu-20-large }
- { NAME: "Bazel 6.1.0", BAZEL: bazel-6.1.0-linux-x86_64, CC: clang, os: ubuntu-20-large }
name: ${{ matrix.NAME }}
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
if: ${{ github.event.pull_request.head.repo.full_name == 'protocolbuffers/upb' }}
- name: Download historical Bazel version
run: |
FILENAME=$HOME/bin/${{ matrix.BAZEL }}
VERSION=$(echo ${{ matrix.BAZEL }} | cut -d- -f 2 )
mkdir -p $HOME/bin
echo $HOME/bin >> $GITHUB_PATH
wget -O $FILENAME https://github.com/bazelbuild/bazel/releases/download/$VERSION/${{ matrix.BAZEL }}
chmod a+x $FILENAME
if: ${{ matrix.BAZEL != 'bazel' }}
- name: Check compiler versions
if: matrix.CC
run: ${{ matrix.CC }} --version
- name: Check Bazel versions
run: ${{ matrix.BAZEL }} --version
- id: bazel-cache
name: Set up Bazel caching
uses: ./.github/actions/setup-bazel-cache
- name: Setup Python venv
if: ${{ runner.os != 'Windows' }}
run: rm -rf /tmp/venv && python3 -m venv /tmp/venv && source /tmp/venv/bin/activate && python3 --version
- name: Install dependencies
run: sudo apt update && sudo apt install -y ${{ matrix.install }}
if: matrix.install != ''
- name: Install numpy
run: pip3 install numpy
- name: Setup environment variables
if: matrix.CC
run: echo "CC=${{ matrix.CC }}" >> $GITHUB_ENV
- name: Run tests
run: cd ${{ github.workspace }} && ${{ matrix.BAZEL }} ${{ matrix.startup-flags }} ${{ matrix.BAZEL_CMD || 'test' }} --test_output=errors ${{ steps.bazel-cache.outputs.cache_args }} ${{ matrix.targets || '...' }} ${{ matrix.flags }}
- uses: actions/upload-artifact@v3
with:
name: logs
path: |
**/*.log
no-python:
runs-on: ubuntu-20-large
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
name: "No System Python"
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
if: ${{ github.event.pull_request.head.repo.full_name == 'protocolbuffers/upb' }}
- id: bazel-cache
name: Set up Bazel caching
uses: ./.github/actions/setup-bazel-cache
- name: Uninstall python
run: which python3 && sudo mv `which python3` /tmp && ! which python3
- name: Run tests
run: cd ${{ github.workspace }} && bazel test --test_output=errors ${{ steps.bazel-cache.outputs.cache_args }} //python/... -- -//python/dist:source_wheel

@ -1,22 +0,0 @@
name: Check ClangFormat
on:
push:
branches:
- main
- '[0-9]+.x'
pull_request:
branches:
- main
- '[0-9]+.x'
workflow_dispatch:
jobs:
check_clang_format:
runs-on: ubuntu-20-large
steps:
- uses: actions/checkout@v2
- name: Run ClangFormat
run: find . | grep -E '\.(c|h|cc)$' | grep -E -v '^./(third_party|cmake)' | xargs clang-format -i
- name: Check for differences
run: git diff --exit-code

@ -1,24 +0,0 @@
name: Generate Files
# After any push to the main branch, re-generate pregenerated files.
on:
push:
branches:
- main
- '[0-9]+.x'
jobs:
generate:
if: github.repository == 'protocolbuffers/upb'
runs-on: ubuntu-22-large
steps:
- uses: actions/checkout@v3
with:
# Note: this token has an expiration date, so if the workflow starts
# failing then you may need to generate a fresh token.
token: ${{ secrets.BOT_ACCESS_TOKEN }}
- name: Configure name and email address in Git
run: cd ${{ github.workspace }} && git config user.name "Protobuf Team Bot" && git config user.email "protobuf-team-bot@google.com"
- name: Commit and push update
run: cd ${{ github.workspace }} && ./cmake/push_auto_update.sh

@ -1,15 +0,0 @@
mergeable:
pull_requests:
label:
and:
- must_exclude:
regex: '^disposition/DO NOT MERGE'
message: 'Pull request marked not mergeable'
- must_include:
regex: 'mergeable:force-allow'
message: 'Pull requests should not be merged directly and should instead
be handled by Copybara.
To enable Github merges, add the `mergeable:force-allow` label and get a second
approval. This should almost never be used except for releases or as a break glass
measure after discussing with the team.'

@ -1,173 +0,0 @@
name: Python 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-large
if: ${{ github.event.pull_request.head.repo.full_name == 'protocolbuffers/upb' }}
env:
# Bazel 5.4.0. Once we have moved to toolchains, we can update to Bazel 6.x.
DOCKER_IMAGE: us-docker.pkg.dev/protobuf-build/release-containers/linux/apple@sha256:bb1d14738449916d489c1cbb062508c4dca5bd265ea3e67a2628ae40912b9b00
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 -q us-docker.pkg.dev
- name: Pull Docker Image
run: docker pull $DOCKER_IMAGE
- name: Check Bazel version
run: cd ${{ github.workspace }} && docker run -v$PWD:/workspace $DOCKER_IMAGE --version
- id: bazel-cache
name: Set up Bazel caching
uses: ./.github/actions/setup-bazel-cache
- 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 --@com_google_protobuf//toolchain:release=true --symlink_prefix=/ -c dbg python/dist ${{ steps.bazel-cache.outputs.cache_args }} python/dist:test_wheel python/dist:source_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/
- uses: actions/upload-artifact@v3
with:
name: requirements
# Tests shouldn't have access to the whole upb repo, upload the one file we need
path: python/requirements.txt
test_wheels:
name: Test Wheels
needs: build_wheels
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
matrix:
include:
# Linux and Mac use the limited API, so all Python versions will use a single wheel.
# As a result we can just test the oldest and newest supported Python versions and assume
# this gives us sufficient test coverage.
- { os: ubuntu-18-large, python-version: "3.7", architecture: x64, type: 'binary' }
- { os: macos-11, python-version: "3.7", architecture: x64, type: 'binary' }
- { os: ubuntu-20-large, python-version: "3.10", architecture: x64, type: 'binary' }
- { os: macos-12, python-version: "3.10", architecture: x64, type: 'binary' }
- { os: ubuntu-18-large, python-version: "3.7", architecture: x64, type: 'source' }
- { os: macos-11, python-version: "3.7", architecture: x64, type: 'source' }
- { os: ubuntu-20-large, python-version: "3.10", architecture: x64, type: 'source' }
- { os: macos-12, python-version: "3.10", architecture: x64, type: 'source' }
# Windows uses the full API up until Python 3.10, so each of these
# jobs tests a distinct binary wheel.
- { os: windows-2019-large, python-version: "3.7", architecture: x86, type: 'binary' }
- { os: windows-2019-large, python-version: "3.8", architecture: x86, type: 'binary' }
- { os: windows-2019-large, python-version: "3.9", architecture: x86, type: 'binary' }
- { os: windows-2019-large, python-version: "3.10", architecture: x86, type: 'binary' }
- { os: windows-2019-large, python-version: "3.7", architecture: x64, type: 'binary' }
- { os: windows-2019-large, python-version: "3.8", architecture: x64, type: 'binary' }
- { os: windows-2019-large, python-version: "3.9", architecture: x64, type: 'binary' }
- { os: windows-2019-large, python-version: "3.10", architecture: x64, type: 'binary' }
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Download Wheels
uses: actions/download-artifact@v3
with:
name: python-wheels
path: wheels
- name: Download Requirements
uses: actions/download-artifact@v3
with:
name: requirements
path: requirements
- 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 requirements
run: pip install -r requirements/requirements.txt
- name: Install Protobuf Binary Wheel
run: pip install -vvv --no-index --find-links wheels protobuf
if: ${{ matrix.type == 'binary' }}
- name: Install Protobuf Source Wheel
run: |
cd wheels
tar -xzvf *.tar.gz
cd protobuf-*/
pip install .
if: ${{ matrix.type == 'source' }}
- 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: Install Protobuf Test Wheel
run: pip install -vvv --no-index --find-links wheels protobuftests
- 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
test_pure_python_wheels:
name: Test Pure Python Wheels
needs: build_wheels
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
matrix:
python-version: ["3.7", "3.10"]
runs-on: ubuntu-large
steps:
- name: Download Wheels
uses: actions/download-artifact@v3
with:
name: python-wheels
path: wheels
- name: Delete Binary Wheels
run: find wheels -type f | grep -v none-any | xargs rm
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Setup Python venv
run: |
python -m pip install --upgrade pip
python -m venv env
source env/bin/activate
echo "VIRTUAL ENV:" $VIRTUAL_ENV
- name: Install numpy
run: pip install numpy
- name: Install Protobuf Wheels
run: pip install -vvv --no-index --find-links wheels protobuf protobuftests
- name: Run the unit tests
run: |
TESTS=$(pip show -f protobuftests | grep _test.py | sed 's,/,.,g' | sed -E 's,.py$,,g')
for test in $TESTS; do
python -m unittest -v $test
done

@ -5,10 +5,10 @@ freshness: { owner: 'haberman' reviewed: '2023-02-24' }
# upb vs. C++ Protobuf Design
[upb](https://github.com/protocolbuffers/upb) is a small C protobuf library.
While some of the design follows in the footsteps of the C++ Protobuf Library,
upb departs from C++'s design in several key ways. This document compares
and contrasts the two libraries on several design points.
[upb](https://github.com/protocolbuffers/protobuf/tree/main/upb) is a small C
protobuf library. While some of the design follows in the footsteps of the C++
Protobuf Library, upb departs from C++'s design in several key ways. This
document compares and contrasts the two libraries on several design points.
## Design Goals
@ -36,7 +36,8 @@ core to stay small and simple. We want to be compatible with all FFI
interfaces, so C ABI compatibility is a must.
Despite these differences, C++ protos and upb offer [roughly the same core set
of features](https://github.com/protocolbuffers/upb#features).
of
features](https://github.com/protocolbuffers/protobuf/tree/main/upb#features).
## Arenas

@ -1054,7 +1054,7 @@ static PyGetSetDef PyUpb_FieldDescriptor_Getters[] = {
"Default Value"},
{"has_default_value", (getter)PyUpb_FieldDescriptor_HasDefaultValue},
{"is_extension", (getter)PyUpb_FieldDescriptor_GetIsExtension, NULL, "ID"},
// TODO(https://github.com/protocolbuffers/upb/issues/459)
// TODO(https://github.com/protocolbuffers/protobuf/issues/13760)
//{ "id", (getter)GetID, NULL, "ID"},
{"message_type", (getter)PyUpb_FieldDescriptor_GetMessageType, NULL,
"Message type"},
@ -1069,7 +1069,7 @@ static PyGetSetDef PyUpb_FieldDescriptor_Getters[] = {
"Has Options"},
{"has_presence", (getter)PyUpb_FieldDescriptor_GetHasPresence, NULL,
"Has Presence"},
// TODO(https://github.com/protocolbuffers/upb/issues/459)
// TODO(https://github.com/protocolbuffers/protobuf/issues/13760)
//{ "_options",
//(getter)NULL, (setter)SetOptions, "Options"}, { "_serialized_options",
//(getter)NULL, (setter)SetSerializedOptions, "Serialized Options"},

@ -1309,9 +1309,9 @@ static PyObject* PyUpb_Message_ParseFromString(PyObject* self, PyObject* arg) {
}
static PyObject* PyUpb_Message_ByteSize(PyObject* self, PyObject* args) {
// TODO(https://github.com/protocolbuffers/upb/issues/462): At the moment upb
// does not have a "byte size" function, so we just serialize to string and
// get the size of the string.
// TODO(https://github.com/protocolbuffers/protobuf/issues/13759): At the
// moment upb does not have a "byte size" function, so we just serialize to
// string and get the size of the string.
PyObject* subargs = PyTuple_New(0);
PyObject* serialized = PyUpb_Message_SerializeToString(self, subargs, NULL);
Py_DECREF(subargs);
@ -1656,7 +1656,7 @@ static PyGetSetDef PyUpb_Message_Getters[] = {
static PyMethodDef PyUpb_Message_Methods[] = {
{"__deepcopy__", (PyCFunction)DeepCopy, METH_VARARGS,
"Makes a deep copy of the class."},
// TODO(https://github.com/protocolbuffers/upb/issues/459)
// TODO(https://github.com/protocolbuffers/protobuf/issues/13760)
//{ "__unicode__", (PyCFunction)ToUnicode, METH_NOARGS,
// "Outputs a unicode representation of the message." },
{"ByteSize", (PyCFunction)PyUpb_Message_ByteSize, METH_NOARGS,

Loading…
Cancel
Save