Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 24 additions & 176 deletions .github/workflows/protobuf.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
name: ProtoBuf CI Builds

env:
PROTOBUF_VERSION: 3.20.1
PROTOBUF_VARIANT: '-all' # Use '-all' prior to 22.0, '' after
ABSEIL_VERSION: 20230802.1
name: OSI CI Builds

on:
push:
Expand All @@ -13,29 +8,22 @@ on:
jobs:
spellcheck:
name: Spellcheck
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: rojopolis/[email protected]
name: Spellcheck
with:
config_path: .github/.pyspelling.yml

build-proto2-linux64:
name: Build Proto2 Linux 64
run-tests:
name: Run tests

runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:
- name: Checkout OSI
uses: actions/checkout@v4
with:
submodules: true

- name: Check Build Setup
run: |
( result=0 ; for f in *.proto ; do grep -wq "$f" CMakeLists.txt || { echo "Missing $f in CMakeLists.txt" && let "result++"; } ; done ; exit $result )
( result=0 ; for f in *.proto ; do grep -q '"'$f'"' setup.py || { echo "Missing $f in setup.py" && let "result++"; } ; done ; exit $result )

- name: Setup Python
uses: actions/setup-python@v5
Expand All @@ -45,49 +33,27 @@ jobs:
- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build
python -m pip install -r requirements_tests.txt

- name: Check black format
run: |
black --check --diff .

- name: Install Doxygen
run: sudo apt-get install doxygen graphviz

- name: Cache Dependencies
id: cache-depends
uses: actions/cache@v4
with:
path: protobuf-${{ env.PROTOBUF_VERSION }}
key: ${{ runner.os }}-v2-depends

- name: Download ProtoBuf ${{ env.PROTOBUF_VERSION }}
if: steps.cache-depends.outputs.cache-hit != 'true'
run: curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v${{env.PROTOBUF_VERSION}}/protobuf${{env.PROTOBUF_VARIANT}}-${{env.PROTOBUF_VERSION}}.tar.gz && tar xzvf protobuf${{env.PROTOBUF_VARIANT}}-${{env.PROTOBUF_VERSION}}.tar.gz
- name: Run Python Tests
run: python -m unittest discover tests

- name: Download Abseil ${{ env.ABSEIL_VERSION }}
if: steps.cache-depends.outputs.cache-hit != 'true' && env.PROTOBUF_VARIANT == ''
run: curl -OL https://github.com/abseil/abseil-cpp/archive/refs/tags/${{env.ABSEIL_VERSION}}.tar.gz && tar xzvf ${{env.ABSEIL_VERSION}}.tar.gz && rm -rf protobuf-${{env.PROTOBUF_VERSION}}/third_party/abseil-cpp && mv abseil-cpp-${{env.ABSEIL_VERSION}} protobuf-${{env.PROTOBUF_VERSION}}/third_party/abseil-cpp
build-docs:
name: Build docs

- name: Build ProtoBuf ${{ env.PROTOBUF_VERSION }} via autotools
if: steps.cache-depends.outputs.cache-hit != 'true' && env.PROTOBUF_VARIANT == '-all'
working-directory: protobuf-${{ env.PROTOBUF_VERSION }}
run: ./configure DIST_LANG=cpp --prefix=/usr && make
runs-on: ubuntu-24.04

- name: Build ProtoBuf ${{ env.PROTOBUF_VERSION }} via cmake
if: steps.cache-depends.outputs.cache-hit != 'true' && env.PROTOBUF_VARIANT == ''
working-directory: protobuf-${{ env.PROTOBUF_VERSION }}
run: cmake -DCMAKE_CXX_STANDARD=17 -Dprotobuf_BUILD_SHARED_LIBS=ON -Dprotobuf_BUILD_TESTS=OFF . && cmake --build . --config Release -j 4
steps:
- name: Checkout OSI
uses: actions/checkout@v4

- name: Install ProtoBuf ${{ env.PROTOBUF_VERSION }}
working-directory: protobuf-${{ env.PROTOBUF_VERSION }}
run: sudo make install && sudo ldconfig
- name: Install Doxygen
run: sudo apt-get install doxygen graphviz

- name: Install proto2cpp
run: git clone --depth 1 https://github.com/OpenSimulationInterface/proto2cpp.git

- name: Prepare C++ Build
- name: Prepare Build
run: mkdir build

- name: Add Development Version Suffix
Expand All @@ -105,136 +71,18 @@ jobs:
echo "EXCLUDE_PATTERNS = */osi3/* */protobuf-*/* */proto2cpp/* */flatbuffers/*" >> doxygen_config.cmake.in
echo "GENERATE_TREEVIEW = YES" >> doxygen_config.cmake.in

- name: Configure C++ Build
- name: Configure Build
working-directory: build
run: cmake -D FILTER_PROTO2CPP_PY_PATH=$GITHUB_WORKSPACE/proto2cpp ${{ env.PROTOBUF_VARIANT =='' && '-DCMAKE_CXX_STANDARD=17' }} ..
run: cmake -D FILTER_PROTO2CPP_PY_PATH=$GITHUB_WORKSPACE/proto2cpp ..

