Start removing support for Swift < 5.6. #885
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Test | |
# NOTE: If making changes to most of the steps, please also look to update | |
# regular_conformance.yml also. | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
core: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
# Looking at https://hub.docker.com/_/swift, the version only tags (i.e. | |
# - 5.6.3) use different Ubuntu releases. Generally we want to avoid | |
# bionic as it is older then we want to deal with having to build | |
# protobuf on. | |
# | |
# We also could use less specific tags (i.e. - 5.6), so they "float" as | |
# new point release come, but to help make history/logs more clear, | |
# being explicit (at the cost of having to update with point releases) | |
# seems better. This should also ensure protobuf caching changes with | |
# each new image incase system in the Swift image are changed/updated. | |
swift: | |
- 5.8.1-jammy | |
- 5.7.3-jammy | |
- 5.6.3-focal | |
# protobuf_git can reference a commit, tag, or branch | |
# commit: "commits/6935eae45c99926a000ecbef0be20dfd3d159e71" | |
# tag: "ref/tags/v3.11.4" | |
# branch: "ref/heads/main" | |
protobuf_git: ["ref/heads/main"] | |
container: | |
image: swift:${{ matrix.swift }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
path: main | |
- name: Update and install dependencies | |
# dependencies from https://github.com/protocolbuffers/protobuf/blob/main/src/README.md | |
# this step is run before get-sha because we need curl and jq for get-sha | |
run: apt-get update && apt-get install -y curl make g++ cmake jq | |
- name: Get Protobuf Commit SHA | |
id: get-sha | |
run: | | |
set -eu | |
url="https://api.github.com/repos/protocolbuffers/protobuf/git/${{ matrix.protobuf_git }}" | |
case ${{ matrix.protobuf_git }} in | |
ref/*) | |
echo "sha=$( curl -s -u "u:${{ github.token }}" "${url}" | jq -r .object.sha )" >> $GITHUB_OUTPUT | |
;; | |
commits/*) | |
echo "sha=$( curl -s -u "u:${{ github.token }}" "${url}" | jq -r .sha )" >> $GITHUB_OUTPUT | |
;; | |
esac | |
- name: Build | |
working-directory: main | |
run: make build | |
- name: Test runtime | |
working-directory: main | |
run: make test-runtime | |
- name: Cache protobuf | |
id: cache-protobuf | |
uses: actions/cache@v3 | |
with: | |
path: protobuf | |
# NOTE: for refs that can float like 'main' the cache might be out of date! | |
key: ${{ runner.os }}-${{ matrix.swift}}-protobuf-${{ steps.get-sha.outputs.sha }} | |
- name: Checkout protobuf repo | |
if: steps.cache-protobuf.outputs.cache-hit != 'true' | |
uses: actions/checkout@v3 | |
with: | |
repository: protocolbuffers/protobuf | |
ref: ${{ steps.get-sha.outputs.sha }} | |
submodules: true | |
path: protobuf | |
- name: Build protobuf | |
if: steps.cache-protobuf.outputs.cache-hit != 'true' | |
working-directory: protobuf | |
run: | | |
mkdir cmake_build | |
cd cmake_build | |
cmake \ | |
-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 | |
working-directory: main | |
run: make test-plugin PROTOC=../protobuf/cmake_build/protoc | |
- name: Test conformance | |
working-directory: main | |
run: make test-conformance CONFORMANCE_TEST_RUNNER=../protobuf/cmake_build/conformance_test_runner | |
- name: Test SPM plugin | |
working-directory: main | |
run: make test-spm-plugin PROTOC=../protobuf/cmake_build/protoc | |
sanitizer_testing: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
sanitizer: ["address", "thread"] | |
swiftpm_config: ["debug", "release"] | |
container: | |
# Test on the latest Swift release. | |
image: swift:latest | |
steps: | |
- uses: actions/checkout@v3 | |
- 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@v3 | |
- name: Build | |
run: FuzzTesting/do_build.sh --${{ matrix.swiftpm_config }}-only --run-regressions |