Skip to content

Weblate Translation Build Check #3

Weblate Translation Build Check

Weblate Translation Build Check #3

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: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## βœ… Translation Build successful!
The translation PR was built and tested successfully.
**Next step:** Perform squash-merge.
> Don't forget to update \`locales_config.xml\` if a new language was added.`
})