-
Notifications
You must be signed in to change notification settings - Fork 9
120 lines (112 loc) Β· 4.04 KB
/
weblate-build-check.yml
File metadata and controls
120 lines (112 loc) Β· 4.04 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
name: Weblate Translation Build Check
on:
pull_request_review:
types: [submitted]
pull_request:
types: [ready_for_review]
branches: [main]
workflow_dispatch: # Allows owner to manually trigger (owners cannot approve their own PRs)
inputs:
pr_number:
description: 'PR number to post result comment on'
required: false
jobs:
build:
name: Build & Test Translation PR
runs-on: ubuntu-latest
# Only for Weblate PRs, only after approval, ready-for-review, or manual dispatch
if: >
github.event_name == 'workflow_dispatch' ||
(
github.event.pull_request.head.ref == 'weblate-translations' &&
(
(github.event_name == 'pull_request_review' && github.event.review.state == 'approved') ||
(github.event_name == 'pull_request' && github.event.action == 'ready_for_review')
)
)
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: weblate-translations
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Gradle Cache
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Verify strings.xml validity
run: |
echo "π Checking XML validity of all translation files..."
python3 - <<'EOF'
import xml.etree.ElementTree as ET
import glob, sys
files = glob.glob('android/app/src/main/res/values-*/strings.xml')
errors = 0
for f in sorted(files):
try:
ET.parse(f)
print(f' β
{f}')
except ET.ParseError as e:
print(f' β {f} β Invalid XML: {e}')
errors += 1
if errors > 0:
print(f'β {errors} file(s) have XML errors')
sys.exit(1)
print('β
All translation files are valid XML')
EOF
- name: Build Debug APK
run: |
cd android
./gradlew assembleStandardDebug assembleFdroidDebug --no-daemon --stacktrace
- name: Run Unit Tests
run: |
cd android
./gradlew test --no-daemon --stacktrace
- name: Verify build result
run: |
if [ -f "android/app/build/outputs/apk/standard/debug/app-standard-debug.apk" ]; then
echo "β
Standard Debug APK built successfully"
else
echo "β Standard Debug APK build failed"
exit 1
fi
if [ -f "android/app/build/outputs/apk/fdroid/debug/app-fdroid-debug.apk" ]; then
echo "β
F-Droid Debug APK built successfully"
else
echo "β F-Droid Debug APK build failed"
exit 1
fi
- name: Post PR comment
uses: actions/github-script@v7
if: success()
with:
script: |
// workflow_dispatch passes pr_number as input; PR events use context.issue.number
const prNumber = context.payload.inputs?.pr_number
? parseInt(context.payload.inputs.pr_number)
: context.issue.number;
if (!prNumber) {
core.warning('No PR number available β skipping comment');
return;
}
github.rest.issues.createComment({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: '## \u2705 Translation Build successful!\n\n' +
'The translation PR was built and tested successfully.\n\n' +
'**Next step:** Perform squash-merge.\n\n' +
'> Don\'t forget to update `locales_config.xml` if a new language was added.'
})