Skip to content

Professionalize the C++ exercise repository#28

Merged
doctorlai-msrc merged 3 commits into
mainfrom
refactor2
Jul 16, 2026
Merged

Professionalize the C++ exercise repository#28
doctorlai-msrc merged 3 commits into
mainfrom
refactor2

Conversation

@doctorlai-msrc

Copy link
Copy Markdown
Collaborator

Summary

Professionalize the C++ exercise repository with a consistent local/CI verification interface, sanitizer-aware builds, aggregate coverage gates, secure pull request coverage comments, and complete contributor-facing repository documentation.

Changes

  • Add top-level build, test, format, lint, coverage, and check Make targets.
  • Run clean sanitizer builds so object files cannot be reused across incompatible compiler flags.
  • Use fail-fast AddressSanitizer and UndefinedBehaviorSanitizer checks locally; run ThreadSanitizer on supported native Linux environments.
  • Detect WSL2 and skip the unsupported GCC ThreadSanitizer runtime there by default while retaining the full ASan/TSan/UBSan matrix in GitHub Actions.
  • Propagate shared linker flags through every example Makefile so sanitizer and coverage runtimes are linked consistently.
  • Generate text, HTML, XML, and JSON coverage reports with minimum coverage gates of 80% lines, 80% functions, and 70% branches.
  • Upload coverage artifacts and create or update a coverage summary comment on pull requests.
  • Keep the privileged coverage-comment workflow isolated from PR code, validate all artifact metrics, resolve fork PRs through the GitHub API, reject stale commits, serialize updates, and pin actions to immutable commit SHAs.
  • Replace the bc-based Pi checks with strict numeric awk validation.
  • Fix escaped newline output in the smart pointer and Sudoku examples.
  • Add .gitattributes, generated-artifact ignores, Dependabot configuration, issue/PR templates, and contributor, security, support, privacy, and changelog documentation.
  • Refresh the README with the complete example inventory, supported commands, dependencies, CI behavior, coverage policy, badges, and WSL2 sanitizer notes.
  • Update repository sponsorship options in .github/FUNDING.yml.

Coverage

Category Result Required
Lines 91.4% (755 / 826) 80%
Functions 98.9% (87 / 88) 80%
Branches 71.3% (469 / 658) 70%

Validation

  • make check on Ubuntu 24.04 under WSL2: passed with ASan and fail-fast UBSan; TSan was skipped as documented because the GCC runtime cannot reliably reserve its shadow-memory layout under WSL2.
  • make coverage: passed all aggregate thresholds and generated text, HTML, XML, and JSON reports.
  • Injected recursive clean, formatting, and compiler failures propagate as nonzero exits.
  • GitHub workflow and Dependabot YAML parsing: passed.
  • Embedded actions/github-script JavaScript syntax check: passed.
  • Shell syntax checks for clang-check.sh and all tests.sh files: passed.
  • README local-link and example-inventory checks: passed.
  • Editor diagnostics: no errors.
  • git diff HEAD --check: passed.

Notes

  • GitHub Actions explicitly runs ASan, TSan, and UBSan on native Ubuntu runners; native TSan could not be executed locally from this WSL2 workspace.
  • The workflow_run coverage-comment path, including fork PR association and concurrency cancellation, requires an actual pull request to verify end to end on GitHub.

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

This PR professionalizes the C++ examples repository by standardizing local developer commands, hardening/expanding CI (sanitizers + coverage + PR coverage comments), and adding contributor-facing repository documentation and housekeeping files.

Changes:

  • Introduces a consistent top-level make interface (build/test/format/lint/coverage/check), sanitizer-aware clean builds, and aggregate coverage reporting/gates.
  • Expands GitHub Actions into dedicated sanitizer and coverage jobs, plus a separate workflow_run-based coverage comment workflow with pinned action SHAs.
  • Updates examples and docs: propagates shared linker flags in example Makefiles, fixes escaped newline output in examples, replaces bc with strict awk validation in Pi tests, and adds repo policy docs/templates.

Reviewed changes

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

