Skip to content

Commit e26a368

Browse files
Fix release i18n guard and recovery path
1 parent d3318bd commit e26a368

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

.github/workflows/release-on-main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
shell: bash
3232
run: |
3333
set -euo pipefail
34+
MANUAL_DISPATCH='${{ github.event_name == 'workflow_dispatch' && '1' || '0' }}'
3435
BEFORE_SHA='${{ github.event.before }}'
3536
AFTER_SHA='${{ github.sha }}'
3637
RANGE="${BEFORE_SHA}..${AFTER_SHA}"
@@ -48,9 +49,13 @@ jobs:
4849
;;
4950
esac
5051
done
52+
if [[ "${MANUAL_DISPATCH}" == '1' ]]; then
53+
should_publish=1
54+
fi
5155
5256
{
5357
echo "range=${RANGE}"
58+
echo "manual_dispatch=${MANUAL_DISPATCH}"
5459
echo "should_publish=${should_publish}"
5560
} >> "${GITHUB_OUTPUT}"
5661

scripts/lang_usage_guard.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,22 @@ for (const fullPath of sourceFiles.sort()) {
100100
}
101101
}
102102
103-
const jqueryI18nRegex = /\$\.i18n\(\s*['"]([^'"]+)['"]/g;
104-
while ((match = jqueryI18nRegex.exec(source)) !== null) {
103+
const i18nCallRegexes = [
104+
/\$\.i18n\(\s*['"]([^'"]+)['"]/g,
105+
/\bjq\.i18n\(\s*['"]([^'"]+)['"]/g
106+
];
107+
for (const i18nCallRegex of i18nCallRegexes) {
108+
while ((match = i18nCallRegex.exec(source)) !== null) {
109+
const key = match[1].trim();
110+
if (!key) continue;
111+
const line = lineNumberAt(source, match.index);
112+
if (!referencedKeys.has(key)) referencedKeys.set(key, []);
113+
referencedKeys.get(key).push(`${relPath}:${line}`);
114+
}
115+
}
116+
117+
const i18nWrapperRegex = /\b(?:i18nLabel|i18nText)\(\s*['"]([^'"]+)['"]/g;
118+
while ((match = i18nWrapperRegex.exec(source)) !== null) {
105119
const key = match[1].trim();
106120
if (!key) continue;
107121
const line = lineNumberAt(source, match.index);

tests/versioning-guard.test.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,10 @@ test('validation workflows delegate to the shared ci suite with dev coverage, fa
435435

436436
test('release-on-main validates remote raw publish artifacts before publishing releases', () => {
437437
assert.match(releaseOnMainWorkflow, /Detect release artifact changes/);
438+
assert.match(releaseOnMainWorkflow, /MANUAL_DISPATCH='.*workflow_dispatch.*'/);
438439
assert.match(releaseOnMainWorkflow, /should_publish/);
440+
assert.match(releaseOnMainWorkflow, /manual_dispatch=\$\{MANUAL_DISPATCH\}/);
441+
assert.match(releaseOnMainWorkflow, /if \[\[ "\$\{MANUAL_DISPATCH\}" == '1' \]\]; then/);
439442
assert.match(releaseOnMainWorkflow, /Skip release publish for non-release main pushes/);
440443
assert.match(releaseOnMainWorkflow, /Validate remote raw publish artifacts/);
441444
assert.match(releaseOnMainWorkflow, /FVPLUS_REMOTE_PUBLISH_ATTEMPTS:\s*'30'/);
@@ -585,6 +588,11 @@ test('standards guard scripts exist with expected core checks', () => {
585588
assert.match(i18nGuard, /Missing base locale file/);
586589
assert.match(langUsageGuard, /Language usage guard passed/);
587590
assert.match(langUsageGuard, /data-i18n/);
591+
assert.match(langUsageGuard, /i18nCallRegexes/);
592+
assert.match(langUsageGuard, /\$\\\.i18n/);
593+
assert.match(langUsageGuard, /jq\\\.i18n/);
594+
assert.match(langUsageGuard, /i18nWrapperRegex/);
595+
assert.match(langUsageGuard, /i18nLabel\|i18nText/);
588596
assert.match(themeScopeGuard, /Theme scope guard passed/);
589597
assert.match(themeScopeGuard, /#fv-settings-root/);
590598
assert.match(themeRuntimeGuard, /Theme runtime guard passed/);

0 commit comments

Comments
 (0)