Files
json/.github/workflows/check_amalgamation.yml
Niels Lohmann 734fd305a1
Code scanning - action / CodeQL-Build (push) Canceled after 0s
flawfinder / Flawfinder (push) Canceled after 0s
macOS / macos-14 (15.0.1) (push) Canceled after 0s
macOS / macos-14 (15.1) (push) Canceled after 0s
macOS / macos-14 (15.2) (push) Canceled after 0s
macOS / macos-14 (15.3) (push) Canceled after 0s
macOS / macos-14 (15.4) (push) Canceled after 0s
macOS / macos-15 (16.0) (push) Canceled after 0s
macOS / macos-15 (16.1) (push) Canceled after 0s
macOS / macos-15 (16.2) (push) Canceled after 0s
macOS / macos-15 (16.3) (push) Canceled after 0s
macOS / macos-15 (16.4) (push) Canceled after 0s
macOS / macos-15 (26.0.1) (push) Canceled after 0s
macOS / xcode_standards (11) (push) Canceled after 0s
macOS / xcode_standards (14) (push) Canceled after 0s
macOS / xcode_standards (17) (push) Canceled after 0s
macOS / xcode_standards (20) (push) Canceled after 0s
macOS / xcode_standards (23) (push) Canceled after 0s
macOS / xcode_standards (26) (push) Canceled after 0s
Publish documentation / publish_documentation (push) Canceled after 0s
Scorecard supply-chain security / Scorecard analysis (push) Canceled after 0s
Semgrep / Scan (push) Canceled after 0s
Ubuntu / ci_test_gcc (push) Canceled after 0s
Ubuntu / ci_infer (push) Canceled after 0s
Ubuntu / ci_static_analysis_ubuntu (ci_cppcheck) (push) Canceled after 0s
Ubuntu / ci_static_analysis_ubuntu (ci_cpplint) (push) Canceled after 0s
Ubuntu / ci_static_analysis_ubuntu (ci_non_git_tests) (push) Canceled after 0s
Ubuntu / ci_static_analysis_ubuntu (ci_offline_testdata) (push) Canceled after 0s
Ubuntu / ci_static_analysis_ubuntu (ci_reproducible_tests) (push) Canceled after 0s
Ubuntu / ci_static_analysis_ubuntu (ci_reuse_compliance) (push) Canceled after 0s
Ubuntu / ci_static_analysis_ubuntu (ci_test_amalgamation) (push) Canceled after 0s
Ubuntu / ci_static_analysis_ubuntu (ci_test_single_header) (push) Canceled after 0s
Ubuntu / ci_static_analysis_ubuntu (ci_test_valgrind) (push) Canceled after 0s
Ubuntu / ci_static_analysis_clang (ci_clang_analyze) (push) Canceled after 0s
Ubuntu / ci_static_analysis_clang (ci_clang_tidy) (push) Canceled after 0s
Ubuntu / ci_static_analysis_clang (ci_single_binaries) (push) Canceled after 0s
Ubuntu / ci_static_analysis_clang (ci_test_clang) (push) Canceled after 0s
Ubuntu / ci_static_analysis_clang (ci_test_clang_sanitizer) (push) Canceled after 0s
Ubuntu / ci_cmake_options (ci_cmake_flags) (push) Canceled after 0s
Ubuntu / ci_cmake_options (ci_test_diagnostic_positions) (push) Canceled after 0s
Ubuntu / ci_cmake_options (ci_test_diagnostics) (push) Canceled after 0s
Ubuntu / ci_cmake_options (ci_test_legacycomparison) (push) Canceled after 0s
Ubuntu / ci_cmake_options (ci_test_noexceptions) (push) Canceled after 0s
Ubuntu / ci_cmake_options (ci_test_noglobaludls) (push) Canceled after 0s
Ubuntu / ci_cmake_options (ci_test_noimplicitconversions) (push) Canceled after 0s
Ubuntu / ci_test_coverage (push) Canceled after 0s
Ubuntu / ci_test_compilers_gcc_old (4.8) (push) Canceled after 0s
Ubuntu / ci_test_compilers_gcc_old (4.9) (push) Canceled after 0s
Ubuntu / ci_test_compilers_gcc_old (5) (push) Canceled after 0s
Ubuntu / ci_test_compilers_gcc_old (6) (push) Canceled after 0s
Ubuntu / ci_test_compilers_gcc (10) (push) Canceled after 0s
Ubuntu / ci_test_compilers_gcc (11) (push) Canceled after 0s
Ubuntu / ci_test_compilers_gcc (12) (push) Canceled after 0s
Ubuntu / ci_test_compilers_gcc (13) (push) Canceled after 0s
Ubuntu / ci_test_compilers_gcc (14) (push) Canceled after 0s
Ubuntu / ci_test_compilers_gcc (15) (push) Canceled after 0s
Ubuntu / ci_test_compilers_gcc (7) (push) Canceled after 0s
Ubuntu / ci_test_compilers_gcc (8) (push) Canceled after 0s
Ubuntu / ci_test_compilers_gcc (9) (push) Canceled after 0s
Ubuntu / ci_test_compilers_gcc (latest) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (10) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (11) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (12) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (13) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (14) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (15-bullseye) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (16) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (17) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (18) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (19) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (20) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (21) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (22) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (3.4) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (3.5) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (3.6) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (3.7) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (3.8) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (3.9) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (4) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (5) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (6) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (7) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (8) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (9) (push) Canceled after 0s
Ubuntu / ci_test_compilers_clang (latest) (push) Canceled after 0s
Ubuntu / ci_test_standards_gcc (11) (push) Canceled after 0s
Ubuntu / ci_test_standards_gcc (14) (push) Canceled after 0s
Ubuntu / ci_test_standards_gcc (17) (push) Canceled after 0s
Ubuntu / ci_test_standards_gcc (20) (push) Canceled after 0s
Ubuntu / ci_test_standards_gcc (23) (push) Canceled after 0s
Ubuntu / ci_test_standards_gcc (26) (push) Canceled after 0s
Ubuntu / ci_test_standards_clang (11, libcxx) (push) Canceled after 0s
Ubuntu / ci_test_standards_clang (11, libstdcxx) (push) Canceled after 0s
Ubuntu / ci_test_standards_clang (14, libcxx) (push) Canceled after 0s
Ubuntu / ci_test_standards_clang (14, libstdcxx) (push) Canceled after 0s
Ubuntu / ci_test_standards_clang (17, libcxx) (push) Canceled after 0s
Ubuntu / ci_test_standards_clang (17, libstdcxx) (push) Canceled after 0s
Ubuntu / ci_test_standards_clang (20, libcxx) (push) Canceled after 0s
Ubuntu / ci_test_standards_clang (20, libstdcxx) (push) Canceled after 0s
Ubuntu / ci_test_standards_clang (23, libcxx) (push) Canceled after 0s
Ubuntu / ci_test_standards_clang (23, libstdcxx) (push) Canceled after 0s
Ubuntu / ci_test_standards_clang (26, libcxx) (push) Canceled after 0s
Ubuntu / ci_test_standards_clang (26, libstdcxx) (push) Canceled after 0s
Ubuntu / ci_cuda_example (11.8.0) (push) Canceled after 0s
Ubuntu / ci_cuda_example (12.1.1) (push) Canceled after 0s
Ubuntu / ci_cuda_example (12.6.3) (push) Canceled after 0s
Ubuntu / ci_module_cpp20 (gcc:latest) (push) Canceled after 0s
Ubuntu / ci_module_cpp20 (silkeh/clang:latest) (push) Canceled after 0s
Ubuntu / ci_icpc (push) Canceled after 0s
Ubuntu / ci_icpx (push) Canceled after 0s
Ubuntu / ci_nvhpc (push) Canceled after 0s
Ubuntu / ci_emscripten (push) Canceled after 0s
Ubuntu / ci_test_documentation (ci_test_build_documentation) (push) Canceled after 0s
Ubuntu / ci_test_documentation (ci_test_examples) (push) Canceled after 0s
Windows / mingw (x64) (push) Canceled after 0s
Windows / mingw (x86) (push) Canceled after 0s
Windows / msvc (Win32, Debug, default) (push) Canceled after 0s
Windows / msvc (Win32, Debug, latest) (push) Canceled after 0s
Windows / msvc (Win32, Release, default) (push) Canceled after 0s
Windows / msvc (Win32, Release, latest) (push) Canceled after 0s
Windows / msvc (x64, Debug, default) (push) Canceled after 0s
Windows / msvc (x64, Debug, latest) (push) Canceled after 0s
Windows / msvc (x64, Release, default) (push) Canceled after 0s
Windows / msvc (x64, Release, latest) (push) Canceled after 0s
Windows / msvc-vs2026 (Win32, Debug, default) (push) Canceled after 0s
Windows / msvc-vs2026 (Win32, Debug, latest) (push) Canceled after 0s
Windows / msvc-vs2026 (Win32, Release, default) (push) Canceled after 0s
Windows / msvc-vs2026 (Win32, Release, latest) (push) Canceled after 0s
Windows / msvc-vs2026 (x64, Debug, default) (push) Canceled after 0s
Windows / msvc-vs2026 (x64, Debug, latest) (push) Canceled after 0s
Windows / msvc-vs2026 (x64, Release, default) (push) Canceled after 0s
Windows / msvc-vs2026 (x64, Release, latest) (push) Canceled after 0s
Windows / msvc-arm64 (Debug) (push) Canceled after 0s
Windows / msvc-arm64 (Release) (push) Canceled after 0s
Windows / clang (11.0.1) (push) Canceled after 0s
Windows / clang (12.0.1) (push) Canceled after 0s
Windows / clang (13.0.1) (push) Canceled after 0s
Windows / clang (14.0.6) (push) Canceled after 0s
Windows / clang (15.0.7) (push) Canceled after 0s
Windows / clang (16.0.6) (push) Canceled after 0s
Windows / clang (18.1.8) (push) Canceled after 0s
Windows / clang (19.1.7) (push) Canceled after 0s
Windows / clang (20.1.8) (push) Canceled after 0s
Windows / clang-cl-12 (Win32) (push) Canceled after 0s
Windows / clang-cl-12 (x64) (push) Canceled after 0s
Windows / ci_module_cpp20 (push) Canceled after 0s
Format-check the documentation examples in CI (#5386)
* Reformat parser_callback_t example with astyle

The file uses "json & /*parsed*/" in three lambda parameter lists, which
astyle rewrites to "json& /*parsed*/" per --align-reference=type. The
drift went unnoticed because CI never format-checked the documentation
examples; "make pretty" does cover them.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* Format-check the documentation examples in CI

The examples live in docs/mkdocs/docs/examples, but both format checks
still referenced the long-gone docs/examples path:

- check_amalgamation.yml passed it to find, which printed an error for
  the missing path and carried on, so astyle only ever saw include and
  tests. The step still exited 0.
- ci.cmake globbed it into INDENT_FILES, and a GLOB_RECURSE over a
  missing directory silently yields nothing, so the ci_test_amalgamation
  target skipped the examples too.

Either way the 231 example files have never been format-checked. Point
both at the real path, and guard the workflow with an explicit directory
check so a future rename fails the job instead of quietly shrinking the
file list again.

Also drop the dead docs/examples/** path filter from
publish_documentation.yml; docs/mkdocs/** already covers the examples.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-08-20 12:32:50 +02:00

109 lines
3.8 KiB
YAML

name: "Check amalgamation"
on:
pull_request:
permissions:
contents: read
jobs:
save:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit
- name: Save PR number
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/number
echo ${{ github.event.pull_request.user.login }} > ./pr/author
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: pr
path: pr/
check:
runs-on: ubuntu-latest
env:
MAIN_DIR: ${{ github.workspace }}/main
INCLUDE_DIR: ${{ github.workspace }}/main/single_include/nlohmann
TOOL_DIR: ${{ github.workspace }}/tools/tools/amalgamate
steps:
- name: Harden Runner
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit
- name: Checkout pull request
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: main
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
- name: Checkout tools
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: tools
ref: develop
persist-credentials: false
- name: Install astyle
run: |
python3 -mvenv venv
venv/bin/pip3 install -r $MAIN_DIR/tools/astyle/requirements.txt
- name: Regenerate amalgamation and formatting
run: |
cd $MAIN_DIR
python3 $TOOL_DIR/amalgamate.py -c $TOOL_DIR/config_json.json -s .
python3 $TOOL_DIR/amalgamate.py -c $TOOL_DIR/config_json_fwd.json -s .
${{ github.workspace }}/venv/bin/astyle --project=tools/astyle/.astylerc --suffix=none --quiet \
$INCLUDE_DIR/json.hpp $INCLUDE_DIR/json_fwd.hpp
# fail loudly if a directory is renamed or removed: find would only warn
# about the missing path and silently drop its files from the check
SOURCE_DIRS="docs/mkdocs/docs/examples include tests"
for DIR in $SOURCE_DIRS; do
if [ ! -d "$DIR" ]; then
echo "::error::source directory '$DIR' does not exist"
exit 1
fi
done
${{ github.workspace }}/venv/bin/astyle --project=tools/astyle/.astylerc --suffix=none --quiet \
$(find $SOURCE_DIRS -type f \( -name '*.hpp' -o -name '*.cpp' -o -name '*.cu' \) -not -path 'tests/thirdparty/*' -not -path 'tests/abi/include/nlohmann/*' | sort)
- name: Build patch and check for differences
id: diff
run: |
cd $MAIN_DIR
mkdir -p ${{ github.workspace }}/patch
git diff --patch --no-color > ${{ github.workspace }}/patch/amalgamation.patch
if [ -s ${{ github.workspace }}/patch/amalgamation.patch ]; then
echo "The source code has not been amalgamated/formatted correctly. Diff:"
cat ${{ github.workspace }}/patch/amalgamation.patch
echo "has_diff=true" >> "$GITHUB_OUTPUT"
else
echo "has_diff=false" >> "$GITHUB_OUTPUT"
fi
# Uploaded so contributors can fix their PR with `git apply amalgamation.patch`
# instead of installing the pinned astyle version locally.
- name: Upload patch
if: steps.diff.outputs.has_diff == 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: amalgamation-patch
path: patch/amalgamation.patch
- name: Fail if not amalgamated/formatted
if: steps.diff.outputs.has_diff == 'true'
run: exit 1