Skip to content

Commit 0db221f

Browse files
authored
Merge pull request #128 from Perlmint/feature/check_generated_files
2 parents 58dddc3 + d915413 commit 0db221f

File tree

2 files changed

+61
-3
lines changed

2 files changed

+61
-3
lines changed

.github/workflows/main.yml

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,66 @@ jobs:
1616
with:
1717
deno-version: 2.4.3
1818
cache: true
19-
- run: npx @dotenvx/dotenvx run -f .env.ci -- deno task -r codegen
20-
- run: npx @dotenvx/dotenvx run -f .env.ci -- deno task test
21-
- run: deno task check
19+
- uses: pnpm/action-setup@v4
20+
with:
21+
package_json_file: web-next/package.json
22+
- name: Run codegen
23+
run: npx @dotenvx/dotenvx run -f .env.ci -- deno task -r codegen
24+
- name: Run tests
25+
if: always()
26+
run: npx @dotenvx/dotenvx run -f .env.ci -- deno task test
27+
- name: Run checks
28+
if: always()
29+
run: deno task check
30+
- name: Check for untranslated messages
31+
if: always()
32+
run: |
33+
cd web-next/src/locales
34+
has_untranslated=false
35+
for file in */messages.po; do
36+
echo "Checking $file..."
37+
while IFS= read -r line; do
38+
if [ -n "$line" ]; then
39+
line_num=$(echo "$line" | cut -d: -f1)
40+
msgid=$(echo "$line" | cut -d: -f2-)
41+
echo "::error file=web-next/src/locales/$file,line=$line_num::Untranslated message: $msgid"
42+
has_untranslated=true
43+
fi
44+
done < <(awk '/^msgid/ && !/^msgid ""$/ { msgid = $0; getline; while (/^"/) getline; if (/^msgstr ""$/) print NR ": " msgid }' "$file")
45+
46+
if [ "$has_untranslated" = false ]; then
47+
echo "✅ All messages translated in $file"
48+
fi
49+
done
50+
if [ "$has_untranslated" = true ]; then
51+
echo "::error::Found untranslated messages in .po files. Please translate all messages before merging."
52+
exit 1
53+
fi
54+
- name: Extract web-next translations
55+
if: always()
56+
run: cd web-next && deno task extract
57+
- name: Check for uncommitted changes
58+
if: always()
59+
run: |
60+
if ! git diff --exit-code --quiet; then
61+
echo "::error::Generated files have uncommitted changes. Please run the generators locally and commit the changes."
62+
63+
# Get list of changed files and create annotations
64+
git diff --name-only | while read -r file; do
65+
echo "::error file=$file::Generated file has uncommitted changes - please run generators locally and commit"
66+
67+
# Show which lines were changed
68+
git diff --unified=0 "$file" | grep '^@@' | while read -r hunk; do
69+
# Extract line numbers from hunk header like @@ -1,3 +1,4 @@
70+
line_info=$(echo "$hunk" | sed 's/.*+\([0-9]*\).*/\1/')
71+
if [ -n "$line_info" ]; then
72+
echo "::error file=$file,line=$line_info::Generated content differs from committed version"
73+
fi
74+
done
75+
done
76+
77+
exit 1
78+
fi
2279
2380
image:
2481
needs: [test]

deno.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)