# 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:
    - gecko_taskgraph.transforms.test_apk:transforms
    - gecko_taskgraph.transforms.job:transforms
    - gecko_taskgraph.transforms.task:transforms

kind-dependencies:
    - signing-apk

task-defaults:
    run-on-repo-type: [hg]
    description: Runs UI tests for sanity checking startup on Nightly
    treeherder:
        kind: test
        tier: 1
    worker-type: t-linux-docker-amd
    worker:
        docker-image: {in-tree: android-ui-tests}
        max-run-time: 7200
        env:
            GOOGLE_APPLICATION_CREDENTIALS: '.firebase_token.json'
        artifacts:
            - name: public
              path: /builds/worker/artifacts
              type: directory
        retry-exit-status: [20]
    run:
        using: run-commands
    run-on-projects: []
    routes:
        by-level:
            '3':
                - notify.slack-channel.C0134KJ4JHL.on-failed
            'default': []
    scopes:
        by-level:
            '3':
                - queue:route:notify.slack-channel.C0134KJ4JHL.on-failed
                - notify:slack-channel:C0134KJ4JHL
            'default': []
    extra:
        notify:
            by-level:
                '3':
                    slackText: '${rootUrl}/tasks/${status.taskId} | ${task.metadata.name} | ${task.metadata.source}'
                    slackBlocks: |
                        [
                          {
                            "type": "header",
                            "text": {
                              "type": "plain_text",
                              "text": "firefox-android :firefox: ${task.metadata.name} :x:\n "
                            }
                          },
                          {
                            "type": "divider"
                          },
                          {
                             "type": "section",
                             "text": {
                                 "type": "mrkdwn",
                                 "text": "*Task*: <${rootUrl}/tasks/${status.taskId}|Taskcluster>"
                            }
                          },
                          {
                            "type": "section",
                            "text": {
                              "type": "mrkdwn",
                              "text": "*Owner*: ${task.metadata.owner}"
                            }
                          },
                          {
                            "type": "section",
                            "text": {
                              "type": "mrkdwn",
                              "text": "*Source*: <${task.payload.env.GECKO_BASE_REPOSITORY}/rev/${task.payload.env.GECKO_HEAD_REV}|Commit> :hg:"
                            }
                          },
                          {
                            "type": "divider"
                          },
                          {
                            "type": "context",
                            "elements": [
                                {
                                    "type": "mrkdwn",
                                    "text": ":testops-notify: created by <https://mozilla-hub.atlassian.net/wiki/spaces/MTE/overview|Mobile Test Engineering>"
                                }
                            ]
                          }
                        ]
                'default': {}
