Skip to content

Add a public-header CI gate matching stricter warning flags#1503

Open
bmehta001 wants to merge 7 commits into
microsoft:mainfrom
bmehta001:bhamehta/public-header-gate
Open

Add a public-header CI gate matching stricter warning flags#1503
bmehta001 wants to merge 7 commits into
microsoft:mainfrom
bmehta001:bhamehta/public-header-gate

Conversation

@bmehta001

@bmehta001 bmehta001 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Background

Prompted by @baijumeswani's review comment on #1501:

Is it possible to align the build flags used in this repo's pipelines with those that ort expects so we don't see errors when integrating with ort in the future?

This PR does exactly that: it adds a CI gate that compiles our public headers under the same strict warning flags ONNX Runtime applies, so header issues surface in this repo's pipeline instead of at ORT integration time.

Summary

Consumers that embed the SDK (e.g. ONNX Runtime / Foundry Local) compile their own translation units — which #include our public headers — under strict warning flags. From ONNX Runtime's CMake, its C++ targets use:

Toolchain Flags applied to code that includes our headers
GCC / Clang -Wall -Wextra + COMPILE_WARNING_AS_ERROR (= -Werror); Clang also -Wshorten-64-to-32
MSVC /W4 /WX

Third-party headers are normally suppressed (-isystem / /external:W0) only if the SDK is consumed as a proper external/imported target. When that suppression is defeated — include order, precompiled headers, or NO_SYSTEM_FROM_IMPORTED — any warning or missing include in our headers breaks the consumer build.

This PR adds a CI gate that compiles every public header on its own, with no -isystem suppression, under those flags on GCC, Clang, and MSVC — so header issues surface here instead of at integration time.

What's added

  • tests/headers/check_public_headers.sh — GCC + Clang (-std=c++17 -Wall -Wextra -Werror; Clang also -Wshorten-64-to-32).
  • tests/headers/check_public_headers.cmd — MSVC (/W4 /WX, STL suppressed via /external:W0 so only our headers gate).
  • A public-headers job added to the existing build-posix-latest.yml (GCC/Clang) and test-win-latest.yml (MSVC) workflows — no new standalone workflow file.

Bug the gate caught

CompliantByDefaultFilterApi.hpp uses std::vector<uint8_t> but did not include <cstdint>, so it only compiled when something else pulled <cstdint> in first — exactly the kind of latent self-containment issue that breaks a consumer depending on include order. Added the include.

VariantType.hpp is excluded from the standalone gate: it is an implementation fragment included by Variant.hpp (which defines VariantMap/VariantArray and the needed std headers before including it), not a standalone header.

Validation

All 40 public headers pass (39 compiled + VariantType.hpp excluded) locally on:

  • g++ (c++17, -Wall -Wextra -Werror): 39/39
  • clang++ (+ -Wshorten-64-to-32): 39/39
  • MSVC cl (/W4 /WX, STL external): 39/39

Relationship to #1501

Complementary. #1501 makes the headers warning-clean and marks the exported include dir SYSTEM. This PR locks that in with a gate matching ORT's actual flags and additionally verifies self-containment (which surfaced the <cstdint> bug).

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

…f-contained

Consumers that embed the SDK (e.g. ONNX Runtime / Foundry Local) compile their
own translation units -- which include our public headers -- under strict
warning flags: -Wall -Wextra -Werror on GCC/Clang (plus -Wshorten-64-to-32 on
Clang) and /W4 /WX on MSVC, suppressing third-party headers via -isystem /
/external:W0. When that suppression is defeated (include order, PCH, or
NO_SYSTEM_FROM_IMPORTED), any warning or missing include in our headers breaks
the consumer build.

This adds a CI gate that compiles every public header on its own, with no
-isystem suppression, under those flags on GCC, Clang, and MSVC, so header
issues surface here instead of at integration time:
- tests/headers/check_public_headers.sh  (GCC + Clang)
- tests/headers/check_public_headers.cmd (MSVC)
- .github/workflows/public-header-gate.yml

The gate caught one real self-containment bug: CompliantByDefaultFilterApi.hpp
uses std::vector<uint8_t> but did not include <cstdint>, so it only compiled when
something else pulled <cstdint> in first. Added the include. VariantType.hpp is
excluded: it is an implementation fragment included by Variant.hpp (which defines
VariantMap/VariantArray and the needed std headers first), not a standalone header.

