Skip to content

Commit

Permalink
CI: make sure build instructions are kept up to date
Browse files Browse the repository at this point in the history
by checking to make sure that no options() are set in the cmake without
documenting them in the build instructions

Make a script that does this, and run it in CI.

Signed-off-by: Robin Getz <rgetz@mathworks.com>
  • Loading branch information
rgetz authored and pcercuei committed May 8, 2023
1 parent 642e033 commit 8e0c83c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
34 changes: 34 additions & 0 deletions CI/azure/check_README_BUILD.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

# Check the project CMake for options, which are not described in the README_BUILD.md file
# At the same time, check to make sure the defaults are described properly.

error=0

options() {
for file in $(find ./ -not \( -path ./deps -prune \) -name CMakeLists.txt)
do
grep option[[:space:]]*\( "${file}" | \
sed -e "s/^[[:space:]]*//g" -e "s/(/ /g" | \
awk '{print $2}'
done | sort | uniq
}

for opt in $(options)
do
default=$(for file in $(find ./ -not \( -path ./deps -prune \) -name CMakeLists.txt)
do
grep "option[[:space:]]*(${opt} " "${file}" | \
sed -e "s/^[[:space:]]*//g" -e "s/)[[:space:]]*$//" | \
awk '{print $NF}'
done)
if ! grep -q "${opt}.*${default}" README_BUILD.md ; then
echo "no match with ${opt} set with ${default}"
grep -R "${opt}" ./*
error=1
fi
done

if [ "${error}" -eq "1" ] ; then
exit 1
fi
3 changes: 3 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ stages:
- script: ./CI/azure/check_kernel.sh
displayName: 'Kernel check'
condition: and(eq(variables['artifactName'], 'Linux-Ubuntu-22.04'), eq(variables['Build.Reason'], 'PullRequest'))
- script: ./CI/azure/check_README_BUILD.sh
displayName: 'README_BUILD check'
condition: and(eq(variables['artifactName'], 'Linux-Ubuntu-22.04'), eq(variables['Build.Reason'], 'PullRequest'))
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
Expand Down

0 comments on commit 8e0c83c

Please sign in to comment.