Skip to content

Commit 0c28913

Browse files
committed
Skip issue creation on first run
- Add first_run detection in compare step - Create GitHub Actions summary on first run with: - TinyTeX commit SHA and link to R/latex.R - Pattern and category counts - Baseline establishment message - Update Exit if unchanged to not exit on first run - Add cache update step for pattern changes - Update Save cache condition to include first_run - Update Summary step to handle all three cases
1 parent 8de90f3 commit 0c28913

File tree

1 file changed

+46
-11
lines changed

1 file changed

+46
-11
lines changed

.github/workflows/verify-tinytex-patterns.yml

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,56 @@ jobs:
4242
if [ -f .cache/regex.json ]; then
4343
if git diff --no-index --quiet .cache/regex.json regex.json; then
4444
echo "changed=false" >> $GITHUB_OUTPUT
45+
echo "first_run=false" >> $GITHUB_OUTPUT
4546
echo "✓ No changes detected"
4647
else
4748
echo "changed=true" >> $GITHUB_OUTPUT
49+
echo "first_run=false" >> $GITHUB_OUTPUT
4850
echo "✗ Changes detected"
4951
git diff --no-index .cache/regex.json regex.json > pattern-diff.txt || true
5052
fi
5153
else
52-
echo "changed=true" >> $GITHUB_OUTPUT
54+
echo "changed=false" >> $GITHUB_OUTPUT
55+
echo "first_run=true" >> $GITHUB_OUTPUT
5356
echo "⚠ No cached version (first run)"
54-
echo "First run - no previous version to compare" > pattern-diff.txt
5557
fi
5658
59+
- name: Handle first run
60+
if: steps.compare.outputs.first_run == 'true'
61+
env:
62+
GH_TOKEN: ${{ github.token }}
63+
run: |
64+
# Get tinytex commit SHA
65+
TINYTEX_COMMIT=$(gh api repos/rstudio/tinytex/commits/main --jq '.sha')
66+
TINYTEX_SHORT=$(echo $TINYTEX_COMMIT | cut -c1-7)
67+
68+
# Count patterns and categories
69+
PATTERN_COUNT=$(jq '[.[] | length] | add' regex.json)
70+
CATEGORY_COUNT=$(jq 'keys | length' regex.json)
71+
72+
# Write GitHub Actions summary
73+
echo "## TinyTeX Pattern Baseline Established" >> "$GITHUB_STEP_SUMMARY"
74+
echo "" >> "$GITHUB_STEP_SUMMARY"
75+
echo "- **Date:** $(date +%Y-%m-%d)" >> "$GITHUB_STEP_SUMMARY"
76+
echo "- **TinyTeX commit:** [\`$TINYTEX_SHORT\`](https://github.com/rstudio/tinytex/commit/$TINYTEX_COMMIT)" >> "$GITHUB_STEP_SUMMARY"
77+
echo "- **Pattern source:** [R/latex.R](https://github.com/rstudio/tinytex/blob/$TINYTEX_COMMIT/R/latex.R)" >> "$GITHUB_STEP_SUMMARY"
78+
echo "- **Baseline:** $PATTERN_COUNT patterns across $CATEGORY_COUNT categories" >> "$GITHUB_STEP_SUMMARY"
79+
echo "- **Cache key:** tinytex-regex-latest" >> "$GITHUB_STEP_SUMMARY"
80+
echo "" >> "$GITHUB_STEP_SUMMARY"
81+
echo "No issue created (first run - baseline established)." >> "$GITHUB_STEP_SUMMARY"
82+
83+
# Prepare cache directory
84+
mkdir -p .cache
85+
cp regex.json .cache/regex.json
86+
87+
echo "✓ Baseline established - cache will be saved"
88+
5789
- name: Exit if unchanged
58-
if: steps.compare.outputs.changed == 'false'
90+
if: steps.compare.outputs.changed == 'false' && steps.compare.outputs.first_run == 'false'
5991
run: |
6092
echo "No pattern changes detected. Cache hit - exiting."
6193
exit 0
6294
63-
- name: Prepare cache directory
64-
if: steps.compare.outputs.changed == 'true'
65-
run: |
66-
mkdir -p .cache
67-
cp regex.json .cache/regex.json
68-
6995
- name: Prepare readable diff
7096
if: steps.compare.outputs.changed == 'true'
7197
run: |
@@ -116,8 +142,15 @@ jobs:
116142
gh issue comment "$ISSUE_NUM" --body-file comment-body.md
117143
fi
118144
119-
- name: Save new cache
145+
- name: Update cache with new patterns
120146
if: steps.compare.outputs.changed == 'true'
147+
run: |
148+
mkdir -p .cache
149+
cp regex.json .cache/regex.json
150+
echo "✓ Cache updated with new patterns"
151+
152+
- name: Save new cache
153+
if: steps.compare.outputs.changed == 'true' || steps.compare.outputs.first_run == 'true'
121154
uses: actions/cache/save@v4
122155
with:
123156
path: .cache/regex.json
@@ -126,7 +159,9 @@ jobs:
126159
- name: Summary
127160
if: always()
128161
run: |
129-
if [ "${{ steps.compare.outputs.changed }}" == "true" ]; then
162+
if [ "${{ steps.compare.outputs.first_run }}" == "true" ]; then
163+
echo "✓ Baseline established - cache created"
164+
elif [ "${{ steps.compare.outputs.changed }}" == "true" ]; then
130165
echo "✗ Pattern changes detected - issue created/updated"
131166
else
132167
echo "✓ No pattern changes - cache hit"

0 commit comments

Comments
 (0)