| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- name: Build and Test
- # NOTE: If making changes to most of the steps, please also look to update
- # regular_conformance.yml also.
- permissions:
- contents: read
- on:
- push:
- branches: [ main ]
- pull_request:
- branches: [ main ]
- jobs:
- core:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
- matrix:
- # We "float" the bug fix so we pick up new ones. This helps since the GitHub CI
- # is set to ensure the actions pass, thus updates are only needed when the
- # "major.minor" pairs changes.
- #
- # Looking at https://hub.docker.com/_/swift, the version only tags (i.e. - 6.1)
- # could use different Ubuntu releases. At the moment they are all the "noble",
- # which is also what would be desired, so we don't bother listing explicit ones.
- swift:
- - version: "6.2"
- hook: "SWIFT_BUILD_TEST_HOOK=\"-Xswiftc -warnings-as-errors\""
- - version: "6.1"
- hook: "SWIFT_BUILD_TEST_HOOK=\"-Xswiftc -warnings-as-errors\""
- - version: "6.0"
- hook: "SWIFT_BUILD_TEST_HOOK=\"-Xswiftc -warnings-as-errors\""
- - version: "5.10"
- # No "hook", see https://github.com/apple/swift-protobuf/issues/1560 for the
- # current issue with using -warnings-as-errors on linux.
- container:
- image: swift:${{ matrix.swift.version }}
- steps:
- - name: Checkout
- uses: actions/checkout@v4
- with:
- submodules: true
- - name: Update and install dependencies
- # dependencies from https://github.com/protocolbuffers/protobuf/blob/main/src/README.md
- run: apt-get update && apt-get install -y make g++ cmake
- - name: Build
- run: make build ${{ matrix.swift.hook }}
- - name: Test runtime
- run: make test-runtime ${{ matrix.swift.hook }}
- - name: Build protobuf
- working-directory: Sources/protobuf/protobuf
- # https://github.com/protocolbuffers/protobuf/blob/main/cmake/README.md#c-version
- run: |
- mkdir cmake_build
- cd cmake_build
- cmake \
- -DCMAKE_CXX_STANDARD=17 \
- -DCMAKE_BUILD_TYPE=Release \
- -Dprotobuf_BUILD_TESTS=OFF \
- -Dprotobuf_INSTALL=OFF \
- -Dprotobuf_BUILD_CONFORMANCE=ON \
- -S ..
- NUM_CPUS=$(getconf _NPROCESSORS_ONLN)
- make -j "${NUM_CPUS}" protoc conformance_test_runner
- - name: Test plugin
- run: make test-plugin PROTOC=Sources/protobuf/protobuf/cmake_build/protoc
- - name: Test conformance
- run: make test-conformance CONFORMANCE_TEST_RUNNER=Sources/protobuf/protobuf/cmake_build/conformance_test_runner
- - name: Test SPM plugin
- run: make test-spm-plugin PROTOC=Sources/protobuf/protobuf/cmake_build/protoc
- - name: Compilation Tests
- run: make compile-tests PROTOC=Sources/protobuf/protobuf/cmake_build/protoc
- api-breakage:
- name: Api Breakage Compared to main branch
- # Only on pull requests
- if: github.event_name == 'pull_request'
- runs-on: ubuntu-latest
- container:
- # Test on the latest Swift release. This could run on all the support
- # Swift versions, but that doesn't seem worth it until there are Swift
- # version specific conditionals to justify it.
- image: swift:latest
- steps:
- - name: Checkout
- uses: actions/checkout@v4
- with:
- fetch-depth: 0
- submodules: true
- - name: Mark the workspace as safe
- # https://github.com/actions/checkout/issues/766
- run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
- - name: Check for API breaking changes
- run: swift package diagnose-api-breaking-changes origin/main
- format-check:
- name: swift-format Check
- # Only on pull requests
- if: github.event_name == 'pull_request'
- runs-on: ubuntu-latest
- container:
- # Use use the latest Swift release and that's the version of swift-format
- # people should use.
- image: swift:latest
- steps:
- - name: Checkout
- uses: actions/checkout@v4
- with:
- submodules: true
- - name: Mark the workspace as safe
- # https://github.com/actions/checkout/issues/766
- run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
- - name: Run format check
- run: |
- set -eu
- git ls-files -z '*.swift' | xargs -0 swift format format --parallel --in-place
- GIT_PAGER='' git diff --exit-code '*.swift'
- # Disabled as it produces multiple warnings at the moment.
- # - name: Run format lint check
- # run: |
- # set -eu
- # git ls-files -z '*.swift' | xargs -0 swift format lint --strict --parallel
- sanitizer_testing:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
- matrix:
- sanitizer: ["address", "thread"]
- swiftpm_config: ["debug", "release"]
- exclude: # Excluded due to a clang crasher that is fixed in a more recent clang https://github.com/llvm/llvm-project/issues/95928
- - sanitizer: "address"
- swiftpm_config: "debug"
- container:
- # Test on the latest Swift release.
- image: swift:latest
- steps:
- - uses: actions/checkout@v4
- with:
- submodules: true
-
- - name: Test
- run: |
- set -eu
- # Trim out the generate files that are just compile tests, they take a while to compile and
- # are covered in core instead.
- rm Tests/SwiftProtobufTests/generated_swift_names*
- # On linux, the tests seem to always see leaks that don't show up on macOS. Disable the
- # leak detection and just assume it is a Linux Swift issue. This still gets validation
- # for other memory errors. Maybe https://bugs.swift.org/browse/SR-6848.
- if [ "${{ matrix.sanitizer }}" = "address" ] ; then
- export ASAN_OPTIONS=detect_leaks=0
- fi
- # 'release' doesn't support @testable, force it on.
- if [ "${{ matrix.swiftpm_config }}" = "release" ] ; then
- EXTRAS="-Xswiftc -enable-testing"
- fi
- swift test -c ${{ matrix.swiftpm_config }} --sanitize=${{ matrix.sanitizer }} ${EXTRAS:-}
- fuzzing_regressions:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
- matrix:
- swiftpm_config: ["debug", "release"]
- container:
- # Test on the latest Swift release.
- image: swift:latest
- steps:
- - uses: actions/checkout@v4
- with:
- submodules: true
- - name: Build
- run: FuzzTesting/do_build.sh --${{ matrix.swiftpm_config }}-only --run-regressions
|