Bring most of the protos shuffle/update over to the 1.x branch #864
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, 1_x_release_branch ] | |
pull_request: | |
branches: [ main, 1_x_release_branch ] | |
jobs: | |
core: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
swift: ["5.8.1", "5.7.3", "5.6.3", "5.5.3", "5.4.3", "5.3.3", "5.2.5", "5.1.5", "5.0.3", "4.2.4"] | |
# 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"] | |
include: | |
- swift: 5.8.1 | |
ubuntu: -jammy | |
generate_linux_main: false | |
build_protobuf: true | |
- swift: 5.7.3 | |
ubuntu: -jammy | |
generate_linux_main: false | |
build_protobuf: true | |
- swift: 5.6.3 | |
ubuntu: -focal | |
generate_linux_main: false | |
build_protobuf: true | |
- swift: 5.5.3 | |
ubuntu: -focal | |
generate_linux_main: false | |
build_protobuf: true | |
- swift: 5.4.3 | |
ubuntu: -focal | |
generate_linux_main: false | |
build_protobuf: true | |
- swift: 5.3.3 | |
ubuntu: -focal | |
generate_linux_main: true | |
build_protobuf: true | |
- swift: 5.2.5 | |
ubuntu: -focal | |
generate_linux_main: true | |
build_protobuf: true | |
- swift: 5.1.5 | |
ubuntu: -bionic | |
generate_linux_main: true | |
build_protobuf: false | |
- swift: 5.0.3 | |
ubuntu: -bionic | |
generate_linux_main: true | |
build_protobuf: false | |
- swift: 4.2.4 | |
generate_linux_main: true | |
build_protobuf: false | |
container: | |
image: swift:${{ matrix.swift }}${{ matrix.ubuntu }} | |
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 | |
# NOTE: zlib1g-dev is added to fix the Swift 5.0.x builds, when those builds aren't needed | |
# that dep likely can be removed. | |
run: | | |
set -eu | |
apt-get update | |
apt-get install -y curl make g++ cmake jq | |
[ \"${{ matrix.swift }}\" != \"5.0.3\" ] || apt-get install -y zlib1g-dev | |
- 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: Generate LinuxMain.swift | |
if: ${{ matrix.generate_linux_main }} | |
working-directory: main | |
run: make generate-linux-main | |
- name: Build | |
working-directory: main | |
run: make build | |
- name: Test runtime | |
working-directory: main | |
run: make test-runtime | |
- name: Cache protobuf | |
if: ${{ matrix.build_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: ${{ matrix.build_protobuf && 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: ${{ matrix.build_protobuf && 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 | |
if: ${{ matrix.build_protobuf }} | |
working-directory: main | |
run: make test-plugin PROTOC=../protobuf/cmake_build/protoc | |
- name: Test conformance | |
if: ${{ matrix.build_protobuf }} | |
working-directory: main | |
run: make test-conformance CONFORMANCE_TEST_RUNNER=../protobuf/cmake_build/conformance_test_runner | |
sanitizer_testing: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
sanitizer: ["address", "thread"] | |
swiftpm_config: ["debug", "release"] | |
container: | |
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: | |
image: swift:latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build | |
run: FuzzTesting/do_build.sh --${{ matrix.swiftpm_config }}-only --run-regressions |