-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaction.yml
More file actions
57 lines (52 loc) · 1.88 KB
/
action.yml
File metadata and controls
57 lines (52 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# This action.yml provides a GitHub Action for checking that a Spack recipe
# for a CMake-based package contains variants reflecting the available CMake
# options.
#
# Alex Richert, April 2024
name: 'Spack recipe check'
description: 'Check the Spack recipe for a CMake-based package'
inputs:
recipe-file:
required: true
cmakelists-txt:
required: true
ignore-list:
description: 'Space- or comma-delimited list of CMake option names to ignore because they are not needed in the Spack recipe (e.g., ENABLE_DOCS)'
default: ''
alternative-grep:
description: 'Use a more all-encompassing grep on the Spack recipe'
default: false
runs:
using: "composite"
steps:
- name: "Checkout package"
uses: actions/checkout@v4
with:
path: package
- name: "Check Spack recipe"
shell: bash
run: |
# Enable debug tracing if GitHub Actions debug mode is enabled
if [ "${RUNNER_DEBUG}" = "1" ]; then
# Set up a background process to prefix trace output
exec {trace_fd}> >(sed 's/^/::debug::/' >&2)
# Redirect trace output to our custom file descriptor
BASH_XTRACEFD=$trace_fd
set -x
fi
ignore_exp="$(echo ${{ inputs.ignore-list }} | sed 's:[[:space:],]\+:|:g')"
for opt in $(grep -ioP "^option\(\K[^ ]+" ${{ inputs.cmakelists-txt }} | grep -Ev "$ignore_exp") ; do
echo -n "Checking for presence of '$opt' CMake option in package.py..."
if [ ${{ inputs.alternative-grep }} == true ]; then
found=$(grep -cw "${opt}" ${{ inputs.recipe-file }} || true)
else
found=$(grep -cP "define.+\b${opt}\b" ${{ inputs.recipe-file }} || true)
fi
if [ $found -eq 0 ]; then
echo " NOT FOUND"
count+=1
else
echo " found"
fi
done
exit $count