# 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: ac_taskgraph.loader.build_config:loader

transforms:
    - ac_taskgraph.transforms.build:transforms
    - taskgraph.transforms.code_review:transforms
    - taskgraph.transforms.job:transforms
    - taskgraph.transforms.task:transforms

not-for-components:
    - samples-browser   # Their configs are too different, so they're handled in a specific kind

kind-dependencies:
    - toolchain

# We always build components that have changed files or dependencies, but we also need
# to rebuild some or all components when other files change. This structure
# maintains the latter mapping. The value may either be a list of specific components,
# or the special sentinel value `all-components`.
files-affecting-components:
    ^build.gradle$: all-components
    ^settings.gradle$: all-components
    ^buildSrc.*$: all-components
    ^gradle.properties$: all-components
    ^gradle/wrapper/gradle-wrapper.properties$: all-components

job-defaults:
    artifact-template:
        type: file
        name: public/build/{artifact_file_name}
        path: '/builds/worker/checkouts/vcs/{component_path}/build/maven/org/mozilla/components/{component}/{version}/{artifact_file_name}'
    tests-artifact-template:
        type: directory
        name: public/reports/tests
        path: '/builds/worker/checkouts/vcs/{component_path}/build/reports/tests'
    lint-artifact-template:
        type: file
        name: public/reports/lint-results-release.html
        path: '/builds/worker/checkouts/vcs/{component_path}/build/reports/lint-results-release.html'
    text-artifact-template:
        type: file
        name: public/github/customCheckRunText.md
        path: '/builds/worker/github/customCheckRunText.md'
    jacoco-coverage-template:
        type: directory
        name: public/reports/jacoco
        path: '/builds/worker/checkouts/vcs/{component_path}/build/reports/jacoco'
    attributes:
        code-review:
            by-build-type:
                release: false
                nightly: false
                default: true
    description: Execute Gradle tasks for component "{component}"
    expose-artifacts:
        by-build-type:
            release: true
            nightly: true
            default: false
    fetches:
        toolchain:
            - android-sdk-linux
            - android-gradle-dependencies
    include-coverage:
        by-build-type:
            release: false
            nightly: false
            default: true
    run:
        gradlew:
            by-build-type:
                release:
                    - ':{component}:assembleRelease'
                    - ':{component}:testRelease'
                    - ':{component}:lintRelease'
                    - ':{component}:publish'
                nightly:
                    - '-PnightlyVersion={nightlyVersion}'
                    - ':{component}:assembleRelease'
                    - ':{component}:testRelease'
                    - ':{component}:lintRelease'
                    - ':{component}:publish'
                default:
                    by-component:
                        # No lintRelease on this job, gradle task isn't defined
                        tooling-lint:
                            - ':{component}:assemble'
                            - ':{component}:assembleAndroidTest'
                            - ':{component}:test'
                            - ':{component}:lint'
                            - 'githubBuildDetails'
                        # No testRelease on this job, gradle task isn't defined
                        tooling-detekt:
                            - ':{component}:assemble'
                            - ':{component}:assembleAndroidTest'
                            - ':{component}:test'
                            - ':{component}:lintRelease'
                            - 'githubBuildDetails'
                        default:
                            - ':{component}:assemble'
                            - ':{component}:assembleAndroidTest'
                            - ':{component}:testRelease'
                            - ':{component}:lintRelease'
                            - 'githubBuildDetails'
        using: gradlew
        use-caches: false
    run-on-tasks-for:
        by-build-type:
            release: []
            nightly: []
            default: [github-pull-request, github-push]
    treeherder:
        kind: build
        symbol:
            by-build-type:
                release: '{component}(BR)'
                nightly: '{component}(BN)'
                default: '{component}(B)'
        platform: android-all/opt
        tier: 1
    worker-type: b-android
    worker:
        chain-of-trust: true
        docker-image: {in-tree: base}
        max-run-time: 1200


overriden-jobs:
    # Treeherder group names are too long to fit in 25 chars
    lib-fetch-httpurlconnection:
        treeherder:
            symbol: 'lib-fetch-httpurlconnect(B)'
    nightly-lib-fetch-httpurlconnection:
        treeherder:
            symbol: 'lib-fetch-httpurlconnect(BN)'
    release-lib-fetch-httpurlconnection:
        treeherder:
            symbol: 'lib-fetch-httpurlconnect(BR)'

    feature-webcompat-reporter:
        treeherder:
            symbol: 'feature-webcompat-report(B)'
    nightly-feature-webcompat-reporter:
        treeherder:
            symbol: 'feature-webcompat-report(BN)'
    release-feature-webcompat-reporter:
        treeherder:
            symbol: 'feature-webcompat-report(BR)'
