# 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/.
---
task-defaults:
    platform: linux1804-64/opt
    always-target:
        by-platform:
            macosx.*: false
            default: true
    worker-type:
        by-platform:
            linux1804-64.*: t-linux-xlarge-source
            macosx1015-64.*: t-osx-1015-r8
            windows11-64.*: win11-64-2009-source
    worker:
        by-platform:
            linux1804-64.*:
                docker-image: {in-tree: "lint"}
                max-run-time: 3600
            macosx.*:
                max-run-time: 3600
                env:
                    PATH: "/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin"
            default:
                max-run-time: 3600
    use-python: default
    treeherder:
        kind: test
        tier: 1
    run:
        using: mach
    when:
        files-changed:
            - 'config/mozunit/**'
            - 'python/mach_commands.py'

firefox-ci:
    description: taskcluster/gecko_taskgraph unit tests
    always-target: false
    python-version: [3]
    treeherder:
        symbol: ci
    run:
        using: python-test
        subsuite: ci
    when:
        files-changed:
            - '.taskcluster.yml'
            - 'taskcluster/kinds/**'
            - 'taskcluster/**/*.py'
            - 'third_party/python/taskcluster_taskgraph/**/*.py'
            - 'tools/tryselect/selectors/auto.py'

fog:
    description: Python unit tests for Firefox on Glean
    platform:
        - linux1804-64/opt
        - macosx1015-64/opt
        - windows11-64/opt
    python-version: [3]
    treeherder:
        symbol: fp
    run:
        using: python-test
        subsuite: fog
    when:
        files-changed:
            - 'toolkit/components/glean/**'

mach:
    description: python/mach unit tests
    platform:
        - linux1804-64/opt
        - macosx1015-64/opt
        - windows11-64/opt
    python-version: [3]
    treeherder:
        symbol: mach
    run:
        using: python-test
        subsuite: mach
    when:
        files-changed:
            - 'python/mach/**'
            - 'python/sites/**'

marionette-harness:
    description: testing/marionette/harness unit tests
    platform:
        - linux1804-64/opt
        - windows11-64/opt
    python-version: [3]
    treeherder:
        symbol: mnh
    run:
        using: python-test
        subsuite: marionette-harness
    when:
        files-changed:
            - 'testing/marionette/harness/**'
            - 'testing/mozbase/mozlog/mozlog/**'
            - 'testing/mozbase/mozlog/setup.py'

mochitest-harness:
    description: testing/mochitest unittests
    platform:
        - linux1804-64/opt
        - linux1804-64/debug
        - linux1804-64-asan/opt
    always-target: false
    require-build:
        by-project:
            try:
                linux1804-64-asan/opt: build-linux64-asan/opt
                linux1804-64/debug: build-linux64/debug
                linux1804-64/opt: build-linux64/opt
            default:
                linux1804-64-asan/opt: build-linux64-asan/opt
                linux1804-64/debug: build-linux64/debug
                linux1804-64/opt: build-linux64-shippable/opt
    treeherder:
        symbol: py3(mch)
    worker:
        by-platform:
            linux1804-64.*:
                docker-image: {in-tree: "ubuntu1804-test"}
                max-run-time: 3600
    run:
        using: run-task
        cwd: '{checkout}'
        command: >
            source /builds/worker/scripts/xvfb.sh &&
            start_xvfb '1600x1200x24' 0 &&
            export GECKO_BINARY_PATH=$MOZ_FETCHES_DIR/firefox/firefox &&
            export TEST_HARNESS_ROOT=$MOZ_FETCHES_DIR/tests &&
            ./mach python-test --subsuite mochitest
    fetches:
        build:
            - target.tar.bz2
            - artifact: target.common.tests.tar.gz
              dest: tests
            - artifact: target.mochitest.tests.tar.gz
              dest: tests
        toolchain:
            - linux64-fix-stacks
    when:
        files-changed:
            - 'testing/mochitest/**'
            - 'testing/mozbase/mozrunner/mozrunner/**'
            - 'testing/mozbase/moztest/moztest/selftest/**'
            - 'testing/mozharness/mozharness/base/log.py'
            - 'testing/mozharness/mozharness/mozilla/structuredlog.py'
            - 'testing/mozharness/mozharness/mozilla/testing/errors.py'
            - 'testing/profiles/**'


