Skip to content

Commit f674b94

Browse files
committed
ci: add GitHub Actions workflow (lint + integration test)
1 parent ceda377 commit f674b94

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

.github/workflows/ci.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
lint:
11+
name: Lint (ruff)
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Python 3.11
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.11"
20+
21+
- name: Install ruff
22+
run: pip install ruff
23+
24+
- name: Run ruff check
25+
run: ruff check export_script.py import_script.py make_demo_data.py
26+
27+
integration-test:
28+
name: Integration Test (export → validate → import → verify)
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Set up Python 3.11
34+
uses: actions/setup-python@v5
35+
with:
36+
python-version: "3.11"
37+
38+
- name: Generate demo game data
39+
run: python make_demo_data.py
40+
41+
- name: Export game text
42+
run: python export_script.py Game -o exported_ci
43+
44+
- name: Validate exported JSON structure
45+
run: python -c "
46+
import json, sys
47+
with open('exported_ci/script.json', encoding='utf-8') as f:
48+
data = json.load(f)
49+
assert 'info' in data, 'Missing info section'
50+
assert 'strings' in data, 'Missing strings section'
51+
count = data['info']['string_count']
52+
actual = len(data['strings'])
53+
assert count == actual, f'string_count mismatch: {count} != {actual}'
54+
print(f'Export OK: {actual} strings')
55+
"
56+
57+
- name: Fill translated field with original text (simulate translation)
58+
run: python -c "
59+
import json
60+
with open('exported_ci/script.json', encoding='utf-8') as f:
61+
data = json.load(f)
62+
for entry in data['strings']:
63+
if not entry.get('translated'):
64+
entry['translated'] = entry['original']
65+
with open('exported_ci/script.json', 'w', encoding='utf-8') as f:
66+
json.dump(data, f, ensure_ascii=False, indent=2)
67+
print('Filled translated fields')
68+
"
69+
70+
- name: Validate translation progress
71+
run: python import_script.py validate exported_ci/script.json
72+
73+
- name: Import translations
74+
run: python import_script.py import Game exported_ci/script.json -o Game_ci_out
75+
76+
- name: Verify output structure
77+
run: python import_script.py verify Game Game_ci_out
78+
79+
- name: Upload exported script as artifact
80+
if: always()
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: exported-script
84+
path: exported_ci/script.json
85+
retention-days: 7

0 commit comments

Comments
 (0)