Skip to content

Run Conformance Tests #220

Run Conformance Tests

Run Conformance Tests #220

name: Run Conformance Tests
# This workflow is a subset of the build.yml. It *only* try to run the
# conformance checks. It is triggered weekly on a cron to catch when new
# conformance tests are added and they don't pass.
#
# Without this workflow the new tests wouldn't be noticed until a PR was made.
#
# This workflow shares the caching logic with build.yml. It should serve to
# update a subset of the caches for when things do land on trunk. If that
# is deemed not worth it in the future, this can be simplify.
# NOTE: If making changes to most of the steps, please also look to update
# build.yml also.
on:
schedule:
# Every Sunday at 5am.
- cron: '0 5 * * 0'
# Also allow manual triggering from the github UX to revalidate things.
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
# Looking at https://hub.docker.com/_/swift, the version only tags (i.e.
# - 5.9.2) can use different Ubuntu releases. But just to be safe we use
# the specific OS release.
#
# We could use less specific tags (i.e. - 5.9), 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:
- 6.0.1-noble
# 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@v4
with:
path: swift-protobuf
- 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: Cache protobuf
id: cache-protobuf
uses: actions/cache@v4
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@v4
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 conformance
working-directory: swift-protobuf
run: make test-conformance CONFORMANCE_TEST_RUNNER=../protobuf/cmake_build/conformance_test_runner