mozbase:
    description: testing/mozbase unit tests
    platform:
        - linux1804-64/opt
        - macosx1015-64/opt
        - windows11-64/opt
    python-version: [3]
    treeherder:
        symbol: mb
    run:
        using: python-test
        subsuite: mozbase
    when:
        files-changed:
            - 'testing/mozbase/**'

mozharness:
    description: mozharness integration tests
    treeherder:
        symbol: py3(mh)
    run:
        using: run-task
        cache-dotcache: true
        cwd: '{checkout}/testing/mozharness'
        command: >
            /usr/local/bin/tox -e py311-hg6.4
    when:
        files-changed:
            - 'testing/mozharness/**'

mozlint:
    description: python/mozlint unit tests
    platform:
        - linux1804-64/opt
        - macosx1015-64/opt
        - windows11-64/opt
    python-version: [3]
    treeherder:
        symbol: mozlint
        tier: 2
    run:
        using: python-test
        subsuite: mozlint
    dependencies:
        clang-tidy:
            by-platform:
                linux1804-64/opt: toolchain-linux64-clang-tidy
                macosx1015-64/opt: toolchain-macosx64-clang-tidy
                windows11-64/opt: toolchain-win64-clang-tidy
    fetches:
        toolchain:
            by-platform:
                linux1804-64/opt:
                    - linux64-node
                    - linux64-rust
                macosx1015-64/opt:
                    - macosx64-node
                    - macosx64-rust
                windows11-64/opt:
                    - win64-node
                    - win64-rust
        clang-tidy:
            - artifact: clang-tidy.tar.zst
              dest: clang-tools
    when:
        files-changed:
            - 'python/mozlint/**'
            - 'tools/lint/**'

mozrelease:
    description: python/mozrelease unit tests
    python-version: [3]
    treeherder:
        symbol: release
    run:
        using: python-test
        subsuite: mozrelease
    when:
        files-changed:
            - 'python/mozrelease/**'

mozterm:
    description: python/mozterm unit tests
    platform:
        - linux1804-64/opt
        - windows11-64/opt
    python-version: [3]
    treeherder:
        symbol: term
    run:
        using: python-test
        subsuite: mozterm
    when:
        files-changed:
            - 'python/mozterm/**'

mozversioncontrol:
    description: python/mozversioncontrol unit tests
    platform:
        - linux1804-64/opt
        - macosx1015-64/opt
        - windows11-64/opt
    python-version: [3]
    treeherder:
        symbol: vcs
    run:
        using: python-test
        subsuite: mozversioncontrol
    when:
        files-changed:
            - 'python/mozversioncontrol/**'

raptor:
    description: testing/raptor unit tests
    platform:
        - linux1804-64/opt
        - macosx1015-64/opt
        - windows11-64/opt
    python-version: [3]
    treeherder:
        symbol: rap
    run:
        using: python-test
        subsuite: raptor
    when:
        files-changed:
            - 'testing/raptor/**'

reftest-harness:
    description: layout/tools/reftest unittests
    platform:
        - linux1804-64/opt
        - linux1804-64/debug
        - linux1804-64-asan/opt
    require-build:
        by-project:
            try:
                linux1804-64-asan/opt: build-linux64-asan/opt
                linux1804-64/debug: build-linux64/debug
                linux1804-64/opt: build-linux64/opt
            default:
                linux1804-64-asan/opt: build-linux64-asan/opt
                linux1804-64/debug: build-linux64/debug
                linux1804-64/opt: build-linux64-shippable/opt
    always-target: false
    treeherder:
        symbol: py3(ref)
    worker:
        by-platform:
            linux1804-64.*:
                docker-image: {in-tree: "ubuntu1804-test"}
                max-run-time: 3600
    run:
        using: run-task
        cwd: '{checkout}'
        command: >
            source /builds/worker/scripts/xvfb.sh &&
            start_xvfb '1600x1200x24' 0 &&
            export GECKO_BINARY_PATH=$MOZ_FETCHES_DIR/firefox/firefox &&
            export TEST_HARNESS_ROOT=$MOZ_FETCHES_DIR/tests &&
            ./mach python-test --subsuite reftest
    fetches:
        build:
            - target.tar.bz2
            - artifact: target.common.tests.tar.gz
              dest: tests
            - artifact: target.reftest.tests.tar.gz
              dest: tests
        toolchain:
            - linux64-fix-stacks
    when:
        files-changed:
            - 'layout/tools/reftest/**'
            - 'testing/mozbase/mozrunner/mozrunner/**'
            - 'testing/mozbase/moztest/moztest/selftest/**'
            - 'testing/mozharness/mozharness/base/log.py'
            - 'testing/mozharness/mozharness/mozilla/structuredlog.py'
            - 'testing/mozharness/mozharness/mozilla/testing/errors.py'

