# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
---
loader: taskgraph.loader.transform:loader

transforms:
    - taskgraph.transforms.job:transforms
    - taskgraph.transforms.task:transforms

kind-dependencies:
    - toolchain


job-defaults:
    attributes:
        build-type: debug
        code-review: true
    fetches:
        toolchain:
            - android-sdk-linux
            - android-gradle-dependencies
    run:
        # TODO Generate APKs in a build task instead
        gradlew: ['clean', 'assembleGecko', 'assembleAndroidTest', 'assembleDebug']
        secrets:
            - name: project/mobile/android-components/firebase
              key: firebaseToken
              path: .firebase_token.json
              json: true
        using: gradlew
        use-caches: false
    run-on-tasks-for: [github-push]
    treeherder:
            kind: test
            platform: 'ui-test/opt'
            tier: 2
    worker-type: b-android
    worker:
        artifacts:
            - name: public
              path: /builds/worker/artifacts
              type: directory
        docker-image: {in-tree: ui-tests}
        env:
            GOOGLE_APPLICATION_CREDENTIALS: '.firebase_token.json'
            GOOGLE_PROJECT: moz-android-components-230120
        max-run-time: 2400


jobs:
    unit-browser-engine-gecko-nightly:
        description: 'Run unit tests on device for browser component'
        run:
            post-gradlew:
                - ['automation/taskcluster/androidTest/ui-test.sh', 'browser', 'arm', '1']
        treeherder:
            symbol: 'ui-components'
    ui-browser:
        description: 'Run ui tests for browser sample'
        run:
            post-gradlew:
                - ['automation/taskcluster/androidTest/ui-test.sh', 'samples-browser', 'arm', '1']
        treeherder:
            symbol: 'ui-samples-browser'
    ui-glean:
        description: 'Run ui tests for glean sample'
        run:
            post-gradlew:
                - ['automation/taskcluster/androidTest/ui-test.sh', 'samples-glean', 'arm', '1']
        treeherder:
            symbol: 'ui-samples-glean'
    android-feature-containers:
        description: 'Run unit tests on device for feature containers'
        run:
            post-gradlew:
                - ['automation/taskcluster/androidTest/ui-test.sh', 'feature-containers', 'arm', '1']
        treeherder:
            symbol: 'unit-feature-containers'
    android-feature-pwa:
        description: 'Run unit tests on device for feature pwa'
        run:
            post-gradlew:
                - ['automation/taskcluster/androidTest/ui-test.sh', 'feature-pwa', 'arm', '1']
        treeherder:
            symbol: 'unit-feature-pwa'
    android-feature-share:
        description: 'Run unit tests on device for feature share'
        run:
            post-gradlew:
                - ['automation/taskcluster/androidTest/ui-test.sh', 'feature-share', 'arm', '1']
        treeherder:
            symbol: 'unit-share'
    android-feature-sitepermissions:
        description: 'Run unit tests on device for feature site permissions'
        run:
            post-gradlew:
                - ['automation/taskcluster/androidTest/ui-test.sh', 'feature-sitepermissions', 'arm', '1']
        treeherder:
            symbol: 'unit-sitepermissions'
    android-feature-top-sites:
        description: 'Run unit tests on device for feature top sites'
        run:
            post-gradlew:
                - ['automation/taskcluster/androidTest/ui-test.sh', 'feature-top-sites', 'arm', '1']
        treeherder:
            symbol: 'unit-feature-top-sites'
    android-feature-logins:
        description: 'Run unit tests on device for feature logins'
        run:
            post-gradlew:
                - ['automation/taskcluster/androidTest/ui-test.sh', 'feature-logins', 'arm', '1']
        treeherder:
            symbol: 'unit-logins'
    android-feature-prompts:
        description: 'Run unit tests on device for feature prompts'
        run:
            post-gradlew:
                - ['automation/taskcluster/androidTest/ui-test.sh', 'feature-prompts', 'arm', '1']
        treeherder:
            symbol: 'unit-feature-prompts'
    android-support-ktx:
        description: 'Run unit tests on device for support ktx'
        run:
            post-gradlew:
                - ['automation/taskcluster/androidTest/ui-test.sh', 'support-ktx', 'arm', '1']
        treeherder:
            symbol: 'unit-support-ktx'
    android-feature-downloads:
        description: 'Run unit tests on device for feature downloads'
        run:
            post-gradlew:
                - ['automation/taskcluster/androidTest/ui-test.sh', 'support-ktx', 'arm', '1']
        treeherder:
            symbol: 'unit-feature-downloads'

overriden-jobs:
    # names too long to fit in 25 chars
    android-feature-recentlyclosed:
        description: 'Run unit tests on device for feature recentlyclosed'
        run:
            post-gradlew:
                - ['automation/taskcluster/androidTest/ui-test.sh', 'feature-recentlyclosed', 'arm', '1']
        treeherder:
            symbol: 'unit-feature-recentlyclosed'
