Skip to content

Commit 801359e

Browse files
committed
Add check for parameter yaml to ensure consistence with source
1 parent 12515e5 commit 801359e

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

.github/workflows/build_test_cmake.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,35 @@ jobs:
7878
rm -rf build
7979
cmake -B build -G Ninja ${{ matrix.build_args }}
8080
cmake --build build -j $(nproc)
81+
82+
- name: Check parameters.yaml consistency
83+
if: matrix.tag == 'gnu' && matrix.build_args == ''
84+
run: |
85+
ABACUS_BIN=$(find build -maxdepth 1 -name "abacus_*" -type f -executable | head -1)
86+
if [ -z "${ABACUS_BIN}" ]; then
87+
echo "ERROR: Could not find abacus binary in build/"
88+
exit 1
89+
fi
90+
echo "Using binary: ${ABACUS_BIN}"
91+
${ABACUS_BIN} --generate-parameters-yaml > /tmp/parameters_generated.yaml
92+
if ! diff -q docs/parameters.yaml /tmp/parameters_generated.yaml; then
93+
echo ""
94+
echo "============================================"
95+
echo "ERROR: docs/parameters.yaml is out of sync!"
96+
echo "============================================"
97+
echo ""
98+
echo "The committed parameters.yaml does not match the parameter"
99+
echo "metadata embedded in the C++ source code. This usually means"
100+
echo "a developer modified Input_Item definitions in"
101+
echo "source/source_io/module_parameter/read_input_item_*.cpp"
102+
echo "but forgot to regenerate the YAML file."
103+
echo ""
104+
echo "To fix, run the following commands locally:"
105+
echo ""
106+
echo " \${ABACUS_BIN} --generate-parameters-yaml > docs/parameters.yaml"
107+
echo ""
108+
echo "--- Diff ( < committed | > generated ) ---"
109+
diff docs/parameters.yaml /tmp/parameters_generated.yaml || true
110+
exit 1
111+
fi
112+
echo "parameters.yaml is up-to-date."

0 commit comments

Comments
 (0)