taskgraph-tests:
    description: taskcluster/gecko_taskgraph unit tests
    python-version: [3]
    treeherder:
        symbol: tg
    run:
        using: python-test
        subsuite: taskgraph
    when:
        files-changed:
            - 'python/mach/**/*.py'
            - 'taskcluster/**/*.py'
            - 'third_party/python/taskcluster_taskgraph/**/*.py'

tryselect:
    description: tools/tryselect unit tests
    platform:
        - linux1804-64/opt
        - windows11-64/opt
    python-version: [3]
    treeherder:
        symbol: try
    run:
        using: python-test
        subsuite: try
    when:
        files-changed:
            - 'taskcluster/config.yml'
            - 'taskcluster/kinds/test/**'
            - 'taskcluster/gecko_taskgraph/transforms/**'
            - 'third_party/python/taskcluster_taskgraph/**/*.py'
            - 'tools/tryselect/**'

mozbuild:
    description: mozbuild unit tests
    platform:
        - linux1804-64/opt
        - macosx1015-64/opt
        - windows11-64/opt
    python-version: [3]
    treeherder:
        symbol: mbu
    run:
        using: python-test
        subsuite: mozbuild
    fetches:
        toolchain:
            by-platform:
                linux1804-64/opt:
                    - linux64-node
                macosx1015-64/opt:
                    - macosx64-node
                windows11-64/opt:
                    - win64-node
                    - win64-mozmake
    when:
        files-changed:
            - '**/moz.configure'
            - 'build/moz.configure/**'
            - 'config/tests/**'
            - 'dom/bindings/mozwebidlcodegen/**'
            - 'modules/libpref/init/**'
            - 'modules/libpref/test/**'
            - 'python/mach/**'
            - 'python/mozboot/**'
            - 'python/mozbuild/**'
            - 'python/mozterm/**'
            - 'python/mozversioncontrol/**'
            - 'testing/mozbase/**'
            - 'testing/xpcshell/xpcshellcommandline.py'

mozperftest:
    description: mozperftest unit tests
    platform:
        - linux1804-64/opt
        - macosx1015-64/opt
        - windows11-64/opt
    treeherder:
        symbol: mpu
    run:
        mach: perftest-test
    fetches:
        toolchain:
            by-platform:
                linux1804-64/opt:
                    - linux64-node
                    - browsertime
                macosx1015-64/opt:
                    - macosx64-node
                    - browsertime
                windows11-64/opt:
                    - win64-node
                    - browsertime
    when:
        files-changed:
            - 'testing/performance/**'
            - 'python/mozperftest/**'

fxms-schemas:
    description: >
        Ensure messaging-system schemas are up-to-date and run Experimenter
        integration tests.
    platform:
        - linux1804-64/opt
    treeherder:
        symbol: py3(fxms)
    require-build:
        by-project:
            try:
                linux1804-64/opt: build-linux64/opt
            default:
                linux1804-64/opt: build-linux64/opt
    fetches:
        build:
            - artifact: target.tar.bz2
            - artifact: target.common.tests.tar.gz
    worker:
        by-platform:
            linux1804-64.*:
                docker-image: {in-tree: "ubuntu1804-test"}
                max-run-time: 3600
    run:
        using: run-task
        cwd: '{checkout}'
        command: >
            cd browser/components/asrouter/content-src/schemas &&
            env LD_LIBRARY_PATH=${MOZ_FETCHES_DIR}/firefox \
                ${MOZ_FETCHES_DIR}/bin/xpcshell \
                    -g ${MOZ_FETCHES_DIR}/firefox \
                    -a ${MOZ_FETCHES_DIR}/firefox/browser \
                    extract-test-corpus.js
            ../../../../../mach python -- make-schemas.py --check
    when:
        files-changed:
            - 'browser/components/asrouter/content-src/schemas/extract-test-corpus.js'
            - 'browser/components/asrouter/content-src/schemas/make-schemas.py'
            - 'browser/components/asrouter/content-src/**/*.schema.json'
            - 'browser/components/asrouter/modules/CFRMessageProvider.sys.mjs'
            - 'browser/components/asrouter/modules/OnboardingMessageProvider.sys.mjs'
            - 'browser/components/asrouter/modules/PanelTestProvider.sys.mjs'