Validated locally: all 40 public headers pass (39 compiled + VariantType
excluded) on g++, clang++, and MSVC cl /W4 /WX.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bmehta001 bmehta001 requested a review from a team as a code owner July 9, 2026 22:00
@bmehta001 bmehta001 requested a review from Copilot July 9, 2026 22:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a CI “public header gate” intended to catch warning-as-error and self-containment problems in exported headers (matching strict consumer builds like ONNX Runtime), so issues surface in this repo before downstream integration failures.

Changes:

  • Add GCC/Clang standalone public-header compilation gate (tests/headers/check_public_headers.sh).
  • Add MSVC standalone public-header compilation gate (tests/headers/check_public_headers.cmd).
  • Add GitHub Actions workflow to run the gate on Linux and Windows, plus fix a missing <cstdint> include in a public header.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
tests/headers/check_public_headers.sh New Linux header-compilation gate script for GCC/Clang.
tests/headers/check_public_headers.cmd New Windows header-compilation gate script for MSVC.
lib/include/public/CompliantByDefaultFilterApi.hpp Adds missing <cstdint> include for header self-containment.
.github/workflows/public-header-gate.yml New CI workflow to run the public-header gate on Ubuntu + Windows.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/headers/check_public_headers.sh Outdated
Comment thread tests/headers/check_public_headers.sh Outdated
Comment thread tests/headers/check_public_headers.cmd Outdated
Comment thread tests/headers/check_public_headers.cmd Outdated
…lags, fix MSVC includes

- Gate both *.hpp and *.h so the flat C API headers (mat.h, CommonFields.h) are
  covered, not just *.hpp. Both compile clean standalone under the gate flags.
- Drop -Wno-unused-but-set-variable from the GCC/Clang flags: no public header
  relies on it, so removing it makes the gate stricter. Kept -Wno-unused-parameter
  (mirrors this repo's WARN_FLAGS; intentional unused params use UNREFERENCED_PARAMETER).
- MSVC gate: add /I lib\include so headers that conditionally pull mat/config.h
  (e.g. CsProtocol_types.hpp) exercise the same include graph as the GCC/Clang gate.

Validated locally: 41/41 public headers pass on g++, clang++, and MSVC cl /W4 /WX.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

Comment thread .github/workflows/public-header-gate.yml Outdated
Comment thread .github/workflows/public-header-gate.yml Outdated
Comment thread .github/workflows/public-header-gate.yml Outdated
Comment thread .github/workflows/public-header-gate.yml Outdated
Instead of a standalone workflow, add the header gate as an isolated job in the
workflows that already run on the same triggers:
- build-posix-latest.yml gains a 'public-headers' job (GCC/Clang on ubuntu).
- test-win-latest.yml gains a 'public-headers' job (MSVC on windows).

Removes .github/workflows/public-header-gate.yml. The gate scripts under
tests/headers/ are unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@bmehta001 bmehta001 self-assigned this Jul 9, 2026
@bmehta001 bmehta001 changed the title Add a public-header CI gate matching consumer (ONNX Runtime) warning flags Add a public-header CI gate matching stricter warning flags Jul 9, 2026
@bmehta001 bmehta001 requested a review from Copilot July 10, 2026 16:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread tests/headers/check_public_headers.sh Outdated
bmehta001 and others added 2 commits July 10, 2026 11:31
…lags

The gate suppressed -Wunused-parameter, which is not part of the strict
consumer flag set it claims to mirror (-Wall -Wextra -Werror). That hid a real
break: NullObjects.hpp overrides left parameters unused because the old
UNREFERENCED_PARAMETER macro expanded to nothing on GCC/Clang, so a consumer
including LogManager.hpp with plain -Wall -Wextra -Werror failed to compile
while the gate passed. With the macro now expanding to (void)(...) (merged from
main), the headers are clean without the suppression; drop it so the gate
actually catches this class of consumer break.

Verified: 41/41 public headers pass standalone on g++ and clang++ without
-Wno-unused-parameter.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread tests/headers/check_public_headers.sh
Comment thread tests/headers/check_public_headers.cmd Outdated
The gate could silently pass without compiling anything: with nullglob the shell
header globs expand to nothing (and the batch FOR loop runs zero times) when the
computed public-header directory is wrong, so a miscomputed path reported success
while testing nothing. Both scripts now validate the public-header directory
exists and fail if zero headers were compiled.

Also give the MSVC script a unique per-invocation work directory
(%TEMP%\pubhdrgate_<rand>) so concurrent runs on the same machine cannot clobber
each other's temporary translation unit, and clean it up on exit.

Files: tests/headers/check_public_headers.sh, tests/headers/check_public_headers.cmd

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants