Debian Codegraph @

.github/workflows/unicode-check.yml

raw
1 # Watches for a new Unicode release and opens an issue when the tables pinned
2 # in tools/idna-data fall behind. Deliberately opens an issue rather than a
3 # pull request: a Unicode update warrants human review of the table diff and
4 # the regenerated UTS #46 conformance tests.
5
6 name: Check for new Unicode version
7
8 on:
9 schedule:
10 - cron: '0 6 1 * *' # monthly, 06:00 UTC on the 1st
11 workflow_dispatch:
12
13 permissions:
14 contents: read
15
16 jobs:
17 check:
18 runs-on: ubuntu-latest
19 permissions:
20 contents: read
21 issues: write
22 steps:
23 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
24
25 - name: Compare latest Unicode release against pinned version
26 id: compare
27 run: |
28 pinned=$(sed -n 's/^PREFERRED_VERSION = "\(.*\)"$/\1/p' tools/idna-data)
29 latest=$(curl -fsSL https://www.unicode.org/Public/UCD/latest/ReadMe.txt \
30 | sed -n 's/.*Version \([0-9][0-9.]*\) of the Unicode Standard.*/\1/p' | head -1)
31 echo "pinned=$pinned latest=$latest"
32 if [ -z "$latest" ]; then
33 echo "::error::Could not determine the latest Unicode version"
34 exit 1
35 fi
36 echo "pinned=$pinned" >> "$GITHUB_OUTPUT"
37 echo "latest=$latest" >> "$GITHUB_OUTPUT"
38 if [ "$pinned" = "$latest" ]; then
39 echo "Tables are current."
40 elif [ "$(curl -sSI -o /dev/null -w '%{http_code}' "https://www.unicode.org/Public/${latest}/idna/IdnaMappingTable.txt")" = "200" ]; then
41 # The generator also needs the UTS #46 files, which normally publish
42 # alongside the UCD but are checked separately to be safe. Redirects
43 # are not followed: unreleased version paths 302 to /Public/draft/.
44 echo "update=true" >> "$GITHUB_OUTPUT"
45 else
46 echo "UTS #46 data for ${latest} is not published yet; will check again next run."
47 fi
48
49 - name: Set up Python
50 if: steps.compare.outputs.update == 'true'
51 uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
52 with:
53 python-version: '3.14'
54
55 - name: Preview table changes for the new version
56 if: steps.compare.outputs.update == 'true'
57 id: preview
58 env:
59 LATEST: ${{ steps.compare.outputs.latest }}
60 run: |
61 if python tools/idna-data make-libdata --version "$LATEST" --dir idna --test-dir tests; then
62 summary=$(git diff --stat -- idna/idnadata.py idna/uts46data.py tests/test_idna_uts46.py)
63 else
64 summary="(tools/idna-data failed against ${LATEST}; the generator may need updating for this release)"
65 fi
66 {
67 echo 'summary<<EOF'
68 echo "$summary"
69 echo 'EOF'
70 } >> "$GITHUB_OUTPUT"
71
72 - name: Open tracking issue
73 if: steps.compare.outputs.update == 'true'
74 env:
75 GH_TOKEN: ${{ github.token }}
76 PINNED: ${{ steps.compare.outputs.pinned }}
77 LATEST: ${{ steps.compare.outputs.latest }}
78 SUMMARY: ${{ steps.preview.outputs.summary }}
79 RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
80 run: |
81 existing=$(gh issue list --state all --search "Unicode ${LATEST} in:title" --json number --jq length)
82 if [ "$existing" != "0" ]; then
83 echo "An issue for Unicode ${LATEST} already exists; nothing to do."
84 exit 0
85 fi
86 cat > body.md <<EOF
87 Unicode ${LATEST} has been released; the tables in this repository are generated from ${PINNED}.
88
89 To update:
90
91 1. Set \`PREFERRED_VERSION = "${LATEST}"\` in \`tools/idna-data\`.
92 2. Run \`tools/idna-data make-libdata --dir idna --test-dir tests\` to regenerate \`idna/idnadata.py\`, \`idna/uts46data.py\` and \`tests/test_idna_uts46.py\`.
93 3. Review the diff and run the test suite; new IdnaTestV2 vectors sometimes need entries in the generator's skip list.
94
95 Preview of the regenerated files against ${LATEST}:
96
97 \`\`\`
98 ${SUMMARY}
99 \`\`\`
100
101 Opened automatically by [the Unicode version check workflow](${RUN_URL}).
102 EOF
103 gh issue create --title "Unicode ${LATEST} data available" --body-file body.md