Skip to content

[table-driven-branch] Updates from main #2427

[table-driven-branch] Updates from main

[table-driven-branch] Updates from main #2427

Workflow file for this run

name: Build and Test
permissions:
contents: read
on:
push:
branches: [ table-driven-branch ]
pull_request:
branches: [ table-driven-branch ]
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.
# TODO: Bring back 6.1, currently has a building error.
#swift: ["6.3", "6.2", "6.1"]
swift: &swift_versions ["6.3", "6.2"]
traits: ["default", "disable-default-traits", "BinaryDelimitedStreams", "FieldMaskUtilities"]
include:
- traits: "default"
flags: ""
- traits: "disable-default-traits"
flags: "--disable-default-traits"
- traits: "BinaryDelimitedStreams"
flags: "--traits BinaryDelimitedStreams"
- traits: "FieldMaskUtilities"
flags: "--traits FieldMaskUtilities"
name: Swift ${{ matrix.swift }} | Traits - ${{ matrix.traits }}
container:
image: swift:${{ matrix.swift }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Update and install dependencies
# Just ensure we have the latest `g++` for building protoc (since it is
# built by SwiftPM), full dependencies available at
# https://github.com/protocolbuffers/protobuf/blob/main/src/README.md
#
# `make` is needed for using our own `Makefile`.
run: apt-get update && apt-get install -y make g++
- name: Build
run: make build SWIFT_BUILD_TEST_HOOK="-Xswiftc -warnings-as-errors ${{ matrix.flags }}"
- name: Test runtime
run: make test-runtime SWIFT_BUILD_TEST_HOOK="-Xswiftc -warnings-as-errors ${{ matrix.flags }}"
- name: Test plugin
if: ${{ matrix.traits == 'default' }}
run: make test-plugin
- name: Test SPM plugin
if: ${{ matrix.traits == 'default' }}
run: make test-spm-plugin
compile_tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
swift: *swift_versions
name: Swift ${{ matrix.swift }} | Compilation Tests
container:
image: swift:${{ matrix.swift }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Update and install dependencies
# Just ensure we have the latest `g++` for building protoc (since it is
# built by SwiftPM), full dependencies available at
# https://github.com/protocolbuffers/protobuf/blob/main/src/README.md
#
# `make` is needed for using our own `Makefile`.
run: apt-get update && apt-get install -y make g++ python3
- name: Compilation Tests
run: make compile-tests
# TODO: Enable this when the NSLock usage is resolved.
# linkage-test:
# runs-on: ubuntu-latest
# name: Foundation linkage test
# container:
# image: swift:latest
# steps:
# - name: Checkout
# uses: actions/checkout@v6
# - name: Update and install dependencies
# # Just ensure we have the latest `g++` for building protoc (since it is
# # built by SwiftPM), full dependencies available at
# # https://github.com/protocolbuffers/protobuf/blob/main/src/README.md
# run: apt-get update && apt-get install -y g++
# - name: Run linkage test
# run: ./scripts/run-linkage-test.sh
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@v6
- 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'
# TODO: Using block comments for some test follow ups.
# - 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@v6
- 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://github.com/swiftlang/swift/issues/49397
if [ "${{ matrix.sanitizer }}" = "address" ] ; then
export ASAN_OPTIONS=detect_leaks=0
fi
swift test -c ${{ matrix.swiftpm_config }} --sanitize=${{ matrix.sanitizer }}
fuzzing_regressions:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# TODO: "debug" is timing out, need to check for something that is really inefficient.
# swiftpm_config: ["debug", "release"]
swiftpm_config: ["release"]
container:
# Test on the latest Swift release.
image: swift:latest
steps:
- uses: actions/checkout@v6
- name: Build
run: FuzzTesting/do_build.sh --${{ matrix.swiftpm_config }}-only --run-regressions