# 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:
    - android_taskgraph.transforms.build_android_app:transforms
    - gecko_taskgraph.transforms.build_schedules:transforms
    - gecko_taskgraph.transforms.job:transforms
    - gecko_taskgraph.transforms.task:transforms

kind-dependencies:
    - toolchain
    - build-fat-aar
    - generate-baseline-profile-firebase

task-defaults:
    apk-artifact-template:
        type: file
        name: 'public/build/target.{abi}.apk'
        path: '/builds/worker/workspace/obj-build/gradle/build/mobile/android/{source_project_name}/app/outputs/apk/{gradle_build}/{gradle_build_type}/{fileName}'
    attributes:
        build_platform: android


tasks:
    focus-debug:
        attributes:
            shipping-product: focus
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar/opt
        description: 'Focus debug build from source code'
        run:
            gradle-build-type: debug
            gradle-build-name: focusDebug
            gradle-build: focus
        source-project-name: "focus-android"
        treeherder:
            symbol: focus-debug(Bf)
            platform: focus-android-all/opt

    klar-debug:
        attributes:
            shipping-product: focus
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar/opt
        description: 'Klar debug build from source code'
        run:
            gradle-build-type: debug
            gradle-build-name: klarDebug
            gradle-build: klar
        source-project-name: "focus-android"
        treeherder:
            symbol: focus-debug(Bkl)
            platform: focus-android-all/opt

    fenix-debug:
        attributes:
            shipping-product: fenix
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar/opt
        description: 'Fenix debug build from source code'
        run:
            gradle-build-type: debug
            gradle-build-name: fenixDebug
            gradle-build: fenix
            gradle-extra-options:
                - -PdisableLeakCanary
            track-apk-size: true
        source-project-name: "fenix"
        treeherder:
            symbol: fenix-debug(Bf)
            platform: fenix-android-all/opt

    focus-release:
        description: 'Release Focus build'
        attributes:
            release-type: release
            shipping-product: focus
        shipping-product: firefox-android
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar-shippable/opt
        include-shippable-secrets: true
        include-release-version: true
        run:
            gradle-build-type: release
            gradle-build-name: focusRelease
            gradle-build: focus
        run-on-projects: []
        shipping-phase: promote
        source-project-name: "focus-android"
        treeherder:
            symbol: focus-release(Bf)
            platform: focus-android-all/opt

    klar-release:
        description: 'Release Klar build'
        attributes:
            release-type: release
            shipping-product: focus
        shipping-product: firefox-android
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar-shippable/opt
        include-shippable-secrets: true
        include-release-version: true
        run:
            gradle-build-type: release
            gradle-build-name: klarRelease
            gradle-build: klar
        run-on-projects: []
        shipping-phase: promote
        source-project-name: "focus-android"
        treeherder:
            symbol: focus-release(Bkl)
            platform: focus-android-all/opt

    fenix-release:
        description: 'Release Fenix build'
        attributes:
            release-type: release
            shipping-product: fenix
        shipping-product: firefox-android
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar-shippable/opt
            baseline-profile: generate-baseline-profile-firebase-fenix
        fetches:
            baseline-profile:
                - artifact: baseline-prof.txt
                  extract: false
                  dest: baselineProfiles
        include-shippable-secrets: true
        include-release-version: true
        run:
            gradle-build-type: release
            gradle-build-name: fenixRelease
            gradle-build: fenix
            track-apk-size: true
            baseline-profile-path: /builds/worker/fetches/baselineProfiles
        run-on-projects: []
        shipping-phase: promote
        source-project-name: "fenix"
        treeherder:
            symbol: fenix-release(Bf)
            platform: fenix-android-all/opt

    focus-nightly:
        description: 'Nightly focus build'
        attributes:
            # any tasks that have this as a primary dependency will
            # inherit this attribute via the multi_dep loader
            shipping-product: focus
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar-shippable/opt
        include-shippable-secrets: true
        include-nightly-version: true
        run:
            gradle-build-type: nightly
            gradle-build-name: focusNightly
            gradle-build: focus
        run-on-projects: []
        source-project-name: "focus-android"
        treeherder:
            symbol: focus-nightly(B)
            platform: focus-android-all/opt

    fenix-nightly:
        description: 'Nightly fenix build'
        attributes:
            # any tasks that have this as a primary dependency will
            # inherit this attribute via the multi_dep loader
            shipping-product: fenix
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar-shippable/opt
            baseline-profile: generate-baseline-profile-firebase-fenix
        fetches:
            baseline-profile:
                - artifact: baseline-prof.txt
                  extract: false
                  dest: baselineProfiles
        include-shippable-secrets: true
        include-nightly-version: true
        source-project-name: "fenix"
        run:
            gradle-build-type: nightly
            gradle-build-name: fenixNightly
            gradle-build: fenix
            track-apk-size: true
            baseline-profile-path: /builds/worker/fetches/baselineProfiles
        run-on-projects: []
        treeherder:
            symbol: fenix-nightly(B)
            platform: fenix-android-all/opt

    focus-beta:
        description: 'Beta focus build'
        attributes:
            release-type: beta
            shipping-product: focus
        shipping-product: firefox-android
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar-shippable/opt
        include-shippable-secrets: true
        include-release-version: true
        run:
            gradle-build-type: beta
            gradle-build-name: focusBeta
            gradle-build: focus
        run-on-projects: []
        shipping-phase: promote
        source-project-name: "focus-android"
        treeherder:
            symbol: focus-beta(B)
            platform: focus-android-all/opt

    fenix-beta:
        description: 'Beta fenix build'
        attributes:
            release-type: beta
            shipping-product: fenix
        shipping-product: firefox-android
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar-shippable/opt
            baseline-profile: generate-baseline-profile-firebase-fenix
        fetches:
            baseline-profile:
                - artifact: baseline-prof.txt
                  extract: false
                  dest: baselineProfiles
        include-shippable-secrets: true
        include-release-version: true
        run:
            gradle-build-type: beta
            gradle-build-name: fenixBeta
            gradle-build: fenix
            track-apk-size: true
            baseline-profile-path: /builds/worker/fetches/baselineProfiles
        run-on-projects: []
        shipping-phase: promote
        source-project-name: "fenix"
        treeherder:
            symbol: fenix-beta(B)
            platform: fenix-android-all/opt

    focus-nightly-firebase:
        attributes:
            shipping-product: focus
        description: 'Focus Nightly build for UI tests'
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar/opt
        disable-optimization: true
        run:
            gradle-build-type: nightly
            gradle-build-name: focusNightly
            gradle-build: focus
            test-build-type: nightly
        run-on-projects: [trunk]
        source-project-name: "focus-android"
        treeherder:
            symbol: focus-nightly(Bf)
            platform: focus-android-all/opt

    fenix-nightly-firebase:
        attributes:
            shipping-product: fenix
        description: 'Fenix Nightly build for UI tests'
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar/opt
        disable-optimization: true
        run:
            gradle-build-type: nightly
            gradle-build-name: fenixNightly
            gradle-build: fenix
            test-build-type: nightly
        run-on-projects: [trunk]
        source-project-name: "fenix"
        treeherder:
            symbol: fenix-nightly(Bf)
            platform: fenix-android-all/opt

    focus-beta-firebase:
        attributes:
            shipping-product: focus
        description: 'Focus Beta build for UI tests'
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar-shippable/opt
        disable-optimization: true
        run:
            gradle-build-type: beta
            gradle-build-name: focusBeta
            gradle-build: focus
            test-build-type: beta
        run-on-projects: ['release']
        source-project-name: "focus-android"
        treeherder:
            symbol: focus-beta(Bf)
            platform: focus-android-all/opt

    fenix-beta-firebase:
        attributes:
            shipping-product: fenix
        description: 'Fenix Beta build for UI tests'
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar-shippable/opt
        disable-optimization: true
        run:
            gradle-build-type: beta
            gradle-build-name: fenixBeta
            gradle-build: fenix
            test-build-type: beta
        run-on-projects: ['release']
        source-project-name: "fenix"
        treeherder:
            symbol: fenix-beta(Bf)
            platform: fenix-android-all/opt

    focus-android-test-debug:
        attributes:
            shipping-product: focus
        description: 'Focus Android Test for debugging'
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar/opt
        run:
            gradle-build-type: androidTest
            gradle-build-name: androidTest
            gradle-build: focus
        source-project-name: "focus-android"
        apk-artifact-template:
            # this path is determined by the gradle build configs
            path: '/builds/worker/workspace/obj-build/gradle/build/mobile/android/focus-android/app/outputs/apk/androidTest/focus/debug/app-focus-debug-androidTest.apk'
        treeherder:
            symbol: focus-debug(Bat)
            platform: focus-android-all/opt

    fenix-android-test-debug:
        attributes:
            shipping-product: fenix
        description: 'Fenix Debug Android Test for debugging'
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar/opt
        run:
            gradle-build-type: androidTest
            gradle-build-name: androidTest
            gradle-build: fenix
        source-project-name: "fenix"
        apk-artifact-template:
            # 3 differences here:
            #  * "androidTest/" is added
            #  * "{gradle_build_type}" is forced to "debug"
            #  * "{fileName}" is forced to "app-fenix-debug-androidTest.apk"
            path: '/builds/worker/workspace/obj-build/gradle/build/mobile/android/fenix/app/outputs/apk/androidTest/fenix/debug/app-fenix-debug-androidTest.apk'
        treeherder:
            symbol: fenix-debug(Bat)
            platform: fenix-android-all/opt

    # android-test-nightly and android-test-beta, while still being debug builds, are meant to be signed
    # with the nightly/beta key. The Firebase testing infrastructure requires both the androidTest APK
    # and the APK under test to be signed with the same key. Thus, the nightly APK being signed with
    # nightly means we need an androidTest APK with the same signature.

    focus-android-test-nightly:
        attributes:
            shipping-product: focus
        description: 'Focus Nightly Android Test for debugging'
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar/opt
        run:
            gradle-build-type: androidTest
            gradle-build-name: androidTest
            gradle-build: focus
            test-build-type: nightly
        run-on-projects: [trunk]
        source-project-name: "focus-android"
        apk-artifact-template:
            path: '/builds/worker/workspace/obj-build/gradle/build/mobile/android/focus-android/app/outputs/apk/androidTest/focus/nightly/app-focus-nightly-androidTest.apk'
        treeherder:
            symbol: focus-nightly(Bat)
            platform: focus-android-all/opt

    # android-test-nightly and android-test-beta, while still being debug builds, are meant to be signed
    # with the nightly/beta key. The Firebase testing infrastructure requires both the androidTest APK
    # and the APK under test to be signed with the same key. Thus, the nightly APK being signed with
    # nightly means we need an androidTest APK with the same signature.
    #
    # TODO: See if we can tweak the signing kind to make 2 signing jobs out of a single `android-test`
    # job.
    fenix-android-test-nightly:
        attributes:
            nightly: true
            shipping-product: fenix
        description: 'Fenix Nightly Android Test for debugging'
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar/opt
        apk-artifact-template:
            # 3 differences here:
            #  * "androidTest/" is added
            #  * "{gradle_build_type}" is forced to "debug"
            #  * "{fileName}" is forced to "app-fenix-nightly-androidTest.apk"
            path: '/builds/worker/workspace/obj-build/gradle/build/mobile/android/fenix/app/outputs/apk/androidTest/fenix/nightly/app-fenix-nightly-androidTest.apk'
        disable-optimization: true
        run:
            gradle-build-type: androidTest
            gradle-build-name: androidTest
            gradle-build: fenix
            test-build-type: nightly
        run-on-projects: [trunk]
        source-project-name: "fenix"
        treeherder:
            symbol: fenix-nightly(Bat)
            platform: fenix-android-all/opt

    focus-android-test-beta:
        attributes:
            shipping-product: focus
        description: 'Focus Beta Android Test for debugging'
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar-shippable/opt
        run:
            gradle-build-type: androidTest
            gradle-build-name: androidTest
            gradle-build: focus
            test-build-type: beta
        run-on-projects: ['release']
        source-project-name: "focus-android"
        apk-artifact-template:
            path: '/builds/worker/workspace/obj-build/gradle/build/mobile/android/focus-android/app/outputs/apk/androidTest/focus/beta/app-focus-beta-androidTest.apk'
        treeherder:
            symbol: focus-beta(Bat)
            platform: focus-android-all/opt

    fenix-android-test-beta:
        attributes:
            shipping-product: fenix
        description: 'Fenix Beta Android Test for debugging'
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar-shippable/opt
        apk-artifact-template:
            # 3 differences here:
            #  * "androidTest/" is added
            #  * "{gradle_build_type}" is forced to "beta"
            #  * "{fileName}" is forced to "app-fenix-beta-androidTest.apk"
            path: '/builds/worker/workspace/obj-build/gradle/build/mobile/android/fenix/app/outputs/apk/androidTest/fenix/beta/app-fenix-beta-androidTest.apk'
        disable-optimization: true
        run:
            gradle-build-type: androidTest
            gradle-build-name: androidTest
            gradle-build: fenix
            test-build-type: beta
        run-on-projects: ['release']
        source-project-name: "fenix"
        treeherder:
            symbol: fenix-beta(Bat)
            platform: fenix-android-all/opt

    fenix-android-test-mozillaonline:
        attributes:
            shipping-product: fenix
        description: 'Fenix Android Test mozillaonline'
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar-shippable/opt
        apk-artifact-template:
            # 3 differences here:
            #  * "androidTest/" is added
            #  * "{gradle_build_type}" is forced to "beta"
            #  * "{fileName}" is forced to "app-fenix-beta-androidTest.apk"
            path: '/builds/worker/workspace/obj-build/gradle/build/mobile/android/fenix/app/outputs/apk/androidTest/fenix/beta/app-fenix-beta-androidTest.apk'
        run-on-projects: []
        disable-optimization: true
        run:
            gradle-build-type: androidTest
            gradle-build-name: androidTest
            gradle-build: fenix
            gradle-extra-options:
                - -PmozillaOnline
            test-build-type: beta
        source-project-name: "fenix"
        treeherder:
            symbol: fenix-beta(Bat-mo)
            platform: fenix-android-all/opt

    fenix-nightly-simulation:
        description: 'Fenix Nightly Simulation'
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar-shippable/opt
            baseline-profile: generate-baseline-profile-firebase-fenix
        fetches:
            baseline-profile:
                - artifact: baseline-prof.txt
                  extract: false
                  dest: baselineProfiles
        attributes:
            nightly: false
            shipping-product: fenix
        include-nightly-version: true
        include-shippable-secrets: true
        run-on-projects: []
        run:
            gradle-build-type: nightly
            gradle-build-name: fenixNightly
            gradle-build: fenix
            baseline-profile-path: /builds/worker/fetches/baselineProfiles
        source-project-name: "fenix"
        treeherder:
            symbol: fenix-nightlySim(B)
            platform: fenix-android-all/opt

    fenix-beta-mozillaonline:
        description: 'Fenix Beta mozillaonline'
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar-shippable/opt
        attributes:
            release-type: beta
            shipping_phase: promote
            shipping-product: fenix
        include-release-version: true
        include-shippable-secrets: true
        run:
            gradle-build-type: beta
            gradle-build-name: fenixBeta
            gradle-build: fenix
            gradle-extra-options:
                - -PmozillaOnline
        run-on-projects: []
        source-project-name: "fenix"
        treeherder:
            symbol: fenix-beta(Bmo)
            platform: fenix-android-all/opt

    fenix-release-mozillaonline:
        description: 'Fenix Release mozillaonline'
        dependencies:
            build-fat-aar: build-fat-aar-android-geckoview-fat-aar-shippable/opt
            baseline-profile: generate-baseline-profile-firebase-fenix
        fetches:
            baseline-profile:
                - artifact: baseline-prof.txt
                  extract: false
                  dest: baselineProfiles
        attributes:
            release-type: release
            shipping_phase: promote
            shipping-product: fenix
        include-release-version: true
        include-shippable-secrets: true
        run:
            gradle-build-type: release
            gradle-build-name: fenixRelease
            gradle-build: fenix
            gradle-extra-options:
                - -PmozillaOnline
            baseline-profile-path: /builds/worker/fetches/baselineProfiles
        run-on-projects: []
        source-project-name: "fenix"
        treeherder:
            symbol: fenix-release(Bmo)
            platform: fenix-android-all/opt