- name: Build C++
- name: Build
working-directory: build
run: cmake --build . --config Release -j 4

- name: Build Python
run: python -m build

- name: Install Python
run: python -m pip install .

- name: Run Python Tests
run: python -m unittest discover tests

- name: Upload Python Distribution
if: ${{ github.event_name == 'pull_request' || ( github.event_name == 'push' && ( github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') ) ) }}
- name: Upload documentation
uses: actions/upload-artifact@v4
with:
name: python-dist
path: dist/

build-proto3-linux64:
name: Build Proto3 Linux 64

runs-on: ubuntu-22.04

steps:
- name: Checkout OSI
uses: actions/checkout@v4
with:
submodules: true

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.8'

- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build
python -m pip install -r requirements_tests.txt

- name: Cache Dependencies
id: cache-depends
uses: actions/cache@v4
with:
path: protobuf-${{ env.PROTOBUF_VERSION }}
key: ${{ runner.os }}-v2-depends

- name: Download ProtoBuf ${{ env.PROTOBUF_VERSION }}
if: steps.cache-depends.outputs.cache-hit != 'true'
run: curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v${{env.PROTOBUF_VERSION}}/protobuf${{env.PROTOBUF_VARIANT}}-${{env.PROTOBUF_VERSION}}.tar.gz && tar xzvf protobuf${{env.PROTOBUF_VARIANT}}-${{env.PROTOBUF_VERSION}}.tar.gz

- name: Download Abseil ${{ env.ABSEIL_VERSION }}
if: steps.cache-depends.outputs.cache-hit != 'true' && env.PROTOBUF_VARIANT == ''
run: curl -OL https://github.com/abseil/abseil-cpp/archive/refs/tags/${{env.ABSEIL_VERSION}}.tar.gz && tar xzvf ${{env.ABSEIL_VERSION}}.tar.gz && rm -rf protobuf-${{env.PROTOBUF_VERSION}}/third_party/abseil-cpp && mv abseil-cpp-${{env.ABSEIL_VERSION}} protobuf-${{env.PROTOBUF_VERSION}}/third_party/abseil-cpp

- name: Build ProtoBuf ${{ env.PROTOBUF_VERSION }} via autotools
if: steps.cache-depends.outputs.cache-hit != 'true' && env.PROTOBUF_VARIANT == '-all'
working-directory: protobuf-${{ env.PROTOBUF_VERSION }}
run: ./configure DIST_LANG=cpp --prefix=/usr && make

- name: Build ProtoBuf ${{ env.PROTOBUF_VERSION }} via cmake
if: steps.cache-depends.outputs.cache-hit != 'true' && env.PROTOBUF_VARIANT == ''
working-directory: protobuf-${{ env.PROTOBUF_VERSION }}
run: cmake -DCMAKE_CXX_STANDARD=17 -Dprotobuf_BUILD_SHARED_LIBS=ON -Dprotobuf_BUILD_TESTS=OFF . && cmake --build . --config Release -j 4

- name: Install ProtoBuf ${{ env.PROTOBUF_VERSION }}
working-directory: protobuf-${{ env.PROTOBUF_VERSION }}
run: sudo make install && sudo ldconfig

- name: Prepare C++ Build
run: mkdir build

- name: Switch to Proto3 Syntax
run: |
bash convert-to-proto3.sh
rm *.pb2

- name: Add Development Version Suffix
if: ${{ !startsWith(github.ref, 'refs/tags') }}
run: |
echo "VERSION_SUFFIX = .dev`date -u '+%Y%m%d%H%M%S'`" >> VERSION

- name: Configure C++ Build
working-directory: build
run: cmake ${{ env.PROTOBUF_VARIANT =='' && '-DCMAKE_CXX_STANDARD=17' }} ..

- name: Build C++
working-directory: build
run: cmake --build . --config Release -j 4

- name: Build Python
run: python -m build

- name: Install Python
run: python -m pip install .

- name: Run Python Tests
run: python -m unittest discover tests

publish-python-dist:
name: Publish Python Distribution

runs-on: ubuntu-22.04

permissions:
id-token: write

needs: [build-proto2-linux64, build-proto3-linux64]

if: ${{ github.event_name == 'push' && ( github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') ) }}

steps:
- name: Download Distribution
uses: actions/download-artifact@v4
with:
name: python-dist
path: dist/

- name: Publish Snapshot Release on TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
continue-on-error: true
with:
repository-url: https://test.pypi.org/legacy/

- name: Publish Full Release on PyPI
if: startsWith(github.ref, 'refs/tags/v') && ( ! contains(github.ref, '-') )
uses: pypa/gh-action-pypi-publish@release/v1
name: doxygen-doc
path: |
doc/html/
doc/images/
Loading