Skip to content

Commit

Permalink
Add GitHub Actions workflow to verify NIC files match source (#35)
Browse files Browse the repository at this point in the history
* Update iphone_preference_bundle.nic.tar to pass integrity_check.sh
  • Loading branch information
leptos-null authored Jul 14, 2024
1 parent 78f54b9 commit 6075a85
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/nic-integrity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: NIC Integrity

on:
push:

jobs:
check:
runs-on: ubuntu-latest
env:
THEOS: ${{ github.workspace }}/theos
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
submodules: recursive
path: templates

- name: Checkout theos/theos
uses: actions/checkout@v4
with:
repository: theos/theos
submodules: recursive
path: ${{ env.THEOS }}

- name: Check
run: |
cd templates
./integrity_check.sh
35 changes: 35 additions & 0 deletions integrity_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

set -e

WORKSPACE_DIR=$(mktemp -d --tmpdir='' "templates.XXXXXXXXXX")
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 -p . "${RESULT_FILE}.XXXXXXXXXX")
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 -r "${EXTRACT_DIR}"
rm "${RESULT_FILE}"
done

rm -r "${WORKSPACE_DIR}"

exit "${EXIT_CODE}"
Binary file modified iphone_preference_bundle.nic.tar
Binary file not shown.

0 comments on commit 6075a85

Please sign in to comment.