Repository navigation
174 lines (161 loc) · 7.01 KB
/
Copy pathappimage-freshness.yml
File metadata and controls
174 lines (161 loc) · 7.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: AppImage Freshness Check
# ══════════════════════════════════════════════════════════════════
# WARNING-ONLY job: detects when the AppImage needs rebuilding because
# the 4 scanner_fixer modules (deskew, crop, normalize, dedup) or the
# desktop GUI entry (medical_doc_gui_final.py) changed since the last
# successful build recorded in packages/desktop/.last_build_commit.
#
# This job NEVER fails the workflow — it only surfaces a warning
# annotation on the commit/PR so maintainers know a rebuild is needed.
#
# Triggers:
# - push to main or feature/* (paths-filtered to the tracked files)
# - pull_request targeting main (paths-filtered)
# - manual workflow_dispatch
#
# Exit codes from check_appimage_freshness.py:
# 0 = fresh (no rebuild needed)
# 1 = stale (rebuild needed — surfaces warning annotation)
# 2 = no_build (no previous .last_build_commit — informational only)
# 3 = error (config problem — surfaces error annotation, but still
# doesn't fail the job)
# ══════════════════════════════════════════════════════════════════
on:
push:
branches:
- main
- 'feature/**'
- 'feat/**'
- 'fix/**'
paths:
# Only run when the tracked surface changes (or the script itself)
- 'packages/scanner_fixer/src/scanner_fixer/deskew.py'
- 'packages/scanner_fixer/src/scanner_fixer/crop.py'
- 'packages/scanner_fixer/src/scanner_fixer/normalize.py'
- 'packages/scanner_fixer/src/scanner_fixer/dedup.py'
- 'packages/desktop/medical_doc_gui_final.py'
- 'packages/desktop/build_appimage.sh'
- 'packages/desktop/.last_build_commit'
- 'scripts/check_appimage_freshness.py'
- '.github/workflows/appimage-freshness.yml'
pull_request:
branches:
- main
paths:
- 'packages/scanner_fixer/src/scanner_fixer/deskew.py'
- 'packages/scanner_fixer/src/scanner_fixer/crop.py'
- 'packages/scanner_fixer/src/scanner_fixer/normalize.py'
- 'packages/scanner_fixer/src/scanner_fixer/dedup.py'
- 'packages/desktop/medical_doc_gui_final.py'
- 'packages/desktop/build_appimage.sh'
- 'scripts/check_appimage_freshness.py'
- '.github/workflows/appimage-freshness.yml'
workflow_dispatch:
env:
PYTHON_VERSION: "3.11"
jobs:
freshness-check:
name: Check AppImage Freshness (warning-only)
runs-on: ubuntu-22.04
timeout-minutes: 5
# Always allow this job to complete — even if some upstream step
# sets a failure, we want the warning annotation, not a red X.
continue-on-error: true
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # full history so git log can find tracked-file commits
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v7
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Verify git + tracked files
id: sanity
run: |
set -e
echo "git version: $(git --version)"
echo "HEAD: $(git rev-parse HEAD)"
echo ""
echo "Tracked files presence:"
for f in \
packages/scanner_fixer/src/scanner_fixer/deskew.py \
packages/scanner_fixer/src/scanner_fixer/crop.py \
packages/scanner_fixer/src/scanner_fixer/normalize.py \
packages/scanner_fixer/src/scanner_fixer/dedup.py \
packages/desktop/medical_doc_gui_final.py; do
if [ -f "$f" ]; then
echo " ✓ $f"
else
echo " ✗ $f MISSING"
exit 3
fi
done
- name: Run freshness check
id: check
# Capture exit code without failing the step
continue-on-error: true
run: |
set +e
python3 scripts/check_appimage_freshness.py --json > /tmp/freshness.json 2>&1
EXIT_CODE=$?
echo "exit_code=$EXIT_CODE" >> "$GITHUB_OUTPUT"
echo "── Freshness check output (exit $EXIT_CODE) ──"
cat /tmp/freshness.json
echo ""
exit 0 # never fail this step
- name: Annotate result
if: always()
env:
EXIT_CODE: ${{ steps.check.outputs.exit_code }}
run: |
set -e
# Parse JSON output (jq is pre-installed on ubuntu-22.04 runners)
STATUS=$(jq -r '.status' /tmp/freshness.json 2>/dev/null || echo "unknown")
MESSAGE=$(jq -r '.message' /tmp/freshness.json 2>/dev/null || echo "(no message)")
HINT=$(jq -r '.hint // ""' /tmp/freshness.json 2>/dev/null || echo "")
LAST_BUILD=$(jq -r '.last_build_commit_short // "(none)"' /tmp/freshness.json 2>/dev/null)
LATEST=$(jq -r '.latest_tracked_commit_short // "(none)"' /tmp/freshness.json 2>/dev/null)
echo "## AppImage Freshness: ${STATUS^^}" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "| Field | Value |" >> "$GITHUB_STEP_SUMMARY"
echo "|---|---|" >> "$GITHUB_STEP_SUMMARY"
echo "| Status | \`${STATUS}\` |" >> "$GITHUB_STEP_SUMMARY"
echo "| Last build commit | \`${LAST_BUILD}\` |" >> "$GITHUB_STEP_SUMMARY"
echo "| Latest tracked commit | \`${LATEST}\` |" >> "$GITHUB_STEP_SUMMARY"
echo "| Message | ${MESSAGE} |" >> "$GITHUB_STEP_SUMMARY"
if [ -n "$HINT" ]; then
echo "| Hint | ${HINT} |" >> "$GITHUB_STEP_SUMMARY"
fi
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "Exit code: \`${EXIT_CODE}\` (0=fresh, 1=stale, 2=no build, 3=error)" >> "$GITHUB_STEP_SUMMARY"
# Emit a GitHub Actions annotation visible on the commit/PR.
# warning = yellow ⚠ ; error = red ✗ ; notice = blue ℹ
case "$STATUS" in
fresh)
echo "::notice title=AppImage Freshness::${MESSAGE}"
;;
stale)
echo "::warning title=AppImage is stale (rebuild needed)::${MESSAGE} ${HINT}"
;;
no_build)
echo "::notice title=AppImage Freshness::${MESSAGE} ${HINT}"
;;
error)
echo "::warning title=AppImage Freshness check error::${MESSAGE}"
;;
*)
echo "::notice title=AppImage Freshness::Unknown status: ${STATUS}"
;;
esac
- name: Final result
if: always()
env:
EXIT_CODE: ${{ steps.check.outputs.exit_code }}
run: |
echo "Freshness check completed with exit code: ${EXIT_CODE}"
# Per workflow policy: NEVER fail the job.
# Even exit_code=3 (config error) is surfaced as a warning,
# not a failure — the AppImage build job (appimage-build.yml)
# is the source of truth for hard failures.
exit 0