forked from JCSDA/spack-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI checks for util/ utilities (JCSDA#658)
* Add util-tests.yaml * Add util_tests.sh * tweak util-tests.yaml * add checkout version to util-tests.yaml * fix matrix name in util-tests.yaml * fix util CI for MacOS --------- Co-authored-by: Dom Heinzeller <[email protected]>
- Loading branch information
1 parent
8988176
commit 7a628c7
Showing
3 changed files
with
105 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: util-tests | ||
|
||
on: [pull_request,push,workflow_dispatch] | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: false | ||
|
||
- name: run-util-tests | ||
run: | | ||
export SPACK_STACK_DIR=$PWD | ||
cd util/ | ||
./util_tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/bin/bash | ||
# This script is used by the GitHub Actions util-test workflow. | ||
|
||
# This functions runs a command and checks the return code. | ||
function run_and_check(){ | ||
expected=$1 | ||
label=$2 | ||
shift 2 | ||
echo "Running '$*' in $PWD" | ||
eval "$*" &> /tmp/output.$$ | ||
if [ $? -ne $expected ]; then | ||
echo "Test $label failed! Output:" | ||
cat /tmp/output.$$ | ||
rm /tmp/output.$$ | ||
echo | ||
fail=1 | ||
fi | ||
} | ||
|
||
echo "umask:" $(umask) | ||
chmod o+rX $HOME | ||
mkdir -p ${SPACK_STACK_DIR}/util/checks | ||
cd ${SPACK_STACK_DIR}/util/checks | ||
|
||
# Check check_permissions.sh | ||
mkdir -p perm_check1/perm_check2/perm_check3 | ||
cd perm_check1/perm_check2 | ||
chmod 777 ../../perm_check1 | ||
chmod 777 . | ||
chmod 777 ./perm_check3 | ||
run_and_check 0 "check_permissions A" ${SPACK_STACK_DIR}/util/check_permissions.sh | ||
chmod 776 ../../perm_check1 | ||
run_and_check 1 "check_permissions B" ${SPACK_STACK_DIR}/util/check_permissions.sh | ||
chmod 773 ../../perm_check1 | ||
run_and_check 1 "check_permissions C" ${SPACK_STACK_DIR}/util/check_permissions.sh | ||
chmod 770 ../../perm_check1 | ||
run_and_check 1 "check_permissions D" ${SPACK_STACK_DIR}/util/check_permissions.sh | ||
chmod 777 ../../perm_check1 | ||
chmod 776 perm_check3 | ||
run_and_check 1 "check_permissions E" ${SPACK_STACK_DIR}/util/check_permissions.sh | ||
chmod 773 perm_check3 | ||
run_and_check 1 "check_permissions F" ${SPACK_STACK_DIR}/util/check_permissions.sh | ||
chmod 770 perm_check3 | ||
run_and_check 1 "check_permissions G" ${SPACK_STACK_DIR}/util/check_permissions.sh | ||
|
||
# Check show_duplicate_packages.py | ||
cd ${SPACK_STACK_DIR}/util/checks | ||
echo -e " - abcdefg [email protected]\n - tuvwxyz [email protected]" > fakeconcrete.A | ||
run_and_check 1 "show_duplicate_packages.py A1" ${SPACK_STACK_DIR}/util/show_duplicate_packages.py fakeconcrete.A | ||
run_and_check 1 "show_duplicate_packages.py A2" "cat fakeconcrete.A | ${SPACK_STACK_DIR}/util/show_duplicate_packages.py" | ||
echo -e " - abcdefg [email protected]\n - tuvwxyz [email protected]" > fakeconcrete.B | ||
run_and_check 1 "show_duplicate_packages.py B1" ${SPACK_STACK_DIR}/util/show_duplicate_packages.py fakeconcrete.B | ||
run_and_check 1 "show_duplicate_packages.py B2" "cat fakeconcrete.B | ${SPACK_STACK_DIR}/util/show_duplicate_packages.py" | ||
echo -e " - abcdefg [email protected]\n[+] abcdefg [email protected]" > fakeconcrete.C | ||
run_and_check 0 "show_duplicate_packages.py C1" ${SPACK_STACK_DIR}/util/show_duplicate_packages.py fakeconcrete.C | ||
run_and_check 0 "show_duplicate_packages.py C2" "cat fakeconcrete.C | ${SPACK_STACK_DIR}/util/show_duplicate_packages.py" | ||
echo -e " - abcdefg [email protected]\n - tuvwxyz [email protected]\n - hijklmn [email protected]\n[+] opqrstu [email protected]" > fakeconcrete.D | ||
run_and_check 0 "show_duplicate_packages.py D1" ${SPACK_STACK_DIR}/util/show_duplicate_packages.py fakeconcrete.D -i hdf6 -i mypackage | ||
run_and_check 0 "show_duplicate_packages.py D2" ${SPACK_STACK_DIR}/util/show_duplicate_packages.py fakeconcrete.D -i mypackage -i hdf6 | ||
run_and_check 0 "show_duplicate_packages.py D3" "cat fakeconcrete.D | ${SPACK_STACK_DIR}/util/show_duplicate_packages.py -i hdf6 -i mypackage" | ||
run_and_check 0 "show_duplicate_packages.py D4" "cat fakeconcrete.D | ${SPACK_STACK_DIR}/util/show_duplicate_packages.py -i mypackage -i hdf6" | ||
run_and_check 1 "show_duplicate_packages.py D5" "cat fakeconcrete.D | ${SPACK_STACK_DIR}/util/show_duplicate_packages.py -i hdf6" | ||
run_and_check 1 "show_duplicate_packages.py D6" "cat fakeconcrete.D | ${SPACK_STACK_DIR}/util/show_duplicate_packages.py -i mypackage" | ||
|
||
cmd="${SPACK_STACK_DIR}/util/show_duplicate_packages.py fakeconcrete.A 2>/dev/null | uniq | grep -c hdf6" | ||
echo "Running '$cmd' in $PWD" | ||
if [ $(eval "$cmd") -ne 2 ] ; then | ||
echo "show_duplicate_packages.py E failed!" | ||
fail=1 | ||
fi | ||
|
||
cmd="${SPACK_STACK_DIR}/util/show_duplicate_packages.py fakeconcrete.F -d 2>/dev/null | uniq | grep -c hdf6" | ||
echo -e " - abcdefg [email protected]\n - tuvwxyz [email protected]\n - a1b2c3d [email protected]" > fakeconcrete.F | ||
if [ $(eval "$cmd") -ne 2 ] ; then | ||
echo "show_duplicate_packages.py F failed!" | ||
fail=1 | ||
fi | ||
|
||
exit $fail |