mirror of
https://github.com/foxhole-team/foxhole-guard.git
synced 2026-10-21 10:45:41 +02:00
283 lines
11 KiB
YAML
283 lines
11 KiB
YAML
name: android
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- dev
|
|
pull_request:
|
|
paths:
|
|
- ".github/**"
|
|
- "app/**"
|
|
- "config/**"
|
|
- "core/**"
|
|
- "macrobenchmark/**"
|
|
- "gradlew"
|
|
- "gradlew.bat"
|
|
- "gradle/**"
|
|
- "scripts/**"
|
|
- "metadata/**"
|
|
- "third_party/**"
|
|
- "build.gradle.kts"
|
|
- "settings.gradle.kts"
|
|
- "gradle.properties"
|
|
workflow_dispatch:
|
|
inputs:
|
|
foxcore_smoke_only:
|
|
description: "Only build and verify the pinned FoxCore JNI artifact"
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
security_scan_only:
|
|
description: "Only run secret and dependency vulnerability scans"
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: android-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
verify:
|
|
name: build/unit/security verified
|
|
runs-on: ubuntu-24.04
|
|
# A cold public checkout compiles FoxCore, i2pd and the Tor transports from source, so the timeout must clear GitHub's uncached network.
|
|
timeout-minutes: 90
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
|
|
with:
|
|
submodules: recursive
|
|
persist-credentials: false
|
|
|
|
- name: setup Android and FoxHole Core build
|
|
uses: ./.github/actions/setup-foxcore
|
|
with:
|
|
core-repository: ${{ vars.FOXCORE_REPO || 'foxhole-team/foxhole-core' }}
|
|
|
|
- name: pinned FoxCore native smoke
|
|
if: github.event_name == 'workflow_dispatch' && inputs.foxcore_smoke_only
|
|
run: ./gradlew --no-daemon --console=plain --stacktrace :app:prepareFoxCoreNative
|
|
|
|
- name: release provenance regression tests
|
|
run: python3 -m unittest discover -s scripts/tests -p "test_*.py"
|
|
|
|
# Run the cheap security gates before the cold native build so a policy failure is fast.
|
|
- name: secret scan
|
|
if: github.event_name != 'workflow_dispatch' || inputs.security_scan_only || !inputs.foxcore_smoke_only
|
|
run: scripts/run-gitleaks-scan.sh
|
|
|
|
- name: mandatory dependency vulnerability scan
|
|
if: github.event_name != 'workflow_dispatch' || inputs.security_scan_only || !inputs.foxcore_smoke_only
|
|
run: scripts/run-osv-source-scan.sh
|
|
|
|
- name: verify wrapper
|
|
if: github.event_name != 'workflow_dispatch' || (!inputs.foxcore_smoke_only && !inputs.security_scan_only)
|
|
run: ./gradlew --no-daemon --console=plain --version
|
|
|
|
- name: static analysis, lint, unit tests, and coverage
|
|
if: github.event_name != 'workflow_dispatch' || (!inputs.foxcore_smoke_only && !inputs.security_scan_only)
|
|
run: ./gradlew --no-daemon --console=plain --stacktrace :app:detekt verifyDetektBaseline :app:lintDebug :app:lintRelease :app:lintVitalRelease :app:testDebugUnitTest jacocoDebugUnitTestReport jacocoDebugUnitTestCoverageVerification verifyReleaseBuildConfigDefaults
|
|
|
|
- name: build debug APK
|
|
if: github.event_name != 'workflow_dispatch' || (!inputs.foxcore_smoke_only && !inputs.security_scan_only)
|
|
run: ./gradlew --no-daemon --console=plain --stacktrace :app:assembleDebug
|
|
|
|
device-build:
|
|
name: build Android device test APKs once
|
|
needs: verify
|
|
if: github.event_name != 'workflow_dispatch' || (!inputs.foxcore_smoke_only && !inputs.security_scan_only)
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 90
|
|
env:
|
|
CARGO_BUILD_JOBS: "2"
|
|
I2PD_BUILD_JOBS: "2"
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
|
|
with:
|
|
submodules: recursive
|
|
persist-credentials: false
|
|
- name: setup Android and FoxHole Core build
|
|
uses: ./.github/actions/setup-foxcore
|
|
with:
|
|
core-repository: ${{ vars.FOXCORE_REPO || 'foxhole-team/foxhole-core' }}
|
|
android-abis: x86_64
|
|
- name: build the emulator APK from source
|
|
run: |
|
|
./gradlew --no-daemon --max-workers=2 --console=plain -Pfoxhole.abis=x86_64 \
|
|
:app:assembleDebug :app:assembleDebugAndroidTest :core:runtime:assembleDebugAndroidTest
|
|
- name: store exact device test APKs
|
|
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
|
with:
|
|
name: device-test-apks-${{ github.sha }}
|
|
path: |
|
|
app/build/outputs/apk/debug/*.apk
|
|
app/build/outputs/apk/androidTest/debug/*.apk
|
|
core/runtime/build/outputs/apk/androidTest/debug/*.apk
|
|
retention-days: 3
|
|
if-no-files-found: error
|
|
|
|
- name: retain native build diagnostics
|
|
if: failure()
|
|
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
|
with:
|
|
name: device-build-diagnostics-${{ github.sha }}
|
|
path: app/build/reports/
|
|
retention-days: 3
|
|
|
|
device:
|
|
name: Android device boundaries (API ${{ matrix.api }})
|
|
needs: device-build
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 20
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
# The API 37 image fails APK installation before instrumentation starts.
|
|
# API 26 and 34 retain device coverage until that image can run the suites.
|
|
api: ["26", "34"]
|
|
steps:
|
|
- name: checkout device runner
|
|
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
|
|
with:
|
|
persist-credentials: false
|
|
- name: download the single verified device build
|
|
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
|
|
with:
|
|
name: device-test-apks-${{ github.sha }}
|
|
path: device-apks
|
|
- name: enable emulator acceleration
|
|
run: |
|
|
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
|
|
sudo udevadm control --reload-rules
|
|
sudo udevadm trigger --name-match=kvm
|
|
- name: execute device regression tests
|
|
uses: reactivecircus/android-emulator-runner@5d6e86df22ab11632167a1a6b0c9ab0dc3469586 # v2.36.0
|
|
with:
|
|
api-level: ${{ matrix.api }}
|
|
target: google_apis
|
|
arch: x86_64
|
|
cores: 2
|
|
ram-size: 2048M
|
|
disk-size: 6G
|
|
disable-animations: true
|
|
emulator-options: -no-window -no-audio -no-boot-anim -no-snapshot -gpu swiftshader_indirect
|
|
script: bash scripts/run-packaged-device-tests.sh device-apks
|
|
- name: retain device test reports
|
|
if: always()
|
|
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
|
with:
|
|
name: android-device-api-${{ matrix.api }}-${{ github.sha }}
|
|
path: build/reports/device/
|
|
if-no-files-found: warn
|
|
retention-days: 7
|
|
|
|
release-candidate:
|
|
name: signed release candidate
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
|
|
needs: [verify, device]
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 90
|
|
steps:
|
|
- name: checkout verified dev commit
|
|
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
|
|
with:
|
|
submodules: recursive
|
|
persist-credentials: false
|
|
|
|
- name: setup Android and FoxHole Core build
|
|
uses: ./.github/actions/setup-foxcore
|
|
with:
|
|
core-repository: ${{ vars.FOXCORE_REPO || 'foxhole-team/foxhole-core' }}
|
|
|
|
- name: prepare release signing inputs
|
|
shell: bash
|
|
env:
|
|
FOXHOLE_RELEASE_STORE_FILE_B64: ${{ secrets.FOXHOLE_RELEASE_STORE_FILE_B64 }}
|
|
FOXHOLE_RELEASE_STORE_PASSWORD: ${{ secrets.FOXHOLE_RELEASE_STORE_PASSWORD }}
|
|
FOXHOLE_RELEASE_KEY_ALIAS: ${{ secrets.FOXHOLE_RELEASE_KEY_ALIAS }}
|
|
FOXHOLE_RELEASE_KEY_PASSWORD: ${{ secrets.FOXHOLE_RELEASE_KEY_PASSWORD }}
|
|
FOXHOLE_RELEASE_STORE_TYPE: ${{ secrets.FOXHOLE_RELEASE_STORE_TYPE }}
|
|
run: |
|
|
set -euo pipefail
|
|
missing=()
|
|
for secret_name in \
|
|
FOXHOLE_RELEASE_STORE_FILE_B64 \
|
|
FOXHOLE_RELEASE_STORE_PASSWORD \
|
|
FOXHOLE_RELEASE_KEY_ALIAS \
|
|
FOXHOLE_RELEASE_KEY_PASSWORD
|
|
do
|
|
if [[ -z "${!secret_name:-}" ]]; then
|
|
missing+=("$secret_name")
|
|
fi
|
|
done
|
|
if (( ${#missing[@]} > 0 )); then
|
|
printf 'Release signing secrets are required. Missing: %s\n' "${missing[*]}" >&2
|
|
exit 1
|
|
fi
|
|
keystore_path="$RUNNER_TEMP/foxhole-release.p12"
|
|
if ! printf '%s' "$FOXHOLE_RELEASE_STORE_FILE_B64" | base64 --decode > "$keystore_path"; then
|
|
echo "FOXHOLE_RELEASE_STORE_FILE_B64 is not valid base64" >&2
|
|
exit 1
|
|
fi
|
|
chmod 600 "$keystore_path"
|
|
{
|
|
echo "FOXHOLE_RELEASE_STORE_FILE=$keystore_path"
|
|
echo "FOXHOLE_RELEASE_STORE_PASSWORD=$FOXHOLE_RELEASE_STORE_PASSWORD"
|
|
echo "FOXHOLE_RELEASE_KEY_ALIAS=$FOXHOLE_RELEASE_KEY_ALIAS"
|
|
echo "FOXHOLE_RELEASE_KEY_PASSWORD=$FOXHOLE_RELEASE_KEY_PASSWORD"
|
|
echo "FOXHOLE_RELEASE_STORE_TYPE=${FOXHOLE_RELEASE_STORE_TYPE:-PKCS12}"
|
|
} >> "$GITHUB_ENV"
|
|
|
|
- name: resolve published versionCode floor
|
|
id: published
|
|
shell: bash
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
set -euo pipefail
|
|
version_code="$(scripts/package-release-candidate.sh published-code "$GITHUB_REPOSITORY")"
|
|
echo "version_code=$version_code" >> "$GITHUB_OUTPUT"
|
|
|
|
# This signed candidate approves the source tree before main builds the tagged release.
|
|
- name: build and verify signed GitHub and F-Droid candidates
|
|
run: scripts/build-release-variants.sh "${{ steps.published.outputs.version_code }}"
|
|
|
|
- name: package immutable candidate
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
candidate_dir="$RUNNER_TEMP/foxhole-release-candidate"
|
|
source_tree="$(git rev-parse 'HEAD^{tree}')"
|
|
FOXHOLE_SBOM_PATH=build/reports/cyclonedx/bom.json \
|
|
scripts/package-release-candidate.sh \
|
|
prepare \
|
|
"$candidate_dir" \
|
|
"$GITHUB_SHA" \
|
|
"$source_tree"
|
|
|
|
- name: upload immutable candidate
|
|
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
|
with:
|
|
name: foxhole-app-${{ github.sha }}
|
|
path: ${{ runner.temp }}/foxhole-release-candidate/*
|
|
if-no-files-found: error
|
|
retention-days: 3
|
|
compression-level: 0
|
|
|
|
# Mapping and native symbols stay authenticated Actions artifacts, never attached to the public release.
|
|
- name: retain private diagnostics
|
|
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
|
with:
|
|
name: foxhole-private-diagnostics-${{ github.sha }}
|
|
path: |
|
|
build/release-variants/*/mapping.txt
|
|
app/build/outputs/mapping/publicRelease/mapping.txt
|
|
app/build/outputs/native-debug-symbols/publicRelease/publicRelease-native-symbols.zip
|
|
if-no-files-found: error
|
|
retention-days: 3
|