tasks:
    fenix-arm64-v8a-nightly-robo-opt:
        attributes:
            build-type: fenix-nightly
            shipping-product: fenix
        description: Fenix Nightly Opt Robo Test (arm64-v8a)
        dependencies:
            signing: signing-apk-fenix-nightly
        fetches:
            signing:
                - artifact: target.arm64-v8a.apk
                  extract: false
        run:
            secrets:
                - name: project/gecko/level-any/firefox-android/fenix/firebase
                  key: firebaseToken
                  path: mobile/android/test_infra/.firebase_token.json
                  json: true
            commands:
                - [python3, taskcluster/scripts/tests/test-lab.py, fenix/arm-start-test-robo.yml, /builds/worker/fetches/target.arm64-v8a.apk]
        treeherder:
            platform: fenix-android-all/opt
            symbol: fenix-nightly(startup-arm64-robo-opt)
        worker:
            env:
                GOOGLE_PROJECT: moz-fenix

    fenix-arm64-v8a-nightly:
        attributes:
            build-type: fenix-nightly-firebase
            shipping-product: fenix
        dependencies:
            signing: signing-apk-fenix-nightly-firebase
            signing-android-test: signing-apk-fenix-android-test-nightly
        fetches:
            signing:
                - artifact: target.arm64-v8a.apk
                  extract: false
            signing-android-test:
                - artifact: target.noarch.apk
                  extract: false
        run:
            secrets:
                - name: project/gecko/level-any/firefox-android/fenix/firebase
                  key: firebaseToken
                  path: mobile/android/test_infra/.firebase_token.json
                  json: true
            commands:
                - [python3, taskcluster/scripts/tests/test-lab.py, fenix/arm-start-test.yml, /builds/worker/fetches/target.arm64-v8a.apk, --apk_test, /builds/worker/fetches/target.noarch.apk]
        treeherder:
            platform: fenix-android-all/opt
            symbol: fenix-nightly(startup-arm64-v8a)
        worker:
            env:
                GOOGLE_PROJECT: moz-fenix

    fenix-armeabi-v7a-nightly:
        attributes:
            build-type: fenix-nightly-firebase
            shipping-product: fenix
        dependencies:
            signing: signing-apk-fenix-nightly-firebase
            signing-android-test: signing-apk-fenix-android-test-nightly
        fetches:
            signing:
                - artifact: target.armeabi-v7a.apk
                  extract: false
            signing-android-test:
                - artifact: target.noarch.apk
                  extract: false
        run:
            secrets:
                - name: project/gecko/level-any/firefox-android/fenix/firebase
                  key: firebaseToken
                  path: mobile/android/test_infra/.firebase_token.json
                  json: true
            commands:
                - [python3, taskcluster/scripts/tests/test-lab.py, fenix/armeabi-v7a-start-test.yml, /builds/worker/fetches/target.armeabi-v7a.apk, --apk_test, /builds/worker/fetches/target.noarch.apk]
        treeherder:
            platform: fenix-android-all/opt
            symbol: fenix-nightly(startup-armeabi-v7a)
        worker:
            env:
                GOOGLE_PROJECT: moz-fenix

    focus-arm64-v8a-nightly:
        attributes:
            build-type: focus-nightly-firebase
            shipping-product: focus
        dependencies:
            signed-apk-debug-apk: signing-apk-focus-nightly-firebase
            signed-apk-android-test: signing-apk-focus-android-test-nightly
        fetches:
            signed-apk-debug-apk:
                - artifact: target.arm64-v8a.apk
                  extract: false
            signed-apk-android-test:
                - artifact: target.noarch.apk
                  extract: false
        run:
            secrets:
                - name: project/gecko/level-any/firefox-android/focus-android/firebase
                  key: firebaseToken
                  path: mobile/android/test_infra/.firebase_token.json
                  json: true
            commands:
                - [python3, taskcluster/scripts/tests/test-lab.py, focus/arm-start-test.yml, /builds/worker/fetches/target.arm64-v8a.apk, --apk_test, /builds/worker/fetches/target.noarch.apk]
        treeherder:
            platform: focus-android-all/opt
            symbol: focus-nightly(startup-arm64-v8a)
        worker:
            env:
                GOOGLE_PROJECT: moz-focus-android

    focus-armeabi-v7a-nightly:
        attributes:
            build-type: focus-nightly-firebase
            shipping-product: focus
        dependencies:
            signed-apk-debug-apk: signing-apk-focus-nightly-firebase
            signed-apk-android-test: signing-apk-focus-android-test-nightly
        fetches:
            signed-apk-debug-apk:
                - artifact: target.armeabi-v7a.apk
                  extract: false
            signed-apk-android-test:
                - artifact: target.noarch.apk
                  extract: false
        run:
            secrets:
                - name: project/gecko/level-any/firefox-android/focus-android/firebase
                  key: firebaseToken
                  path: mobile/android/test_infra/.firebase_token.json
                  json: true
            commands:
                - [python3, taskcluster/scripts/tests/test-lab.py, focus/armeabi-v7a-start-test.yml, /builds/worker/fetches/target.armeabi-v7a.apk, --apk_test, /builds/worker/fetches/target.noarch.apk]
        treeherder:
            platform: focus-android-all/opt
            symbol: focus-nightly(startup-armeabi-v7a)
        worker:
            env:
                GOOGLE_PROJECT: moz-focus-android

    focus-arm64-v8a-nightly-robo-opt:
        attributes:
            build-type: focus-nightly
            shipping-product: focus
        description: Focus Nightly Opt Robo Test (ARM)
        dependencies:
            signing: signing-apk-focus-nightly
        fetches:
            signing:
                - artifact: target.arm64-v8a.apk
                  extract: false
        run:
            secrets:
                - name: project/gecko/level-any/firefox-android/focus-android/firebase
                  key: firebaseToken
                  path: mobile/android/test_infra/.firebase_token.json
                  json: true
            commands:
                - [python3, taskcluster/scripts/tests/test-lab.py, focus/arm-start-test-robo.yml, /builds/worker/fetches/target.arm64-v8a.apk]
        treeherder:
            symbol: focus-nightly(startup-arm64-robo-opt)
            platform: focus-android-all/opt
        worker:
            env:
                GOOGLE_PROJECT: moz-focus-android
