Skip to content

Commit b2e8265

Browse files
authored
Revise CI running of conformance tests. (#1901)
- Have the `Makefile` provide better messaging in the conformance runners isn't found. - Have `build.yml` run the conformance tests as it is in the protobuf submodule. - Revise the cron based conformance run to be a protobuf HEAD run, so it happens on every PR and still happens on a cron as an early signal for when something might need attention.
1 parent a028b77 commit b2e8265

File tree

4 files changed

+80
-90
lines changed

4 files changed

+80
-90
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
name: Build and Test
22

3-
# NOTE: If making changes to most of the steps, please also look to update
4-
# regular_conformance.yml also.
53
permissions:
64
contents: read
75

@@ -42,8 +40,12 @@ jobs:
4240
with:
4341
submodules: true
4442
- name: Update and install dependencies
45-
# dependencies from https://github.com/protocolbuffers/protobuf/blob/main/src/README.md
46-
run: apt-get update && apt-get install -y make g++ cmake
43+
# Just ensure we have the latest `g++` for building protoc (since it is
44+
# built by SwiftPM), full dependencies available at
45+
# https://github.com/protocolbuffers/protobuf/blob/main/src/README.md
46+
#
47+
# `make` is needed for using our own `Makefile`.
48+
run: apt-get update && apt-get install -y make g++
4749
- name: Build
4850
run: make build ${{ matrix.swift.hook }}
4951
- name: Test runtime
@@ -60,23 +62,6 @@ jobs:
6062
# The protoc build isn't part of Package@swift-5.10.swift
6163
if: ${{ matrix.swift.version != '5.10' }}
6264
run: make compile-tests
63-
- name: Build protobuf
64-
working-directory: Sources/protobuf/protobuf
65-
# https://github.com/protocolbuffers/protobuf/blob/main/cmake/README.md#c-version
66-
run: |
67-
mkdir cmake_build
68-
cd cmake_build
69-
cmake \
70-
-DCMAKE_CXX_STANDARD=17 \
71-
-DCMAKE_BUILD_TYPE=Release \
72-
-Dprotobuf_BUILD_TESTS=OFF \
73-
-Dprotobuf_INSTALL=OFF \
74-
-Dprotobuf_BUILD_CONFORMANCE=ON \
75-
-S ..
76-
NUM_CPUS=$(getconf _NPROCESSORS_ONLN)
77-
make -j "${NUM_CPUS}" conformance_test_runner
78-
- name: Test conformance
79-
run: make test-conformance CONFORMANCE_TEST_RUNNER=Sources/protobuf/protobuf/cmake_build/conformance_test_runner
8065

8166
api-breakage:
8267
name: Api Breakage Compared to main branch
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Run Protobuf Head Conformance Tests
2+
3+
# This work workflow checks out head protocolbuffers/protobuf and runs the
4+
# conformances with that.
5+
#
6+
# It runs on all PRs/Commits and also runs on a Cron to keep an eye out for
7+
# new conformance tests that get added upstream.
8+
9+
permissions:
10+
contents: read
11+
12+
on:
13+
push:
14+
branches: [ main ]
15+
pull_request:
16+
branches: [ main ]
17+
# Every Sunday at 5am to get warning on any new conformance tests upstream.
18+
schedule:
19+
- cron: '0 5 * * 0'
20+
# Also allow manual triggering from the github UX to revalidate things.
21+
workflow_dispatch:
22+
23+
jobs:
24+
build:
25+
runs-on: ubuntu-latest
26+
container:
27+
# Unlike build.yml we only worry about the conformance test with the
28+
# latest Swift release.
29+
image: swift:latest
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
with:
34+
path: swift-protobuf
35+
submodules: true
36+
- name: Update and install dependencies
37+
# Dependencies from https://github.com/protocolbuffers/protobuf/blob/main/src/README.md
38+
run: apt-get update && apt-get install -y make g++ cmake
39+
- name: Checkout protobufbuffers/protobuf
40+
uses: actions/checkout@v4
41+
with:
42+
repository: protocolbuffers/protobuf
43+
path: protobuf
44+
- name: Build protobuf
45+
working-directory: protobuf
46+
# https://github.com/protocolbuffers/protobuf/blob/main/cmake/README.md#c-version
47+
run: |
48+
mkdir cmake_build
49+
cd cmake_build
50+
cmake \
51+
-DCMAKE_CXX_STANDARD=17 \
52+
-DCMAKE_BUILD_TYPE=Release \
53+
-Dprotobuf_BUILD_TESTS=OFF \
54+
-Dprotobuf_INSTALL=OFF \
55+
-Dprotobuf_BUILD_CONFORMANCE=ON \
56+
-S ..
57+
NUM_CPUS=$(getconf _NPROCESSORS_ONLN)
58+
make -j "${NUM_CPUS}" conformance_test_runner
59+
- name: Test conformance
60+
working-directory: swift-protobuf
61+
run: make test-conformance GOOGLE_PROTOBUF_CHECKOUT=../protobuf

.github/workflows/regular_conformance.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.

Makefile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ GENERATE_SRCS=${GENERATE_SRCS_BASE} -I Protos/Sources/SwiftProtobuf
6161
SWIFT_CONFORMANCE_PLUGIN=.build/debug/Conformance
6262

6363
# Where to find the conformance-test-runner. Defaults to being in your protobuf
64-
# checkout. Invoke make with CONFORMANCE_TEST_RUNNER=[PATH_TO_BINARY] to
65-
# override this value.
66-
CONFORMANCE_TEST_RUNNER?=${GOOGLE_PROTOBUF_CHECKOUT}/conformance_test_runner
64+
# checkout when built with CMake. Invoke make with
65+
# CONFORMANCE_TEST_RUNNER=[PATH_TO_BINARY] to override this value.
66+
CONFORMANCE_TEST_RUNNER?=${GOOGLE_PROTOBUF_CHECKOUT}/cmake_build/conformance_test_runner
6767

6868
# Hook to pass arge to swift build|test (mainly for the CI setup)
6969
SWIFT_BUILD_TEST_HOOK?=
@@ -76,6 +76,7 @@ PROTOS_DIRS=Sources/Conformance Sources/SwiftProtobuf Sources/SwiftProtobufPlugi
7676
all \
7777
build \
7878
check \
79+
check-for-conformance-runner \
7980
check-for-protobuf-checkout \
8081
check-proto-files \
8182
check-version-numbers \
@@ -645,8 +646,16 @@ check-proto-files: check-for-protobuf-checkout
645646
rm -f _check_protos.txt; \
646647
fi
647648

649+
check-for-conformance-runner:
650+
@if [ ! -x "${CONFORMANCE_TEST_RUNNER}" ]; then \
651+
echo "ERROR: ${CONFORMANCE_TEST_RUNNER} does not appear to exist"; \
652+
echo "ERROR: built build it or set CONFORMANCE_TEST_RUNNER to point"; \
653+
echo "ERROR: a runner."; \
654+
exit 1; \
655+
fi
656+
648657
# Runs the conformance tests.
649-
test-conformance: build check-for-protobuf-checkout Sources/Conformance/failure_list_swift.txt Sources/Conformance/text_format_failure_list_swift.txt
658+
test-conformance: check-for-conformance-runner build Sources/Conformance/failure_list_swift.txt Sources/Conformance/text_format_failure_list_swift.txt
650659
$(CONFORMANCE_TEST_RUNNER) \
651660
--enforce_recommended \
652661
--failure_list Sources/Conformance/failure_list_swift.txt \

0 commit comments

Comments
 (0)