Skip to content

Commit 1de9915

Browse files
committed
Add CI workflow to check regex.json in tinytex and detect changes
1 parent b20e001 commit 1de9915

File tree

3 files changed

+174
-0
lines changed

3 files changed

+174
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Update: {{DATE}}
2+
3+
New pattern changes detected.
4+
5+
<details>
6+
<summary>Click to expand diff</summary>
7+
8+
```diff
9+
{{DIFF}}
10+
```
11+
12+
</details>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## TinyTeX Pattern Update: {{DATE}}
2+
3+
The daily TinyTeX regex patterns have changed and need review.
4+
5+
### Pattern Diff
6+
7+
<details>
8+
<summary>Click to expand diff</summary>
9+
10+
```diff
11+
{{DIFF}}
12+
```
13+
14+
</details>
15+
16+
### Next Steps
17+
18+
See [dev-docs/tinytex-pattern-maintenance.md](https://github.com/quarto-dev/quarto-cli/blob/main/dev-docs/tinytex-pattern-maintenance.md) for detailed instructions.
19+
20+
**Review checklist:**
21+
22+
- [ ] Review diff for significant changes
23+
- [ ] Determine if patterns need adaptation
24+
- [ ] Update `parse-error.ts` if needed
25+
- [ ] Add/update filter functions
26+
- [ ] Run tests: `unit\latexmk\parse-error.test.ts`
27+
- [ ] Add test cases for new patterns if needed
28+
- [ ] Close this issue when complete
29+
30+
---
31+
32+
_Generated by [verify-tinytex-patterns.yml](https://github.com/quarto-dev/quarto-cli/blob/main/.github/workflows/verify-tinytex-patterns.yml)_
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Verify TinyTeX Pattern Coverage
2+
3+
on:
4+
schedule:
5+
- cron: '0 2 * * *' # Daily 2am UTC (matches TinyTeX daily release)
6+
workflow_dispatch: # Manual trigger for testing
7+
8+
permissions:
9+
contents: read
10+
issues: write
11+
12+
jobs:
13+
verify:
14+
name: Check TinyTeX Pattern Updates
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Download and extract regex.json
22+
env:
23+
GH_TOKEN: ${{ github.token }}
24+
run: |
25+
gh release download daily --repo rstudio/tinytex-releases --pattern "regex.tar.gz"
26+
tar -xzf regex.tar.gz
27+
echo "✓ Downloaded and extracted regex.json"
28+
29+
- name: Restore cached regex.json
30+
id: cache-restore
31+
uses: actions/cache/restore@v4
32+
with:
33+
path: .cache/regex.json
34+
key: tinytex-regex-latest
35+
36+
- name: Compare versions
37+
id: compare
38+
run: |
39+
if [ -f .cache/regex.json ]; then
40+
if git diff --no-index --quiet .cache/regex.json regex.json; then
41+
echo "changed=false" >> $GITHUB_OUTPUT
42+
echo "✓ No changes detected"
43+
else
44+
echo "changed=true" >> $GITHUB_OUTPUT
45+
echo "✗ Changes detected"
46+
git diff --no-index .cache/regex.json regex.json > pattern-diff.txt || true
47+
fi
48+
else
49+
echo "changed=true" >> $GITHUB_OUTPUT
50+
echo "⚠ No cached version (first run)"
51+
echo "First run - no previous version to compare" > pattern-diff.txt
52+
fi
53+
54+
- name: Exit if unchanged
55+
if: steps.compare.outputs.changed == 'false'
56+
run: |
57+
echo "No pattern changes detected. Cache hit - exiting."
58+
exit 0
59+
60+
- name: Prepare cache directory
61+
if: steps.compare.outputs.changed == 'true'
62+
run: |
63+
mkdir -p .cache
64+
cp regex.json .cache/regex.json
65+
66+
- name: Prepare readable diff
67+
if: steps.compare.outputs.changed == 'true'
68+
run: |
69+
# Pretty-print both JSON files for readable diff
70+
if [ -f .cache/regex.json ]; then
71+
jq --sort-keys . .cache/regex.json > old-formatted.json
72+
jq --sort-keys . regex.json > new-formatted.json
73+
git diff --no-index old-formatted.json new-formatted.json > readable-diff.txt || true
74+
else
75+
jq --sort-keys . regex.json > new-formatted.json
76+
echo "First run - no previous version to compare" > readable-diff.txt
77+
fi
78+
79+
- name: Create or update issue
80+
if: steps.compare.outputs.changed == 'true'
81+
env:
82+
GH_TOKEN: ${{ github.token }}
83+
run: |
84+
ISSUE_TITLE="TinyTeX patterns require review"
85+
CURRENT_DATE=$(date +%Y-%m-%d)
86+
87+
# Search for existing open issue
88+
ISSUE_NUM=$(gh issue list \
89+
--label "tinytex-patterns" \
90+
--state open \
91+
--json number,title \
92+
--jq ".[] | select(.title == \"$ISSUE_TITLE\") | .number")
93+
94+
if [ -z "$ISSUE_NUM" ]; then
95+
echo "No matching issue found, creating new one..."
96+
97+
# Use template and replace placeholders
98+
sed "s|{{DATE}}|$CURRENT_DATE|g" .github/workflows/templates/tinytex-issue-body.md | \
99+
sed -e "/{{DIFF}}/r readable-diff.txt" -e "/{{DIFF}}/d" > issue-body.md
100+
101+
gh issue create \
102+
--title "$ISSUE_TITLE" \
103+
--assignee cderv \
104+
--label "tinytex-patterns" \
105+
--body-file issue-body.md
106+
else
107+
echo "Found existing issue #$ISSUE_NUM, adding comment..."
108+
109+
# Use template and replace placeholders
110+
sed "s|{{DATE}}|$CURRENT_DATE|g" .github/workflows/templates/tinytex-comment-body.md | \
111+
sed -e "/{{DIFF}}/r readable-diff.txt" -e "/{{DIFF}}/d" > comment-body.md
112+
113+
gh issue comment "$ISSUE_NUM" --body-file comment-body.md
114+
fi
115+
116+
- name: Save new cache
117+
if: steps.compare.outputs.changed == 'true'
118+
uses: actions/cache/save@v4
119+
with:
120+
path: .cache/regex.json
121+
key: tinytex-regex-latest
122+
123+
- name: Summary
124+
if: always()
125+
run: |
126+
if [ "${{ steps.compare.outputs.changed }}" == "true" ]; then
127+
echo "✗ Pattern changes detected - issue created/updated"
128+
else
129+
echo "✓ No pattern changes - cache hit"
130+
fi

0 commit comments

Comments
 (0)