Skip to content

Commit

Permalink
Add script to verify NIC files match the sources
Browse files Browse the repository at this point in the history
  • Loading branch information
leptos-null committed Jun 19, 2024
1 parent 78f54b9 commit a603a2b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions integrity_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

set -e

WORKSPACE_DIR=$(mktemp -d -t templates)
TEMPLATES_DIR=$(pwd)

# For each directory containing a valid NIC templates' source
TEMPLATES_SOURCES=$(find "${TEMPLATES_DIR}" -type d -name NIC -exec dirname {} \;)

cd "${WORKSPACE_DIR}"

EXIT_CODE=0

for TEMPLATES_SOURCE in $TEMPLATES_SOURCES; do
"${THEOS}/bin/nicify.pl" "${TEMPLATES_SOURCE}" 2> /dev/null
RESULT_FILE=$(ls *.nic.tar)
EXTRACT_DIR=$(mktemp -d -t "${RESULT_FILE}" -p .)
tar -xf "${TEMPLATES_DIR}/${RESULT_FILE}" -C "${EXTRACT_DIR}"
# thanks to https://stackoverflow.com/a/49633090
if ! diff -r --no-dereference --brief -x '.keep' "${TEMPLATES_SOURCE}" "${EXTRACT_DIR}"; then
EXIT_CODE=1
# per https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
if [[ "${GITHUB_ACTIONS}" = "true" ]]; then
# per https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message
echo "::error file=${RESULT_FILE},title=Mismatch::The NIC file does not match the template directory"
fi
fi
rm "${RESULT_FILE}"
done

exit "${EXIT_CODE}"

0 comments on commit a603a2b

Please sign in to comment.