Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Actions workflow to verify NIC files match source #35

Merged
merged 5 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.