Skip to content
Closed
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
40 changes: 40 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,43 @@ jobs:
exit 1
fi
echo "TESSL_TOKEN is correctly unset"

test-anonymous-id:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Install
uses: ./

- name: Verify anonymous ID exists and has correct format
run: |
ID_FILE="$HOME/.tessl/anonymous-id"
if [ ! -f "$ID_FILE" ]; then
echo "::error::Anonymous ID file not created"
exit 1
fi
ID=$(cat "$ID_FILE")
if ! echo "$ID" | grep -qE '^anon-[0-9a-f]{32}$'; then
echo "::error::Anonymous ID has wrong format: $ID"
exit 1
fi
echo "Anonymous ID: $ID"

- name: Verify anonymous ID is deterministic
run: |
EXISTING=$(cat "$HOME/.tessl/anonymous-id")
if command -v sha256sum >/dev/null 2>&1; then
HASH=$(echo -n "setup-tessl-action:${GITHUB_REPOSITORY_ID}" | sha256sum | cut -c1-32)
else
HASH=$(echo -n "setup-tessl-action:${GITHUB_REPOSITORY_ID}" | shasum -a 256 | cut -c1-32)
fi
EXPECTED="anon-${HASH}"
if [ "$EXISTING" != "$EXPECTED" ]; then
echo "::error::Anonymous ID mismatch: got '$EXISTING', expected '$EXPECTED'"
exit 1
fi
echo "Anonymous ID is deterministic: $EXISTING"
11 changes: 11 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ runs:
PLATFORM: ${{ steps.platform.outputs.platform }}
run: echo "${RUNNER_TOOL_CACHE}/tessl/${VERSION}/${PLATFORM}" >> "$GITHUB_PATH"

- name: Seed stable anonymous ID
shell: bash
run: |
mkdir -p "$HOME/.tessl"
if command -v sha256sum >/dev/null 2>&1; then
HASH=$(echo -n "setup-tessl-action:${GITHUB_REPOSITORY_ID}" | sha256sum | cut -c1-32)
else
HASH=$(echo -n "setup-tessl-action:${GITHUB_REPOSITORY_ID}" | shasum -a 256 | cut -c1-32)
fi
echo -n "anon-${HASH}" > "$HOME/.tessl/anonymous-id"

- name: Verify installation
shell: bash
run: |
Expand Down
Loading