Skip to content

refactor(ui): take motion from the theme's MotionScheme #474

refactor(ui): take motion from the theme's MotionScheme

refactor(ui): take motion from the theme's MotionScheme #474

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
schedule:
# Nightly, for the minimum SDK device and the compact phone, which only nightly and manual runs cover.
- cron: '17 3 * * *'
workflow_dispatch:
inputs:
record-screenshots:
description: Record the screenshot goldens on Linux and commit them to this branch
type: boolean
default: false
permissions:
contents: read
concurrency:
# The event is part of the key so a nightly run and a push to main do not cancel each other. Only a pull request's
# newer push cancels its older run; every push to main finishes its full device run, however quickly merges follow.
group: ci-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
android:
# JVM tests: plain unit tests, Robolectric UI tests and the Roborazzi screenshot goldens, plus the builds and checks.
name: Build, JVM tests and lint
if: github.repository != 'thisislvca/mela-archive' && !inputs.record-screenshots
runs-on: ubuntu-24.04
timeout-minutes: 30
outputs:
# true when the only problem is golden images; a same-repository pull request then gets them updated
# (update-screenshots). The job itself still fails, as it always has, so nothing else can hide behind this.
update-goldens: ${{ steps.classify.outputs.update-goldens }}
env:
ALBA_SENTRY_DSN: ''
ALBA_SENTRY_PROPERTIES: /tmp/alba-ci-no-sentry.properties
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: '.nvmrc'
package-manager-cache: false
- uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: temurin
java-version: '21'
- uses: android-actions/setup-android@be39fa834029ff78f1a44aa3bb0819b8fc2bd8fd # v4.0.4
with:
packages: 'platform-tools platforms;android-37.2 build-tools;37.0.0'
log-accepted-android-sdk-licenses: false
- uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
- name: Check notices and scripts
run: |
cmp THIRD_PARTY_NOTICES.md app/src/main/res/raw/third_party_notices.txt
node --test 'scripts/**/*.test.mjs'
bash -n scripts/*.sh
# Goldens are verified when they exist. Without any (the first run after adding screenshot tests), this run
# records them for review and fails until they are committed.
- name: Choose the screenshot mode
id: screenshots
run: |
if find app/src/test/screenshots -name '*.png' 2>/dev/null | grep -q .; then
echo "mode=verify" >> "$GITHUB_OUTPUT"
else
echo "mode=record" >> "$GITHUB_OUTPUT"
fi
- name: Build
id: build
run: >-
./gradlew :app:assembleDebug :app:assembleDebugAndroidTest :engine:assembleDebugAndroidTest
:protocol-icloud-web:assembleDebugAndroidTest :app:assembleRelease :benchmark:assembleBenchmark
:benchmark:assembleProfile --no-daemon --console=plain
# --continue runs every module's tests even when one fails, so "only screenshots failed" is judged on all of them.
- name: JVM tests
id: tests
if: ${{ !cancelled() }}
run: >-
./gradlew testDebugUnitTest -Proborazzi.test.${{ steps.screenshots.outputs.mode }}=true
--continue --no-daemon --console=plain
- name: Lint and static analysis
id: lint
if: ${{ !cancelled() }}
run: ./gradlew lintDebug detekt ktlintCheck --no-daemon --console=plain
# From the JUnit XML and Roborazzi's results summary, not the logs: true only when every failed test is a
# screenshot difference (changed, or new without a golden), or when goldens are left over from removed tests, and
# the build and the static checks passed.
- name: Classify the failures
id: classify
if: ${{ !cancelled() }}
env:
BUILD_OUTCOME: ${{ steps.build.outcome }}
TESTS_OUTCOME: ${{ steps.tests.outcome }}
LINT_OUTCOME: ${{ steps.lint.outcome }}
MODE: ${{ steps.screenshots.outputs.mode }}
run: node scripts/screenshot_changes.mjs classify | tee -a "$GITHUB_STEP_SUMMARY"
- name: Summarize JVM tests
if: ${{ !cancelled() }}
run: >-
find . -path '*/build/test-results/testDebugUnitTest/*' -name 'TEST-*.xml' -print0
| xargs -0 node scripts/device_test_summary.mjs "JVM tests" >> "$GITHUB_STEP_SUMMARY"
- name: Upload screenshots
if: ${{ !cancelled() }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
# Verify mode: the new images and their differences from the goldens. Record mode: the new goldens.
name: screenshots
path: |
app/build/outputs/roborazzi/
app/src/test/screenshots/
if-no-files-found: ignore
retention-days: 14
- name: Upload JVM test reports
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: jvm-test-reports
path: |
**/build/reports/tests/
**/build/test-results/
retention-days: 7
- name: Require committed screenshot goldens
if: ${{ steps.screenshots.outputs.mode == 'record' }}
run: |
echo "::error::No screenshot goldens are committed. This run recorded them in the 'screenshots' artifact;"\
"commit them under app/src/test/screenshots, or run CI with 'record-screenshots' on this branch."
exit 1
update-screenshots:
# The usual way goldens change. When a pull request from a branch of this repository fails only because screenshots
# differ (see "Classify the failures" above), this job records every golden on Linux, commits the changed images to
# the PR branch as the repository's GitHub App, and comments on the PR which screens changed. The push starts a new
# run, which cancels this one (PR concurrency) and is the one that counts. A reviewer accepts the images by merging,
# after looking at them in Files changed. Never for forks, main, pushes or the nightly: those fail as always.
#
# The commit is pushed with a token from the App (secrets ALBA_BOT_APP_ID and ALBA_BOT_PRIVATE_KEY): a GITHUB_TOKEN
# push would start no workflows. GITHUB_TOKEN only comments, which is why this job alone has pull-requests: write.
name: Update screenshot goldens
needs: android
if: >-
${{ !cancelled() && needs.android.outputs.update-goldens == 'true' && github.event_name == 'pull_request'
&& github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-24.04
timeout-minutes: 25
permissions:
contents: read
pull-requests: write
outputs:
pushed: ${{ steps.push.outcome == 'success' }}
env:
ALBA_SENTRY_DSN: ''
ALBA_SENTRY_PROPERTIES: /tmp/alba-ci-no-sentry.properties
steps:
# Needs the scripts, so it comes after the checkout below; the secrets check still runs before the long recording.
# The merge of the PR into its base is what the JVM job verified. No credentials stay in the checkout.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 2
- name: Require the GitHub App secrets
env:
APP_ID: ${{ secrets.ALBA_BOT_APP_ID }}
PRIVATE_KEY: ${{ secrets.ALBA_BOT_PRIVATE_KEY }}
run: bash scripts/ci_goldens.sh require-secrets
# A PR whose head is already a bot golden update and still differs would loop: fail loudly instead.
- name: Check this run is current and cannot loop
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: bash scripts/ci_goldens.sh guard "$HEAD_SHA"
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: '.nvmrc'
package-manager-cache: false
- uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: temurin
java-version: '21'
- uses: android-actions/setup-android@be39fa834029ff78f1a44aa3bb0819b8fc2bd8fd # v4.0.4
with:
packages: 'platform-tools platforms;android-37.2 build-tools;37.0.0'
log-accepted-android-sdk-licenses: false
- uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
- name: Record goldens
id: record
uses: ./.github/actions/record-goldens
- name: Move the goldens onto the pull request head
run: bash scripts/ci_goldens.sh to-head
- name: Install ImageMagick for the pixel comparison
run: command -v identify >/dev/null || (sudo apt-get update -q && sudo apt-get install -y -q --no-install-recommends imagemagick)
# Re-encoded PNGs with the same pixels are not committed. Fails, like an unchanged recording, when no pixel changed.
- name: Drop goldens whose pixels did not change
run: bash scripts/ci/drop-identical-goldens.sh --require-change
- name: Commit and push the goldens
id: push
uses: ./.github/actions/push-goldens
with:
app-id: ${{ secrets.ALBA_BOT_APP_ID }}
private-key: ${{ secrets.ALBA_BOT_PRIVATE_KEY }}
branch: ${{ github.event.pull_request.head.ref }}
pr-number: ${{ github.event.pull_request.number }}
# Only reached if the push did not start a new run that cancelled this one.
- name: Report the failure on the pull request
if: ${{ failure() }}
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: bash scripts/ci_goldens.sh comment-failed "$PR_NUMBER"
record-screenshots:
# Manual fallback (forks, or a branch without a pull request): Actions > CI > Run workflow > pick the branch > tick
# "record-screenshots". Records every golden on Linux, where CI verifies them, and commits the result to that branch
# with the same steps as update-screenshots. Never on main: goldens reach main through review.
#
# The commit is pushed with the App's token (see update-screenshots). That push cannot loop back here: recording
# runs only on a manual workflow_dispatch, never on push or pull_request, and a dispatch made by any bot, the App
# included, is refused.
name: Record screenshot goldens
if: >-
github.repository != 'thisislvca/mela-archive' && github.event_name == 'workflow_dispatch'
&& inputs.record-screenshots && !endsWith(github.actor, '[bot]')
&& startsWith(github.ref, 'refs/heads/') && github.ref != 'refs/heads/main'
runs-on: ubuntu-24.04
timeout-minutes: 20
# The push uses the App's token, not GITHUB_TOKEN, which only needs to read.
permissions:
contents: read
env:
ALBA_SENTRY_DSN: ''
ALBA_SENTRY_PROPERTIES: /tmp/alba-ci-no-sentry.properties
steps:
# No credentials stay in the checkout: the App token is used only by the push.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# No fallback to GITHUB_TOKEN: its push would leave the branch without CI on the new goldens.
- name: Require the GitHub App secrets
env:
APP_ID: ${{ secrets.ALBA_BOT_APP_ID }}
PRIVATE_KEY: ${{ secrets.ALBA_BOT_PRIVATE_KEY }}
run: bash scripts/ci_goldens.sh require-secrets
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: '.nvmrc'
package-manager-cache: false
- uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: temurin
java-version: '21'
- uses: android-actions/setup-android@be39fa834029ff78f1a44aa3bb0819b8fc2bd8fd # v4.0.4
with:
packages: 'platform-tools platforms;android-37.2 build-tools;37.0.0'
log-accepted-android-sdk-licenses: false
- uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
- name: Record goldens
id: record
uses: ./.github/actions/record-goldens
- name: Install ImageMagick for the pixel comparison
if: steps.record.outputs.changed == 'true'
run: command -v identify >/dev/null || (sudo apt-get update -q && sudo apt-get install -y -q --no-install-recommends imagemagick)
- name: Drop goldens whose pixels did not change
id: drop
if: steps.record.outputs.changed == 'true'
run: bash scripts/ci/drop-identical-goldens.sh
- name: Commit and push the goldens
if: steps.record.outputs.changed == 'true' && steps.drop.outputs.remaining == 'true'
uses: ./.github/actions/push-goldens
with:
app-id: ${{ secrets.ALBA_BOT_APP_ID }}
private-key: ${{ secrets.ALBA_BOT_PRIVATE_KEY }}
branch: ${{ github.ref_name }}
instrumentation:
# Pull requests and pushes to main run every app, engine and protocol device test on the Pixel 9 at the target API
# level. The nightly schedule runs the @Smoke tests on the minimum SDK and a compact phone (main's pushes already
# cover the Pixel 9); manual runs do all three. Dropping devices from the matrix, rather than skipping a job, keeps
# the result "Android checks" requires meaningful.
name: ${{ matrix.title }}
if: github.repository != 'thisislvca/mela-archive' && !inputs.record-screenshots
runs-on: ubuntu-24.04
# The test orchestrator starts a fresh instrumentation for each test, which adds a few seconds per test.
timeout-minutes: 75
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(github.event_name == 'schedule' && '[{"device":"pixel9Api30","suite":"smoke","title":"Android 30 smoke device tests"},{"device":"compactApi36","suite":"smoke","title":"Compact phone smoke device tests"}]'
|| github.event_name == 'workflow_dispatch' && '[{"device":"pixel9Api36","suite":"all","title":"Android 36 device tests"},{"device":"pixel9Api30","suite":"smoke","title":"Android 30 smoke device tests"},{"device":"compactApi36","suite":"smoke","title":"Compact phone smoke device tests"}]'
|| '[{"device":"pixel9Api36","suite":"all","title":"Android 36 device tests"}]') }}
env:
ALBA_SENTRY_DSN: ''
ALBA_SENTRY_PROPERTIES: /tmp/alba-ci-no-sentry.properties
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: '.nvmrc'
package-manager-cache: false
- uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: temurin
java-version: '21'
- uses: android-actions/setup-android@be39fa834029ff78f1a44aa3bb0819b8fc2bd8fd # v4.0.4
with:
packages: 'platform-tools emulator platforms;android-37.2 build-tools;37.0.0'
log-accepted-android-sdk-licenses: false
- uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
- name: Enable KVM
run: sudo chmod 666 /dev/kvm
- name: Build test APKs before starting emulators
id: build-test-apks
run: >-
./gradlew :app:assembleDebug :app:assembleDebugAndroidTest
:engine:assembleDebugAndroidTest :protocol-icloud-web:assembleDebugAndroidTest
--max-workers=2 --no-parallel --console=plain
# Each module runs in its own step so a failure or hang is attributed to it. Later modules still run after an
# earlier one fails; any failed step fails the job. Each step retries its failed tests once and lists flaky tests
# in the job summary.
- name: Run app device tests
if: ${{ !cancelled() && steps.build-test-apks.outcome == 'success' }}
run: >-
bash scripts/ci_device_tests.sh app "${{ matrix.device }}" "${{ matrix.title }} (app)"
${{ matrix.suite == 'smoke' && '-Pandroid.testInstrumentationRunnerArguments.annotation=me.lvca.alba.app.testing.Smoke' || '' }}
# Engine and protocol device tests are few and exercise MediaStore, codecs and the Keystore; they all run.
- name: Run engine device tests
if: ${{ !cancelled() && steps.build-test-apks.outcome == 'success' }}
run: bash scripts/ci_device_tests.sh engine "${{ matrix.device }}" "${{ matrix.title }} (engine)"
- name: Run protocol-icloud-web device tests
if: ${{ !cancelled() && steps.build-test-apks.outcome == 'success' }}
run: bash scripts/ci_device_tests.sh protocol-icloud-web "${{ matrix.device }}" "${{ matrix.title }} (protocol-icloud-web)"
- name: Upload device test reports
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: android-device-tests-${{ matrix.device }}
path: |
**/build/reports/androidTests/
**/build/outputs/androidTest-results/
**/build/device-test-attempts/
**/build/intermediates/managed_device_android_test_additional_output/
retention-days: 7
checks:
name: Android checks
if: always() && github.repository != 'thisislvca/mela-archive' && !inputs.record-screenshots
needs: [android, update-screenshots, instrumentation]
runs-on: ubuntu-24.04
timeout-minutes: 2
steps:
# instrumentation is a matrix; its result is success only if every device that ran passed.
#
# A pull request whose goldens were just pushed is the exception: its commit is superseded by the pushed one,
# whose own run decides. This run is normally cancelled by that run (concurrency); if it is not, it does not report
# the old commit's screenshot failure, or its device tests, which the new run repeats, as the result.
- name: Require all checks
env:
BUILD_RESULT: ${{ needs.android.result }}
DEVICE_RESULT: ${{ needs.instrumentation.result }}
UPDATE_RESULT: ${{ needs.update-screenshots.result }}
PUSHED: ${{ needs.update-screenshots.outputs.pushed }}
run: |
if [ "$UPDATE_RESULT" = success ] && [ "$PUSHED" = true ]; then
echo "Screenshots updated: the commit pushed to this branch is checked by its own run." | tee -a "$GITHUB_STEP_SUMMARY"
exit 0
fi
test "$BUILD_RESULT" = success && test "$DEVICE_RESULT" = success