condprof:
    description: testing/condprofile unit tests
    platform:
        - linux1804-64/opt
        - macosx1015-64/opt
        - windows11-64/opt
    python-version: [3]
    treeherder:
        symbol: condprof
    run:
        using: python-test
        subsuite: condprof
    when:
        files-changed:
            - 'testing/condprofile/condprof**'
            - 'testing/condprofile/setup.py'

featuregates:
    description: featuregates Python unit tests
    platform:
        - linux1804-64/opt
        - windows11-64/opt
    python-version: [3]
    treeherder:
        symbol: fg
    run:
        using: python-test
        subsuite: featuregates
    fetches:
        toolchain:
            by-platform:
                linux1804-64/opt:
                    - linux64-node
                windows11-64/opt:
                    - win64-node
    when:
        files-changed:
            - 'toolkit/components/featuregates/**'

skip-fails:
    description: testing/skip-fails unit tests
    always-target: false
    python-version: [3]
    treeherder:
        symbol: sf
    run:
        using: python-test
        subsuite: skip-fails
    when:
        files-changed:
            - 'testing/skipfails.py'
            - 'testing/test/**'

talos:
    description: testing/talos unit tests
    platform: windows11-64/opt
    python-version: [3]
    treeherder:
        symbol: tal
    run:
        using: python-test
        subsuite: talos
    when:
        files-changed:
            - 'testing/talos/**'

telemetry-integration-tests:
    description: pytest-based integration tests for Telemetry
    always-target: false
    platform:
        - linux1804-64/opt
    worker:
        by-platform:
            linux1804-64.*:
                docker-image: {in-tree: "ubuntu1804-test"}
                max-run-time: 3600
    require-build:
        by-project:
            try:
                linux1804-64/opt: build-linux64/opt
            default:
                linux1804-64/opt: build-linux64-shippable/opt
    treeherder:
        symbol: tt(i)
        tier: 3
    run-on-projects: []
    run:
        using: run-task
        cwd: '{checkout}'
        command: >
            source /builds/worker/scripts/xvfb.sh &&
            start_xvfb '1600x1200x24' 0 &&
            export GECKO_BINARY_PATH=$MOZ_FETCHES_DIR/firefox/firefox &&
            ./mach python-test --subsuite telemetry-integration-tests
    fetches:
        build:
            - target.tar.bz2
            - artifact: target.common.tests.tar.gz
              dest: tests
            - artifact: target.reftest.tests.tar.gz
              dest: tests
    when:
        files-changed:
            - 'toolkit/components/telemetry/**'

telemetry-python:
    description: Python unit tests for Telemetry
    platform:
        - linux1804-64/opt
        - macosx1015-64/opt
        - windows11-64/opt
    python-version: [3]
    treeherder:
        symbol: tp
    run:
        using: python-test
        subsuite: telemetry-python
    fetches:
        toolchain:
            by-platform:
                linux1804-64/opt:
                    - linux64-node
                macosx1015-64/opt:
                    - macosx64-node
                windows11-64/opt:
                    - win64-node
    when:
        files-changed:
            - 'toolkit/components/telemetry/**'

webext:
    description: WebExtensions python utilities unit tests
    platform:
        - linux1804-64/opt
    python-version: [3]
    treeherder:
        symbol: webext-py
        tier: 2
    run:
        using: python-test
        subsuite: webext-python
    when:
        files-changed:
            - 'toolkit/components/extensions/webidl-api/**'
            - 'toolkit/components/extensions/schemas/*.json'
            - 'browser/components/extensions/schemas/*.json'
            - 'mobile/shared/components/extensions/schemas/*.json'

xpcom:
    description: xpcom unit tests
    platform:
        - linux1804-64/opt
    python-version: [3]
    treeherder:
        symbol: xpcom
    run:
        using: python-test
        subsuite: xpcom
    when:
        files-changed:
            - 'third_party/python/ply/**'
            - 'xpcom/components/*.py'
            - 'xpcom/components/test/**'
            - 'xpcom/ds/tools/**'
            - 'xpcom/ds/test/**'
            - 'xpcom/idl-parser/**'
