Skip to content
This repository was archived by the owner on May 12, 2026. It is now read-only.

Add script that publishes artifacts from local #4

Add script that publishes artifacts from local

Add script that publishes artifacts from local #4

name: Build and Test
on:
push:
branches:
- main
- master
- develop
- dev
- "release/**"
- "hotfix/**"
- "feature/**"
pull_request:
branches:
- main
- master
- develop
- dev
workflow_dispatch:
workflow_call:
secrets:
ENV_JSON_PASSPHRASE:
required: false
ENV_JSON_ENC_KEY:
required: false
ENV_JSON_ENC_IV:
required: false
jobs:
build-and-test:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
cache: "gradle"
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Install Android SDK packages
run: |
yes | sdkmanager --licenses >/dev/null
yes | sdkmanager "platform-tools" "platforms;android-34" "build-tools;34.0.0"
- name: Decrypt env.json for integration tests
id: decrypt_env
if: hashFiles('env.json.enc') != ''
env:
ENV_JSON_PASSPHRASE: ${{ secrets.ENV_JSON_PASSPHRASE }}
ENV_JSON_ENC_KEY: ${{ secrets.ENV_JSON_ENC_KEY }}
ENV_JSON_ENC_IV: ${{ secrets.ENV_JSON_ENC_IV }}
run: |
echo "decrypted=false" >> "$GITHUB_OUTPUT"
if [ -z "${ENV_JSON_PASSPHRASE:-}" ] && { [ -z "${ENV_JSON_ENC_KEY:-}" ] || [ -z "${ENV_JSON_ENC_IV:-}" ]; }; then
echo "No env.json decryption secret set. Integration tests will be skipped."
exit 0
fi
if ./.ci/decrypt-env.sh; then
echo "decrypted=true" >> "$GITHUB_OUTPUT"
else
echo "Env decryption failed. Integration tests will be skipped."
rm -f env.json
fi
- name: Build + run JVM tests
run: |
./gradlew :pythia:assemble :pythia:test --no-daemon --stacktrace
- name: Build Android modules
run: |
./gradlew :pythia-android:assembleRelease :pythia-android-tests:assembleDebug --no-daemon --stacktrace
- name: Run Android instrumentation tests (optional)
if: steps.decrypt_env.outputs.decrypted == 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
arch: x86_64
profile: pixel_6
disable-animations: true
# Reduce emulator flakiness in CI runners.
# Provide explicit DNS to reduce "UnknownHostException" flakiness in emulators.
disable-multidisplay: true
emulator-options: -no-window -no-audio -no-boot-anim -gpu swiftshader_indirect -no-snapshot-load -no-snapshot-save -dns-server 8.8.8.8 -partition-size 4096
script: |
# Some runners/emulators are flaky around adb install; make the environment more reliable.
adb wait-for-device
adb shell getprop sys.boot_completed || true
adb shell settings put global verifier_verify_adb_installs 0 || true
adb shell settings put global package_verifier_enable 0 || true
./gradlew :pythia-android-tests:connectedCheck --no-daemon --stacktrace --info
- name: Connected Android tests skipped (missing env.json)
if: steps.decrypt_env.outputs.decrypted != 'true'
run: |
echo "Skipping connected Android tests because env.json could not be decrypted."
# Emulator shutdown is occasionally flaky (adb can exit non-zero during teardown).
# Ensure cleanup doesn't fail the whole job.
- name: ADB cleanup (best-effort)
if: always()
run: |
adb devices || true
adb kill-server || true
- name: Cleanup decrypted env.json
if: always()
run: rm -f env.json
- name: Upload test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-reports
path: |
**/build/reports/tests/**/*
**/build/test-results/**/*
**/build/reports/androidTests/**/*
**/build/outputs/androidTest-results/**/*
if-no-files-found: warn