Skip to content

Add check for parameter yaml to ensure consistence with source #16296

Add check for parameter yaml to ensure consistence with source

Add check for parameter yaml to ensure consistence with source #16296

name: Build Test
on:
push:
pull_request:
defaults:
run:
shell: bash
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- tag: gnu
build_args: ""
name: "Build with GNU toolchain"
- tag: intel
external_toolchain_args: "--with-intel"
build_args: ""
name: "Build with Intel toolchain"
- tag: gnu
external_toolchain_args: ""
build_args: "-DENABLE_LIBXC=ON -DENABLE_MLALGO=ON -DENABLE_LIBRI=ON"
name: "Build extra components with GNU toolchain"
- tag: intel
external_toolchain_args: "--with-intel"
build_args: "-DENABLE_LIBXC=ON -DENABLE_PEXSI=ON -DENABLE_MLALGO=ON -DENABLE_LIBRI=ON"
name: "Build extra components with Intel toolchain"
- tag: cuda
external_toolchain_args: ""
build_args: "-DUSE_CUDA=ON"
name: "Build with CUDA support"
- tag: gnu
external_toolchain_args: ""
build_args: "-DENABLE_LCAO=OFF"
name: "Build without LCAO"
- tag: gnu
external_toolchain_args: ""
build_args: "-DUSE_ELPA=OFF "
name: "Build without ELPA"
- tag: gnu
external_toolchain_args: ""
build_args: "-DENABLE_MPI=OFF"
name: "Build without MPI"
- tag: gnu
external_toolchain_args: ""
build_args: "-DENABLE_MPI=OFF -DENABLE_LCAO=OFF"
name: "Build without LCAO and MPI"
name: ${{ matrix.name }}
container: ghcr.io/deepmodeling/abacus-${{ matrix.tag }}
steps:
- name: Checkout
uses: actions/checkout@v7
with:
submodules: recursive
- name: Install external tools from toolchain
run: |
sudo apt update && sudo apt install -y gfortran ninja-build xz-utils
cd toolchain
./install_abacus_toolchain_new.sh --with-dftd4=install --dry-run ${{matrix.external_toolchain_args}}
./scripts/stage4/install_stage4.sh
cd ..
- name: Build
run: |
git config --global --add safe.directory `pwd`
export LD_LIBRARY_PATH=${GKLIB_ROOT}/lib:${METIS32_ROOT}/lib:${PARMETIS32_ROOT}/lib:${SUPERLU_DIST32_ROOT}/lib:${PEXSI32_ROOT}/lib:${LD_LIBRARY_PATH}
export PKG_CONFIG_PATH=${GKLIB_ROOT}/lib/pkgconfig:${METIS32_ROOT}/lib/pkgconfig:${PARMETIS32_ROOT}/lib/pkgconfig:${SUPERLU_DIST32_ROOT}/lib/pkgconfig:${PEXSI32_ROOT}/lib/pkgconfig:${PKG_CONFIG_PATH}
export CPATH=${GKLIB_ROOT}/include:${METIS32_ROOT}/include:${PARMETIS32_ROOT}/include:${SUPERLU_DIST32_ROOT}/include:${PEXSI32_ROOT}/include:${CPATH}
export CMAKE_PREFIX_PATH=${PEXSI32_ROOT}:${SUPERLU_DIST32_ROOT}:${PARMETIS32_ROOT}:${METIS32_ROOT}:${GKLIB_ROOT}:${CMAKE_PREFIX_PATH}
source toolchain/install/setup
rm -rf build
cmake -B build -G Ninja ${{ matrix.build_args }}
cmake --build build -j $(nproc)
- name: Check parameters.yaml consistency
if: matrix.tag == 'gnu' && matrix.build_args == ''
run: |
ABACUS_BIN=$(find build -maxdepth 1 -name "abacus_*" -type f -executable | head -1)
if [ -z "${ABACUS_BIN}" ]; then
echo "ERROR: Could not find abacus binary in build/"
exit 1
fi
echo "Using binary: ${ABACUS_BIN}"
${ABACUS_BIN} --generate-parameters-yaml > /tmp/parameters_generated.yaml
if ! diff -q docs/parameters.yaml /tmp/parameters_generated.yaml; then
echo ""
echo "============================================"
echo "ERROR: docs/parameters.yaml is out of sync!"
echo "============================================"
echo ""
echo "The committed parameters.yaml does not match the parameter"
echo "metadata embedded in the C++ source code. This usually means"
echo "a developer modified Input_Item definitions in"
echo "source/source_io/module_parameter/read_input_item_*.cpp"
echo "but forgot to regenerate the YAML file."
echo ""
echo "To fix, run the following commands locally:"
echo ""
echo " \${ABACUS_BIN} --generate-parameters-yaml > docs/parameters.yaml"
echo ""
echo "--- Diff ( < committed | > generated ) ---"
diff docs/parameters.yaml /tmp/parameters_generated.yaml || true
exit 1
fi
echo "parameters.yaml is up-to-date."