Show a summary per file
File Description
Makefile Adds top-level build/test/lint/coverage/check targets, WSL-aware sanitizer matrix defaults, and aggregate coverage generation via gcovr.
common.mk Adds COVERAGE switch for --coverage flags and makes UBSan fail-fast with -fno-sanitize-recover=undefined.
.github/workflows/ci.yml Splits CI into ASan/UBSan, dedicated TSan (with instrumented oneTBB), and coverage jobs; pins actions by SHA.
.github/workflows/coverage-comment.yml Adds isolated workflow_run workflow to post/update PR coverage summary comments from artifacts.
.gitignore Ignores additional build/coverage artifacts (deps, gcov outputs, binaries, coverage directory).
.gitattributes Enforces LF EOL normalization across common source/config file types.
README.md Expands documentation for prerequisites, commands, sanitizers (incl. WSL2 notes), CI behavior, and repo meta/badges.
CONTRIBUTING.md Adds contributor workflow, prerequisites, and required local validation commands.
SECURITY.md Adds a security policy and private reporting guidance.
SUPPORT.md Adds support channels and guidance for issues/discussions/security reports.
PRIVACY.md Documents repository privacy expectations and cautions about sharing sensitive data in public channels.
CHANGELOG.md Introduces a changelog entry describing the repo “professionalization” changes.
.github/PULL_REQUEST_TEMPLATE.md Adds PR template with validation and checklist items aligned with new make targets.
.github/ISSUE_TEMPLATE/bug_report.md Updates bug report template to request repro commands, sanitizer config, and environment details.
.github/FUNDING.yml Updates sponsorship configuration links.
.github/dependabot.yml Adds Dependabot configuration for GitHub Actions updates.
virtual-interface/Makefile Ensures link rules honor shared $(LDFLAGS)/$(LDLIBS) (sanitizers/coverage runtime linkage).
views-zip-enumerate/Makefile Ensures link rules honor shared $(LDFLAGS)/$(LDLIBS).
unique-ptr-basics/Makefile Ensures link rules honor shared $(LDFLAGS)/$(LDLIBS).
thread-safe-queue/Makefile Ensures link rules honor shared $(LDFLAGS)/$(LDLIBS).
sudoku-solver/Makefile Ensures link rules honor shared $(LDFLAGS)/$(LDLIBS).
sudoku-solver/main.cpp Fixes escaped newline output to print real line breaks in usage/errors/results.
smart-ptr/Makefile Ensures link rules honor shared $(LDFLAGS)/$(LDLIBS).
smart-ptr/main.cpp Fixes escaped newline output to print real line breaks in test output.
rot47/Makefile Ensures link rules honor shared $(LDFLAGS)/$(LDLIBS).
ranges-find-in-vector-string/Makefile Ensures link rules honor shared $(LDFLAGS)/$(LDLIBS).
prefix-sum/Makefile Ensures link rules honor shared $(LDFLAGS)/$(LDLIBS).
pi/Makefile Ensures link rules honor shared $(LDFLAGS)/$(LDLIBS).
pi/tests.sh Replaces bc comparisons with strict numeric validation and range checks via awk; uses safer bash flags.
pi-monte-carlo/Makefile Ensures link rules honor shared $(LDFLAGS)/$(LDLIBS).
pi-monte-carlo/tests.sh Replaces bc comparisons with strict numeric validation and range checks via awk; uses safer bash flags.
parallel-integral-pi/Makefile Ensures link rules honor shared $(LDFLAGS)/$(LDLIBS).
oop-with-exception/Makefile Ensures link rules honor shared $(LDFLAGS)/$(LDLIBS).
multithread-sum/Makefile Ensures link rules honor shared $(LDFLAGS)/$(LDLIBS).
map-with-unknown-key/Makefile Ensures link rules honor shared $(LDFLAGS)/$(LDLIBS).
integer-factorization/Makefile Ensures link rules honor shared $(LDFLAGS)/$(LDLIBS).
fold-left-fold-right/Makefile Ensures link rules honor shared $(LDFLAGS)/$(LDLIBS).

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

Comment thread .github/workflows/coverage-comment.yml Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@doctorlai-msrc
doctorlai-msrc merged commit 37f0291 into main Jul 16, 2026
3 checks passed
@doctorlai-msrc
doctorlai-msrc deleted the refactor2 branch July 16, 2026 20:00
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