<commit_before>version: 1
policy:
  pullRequests: public
tasks:
###############################################################################
# Task: Pull requests
#
# Triggered whenever a pull request is opened or updated.
#
# - Build the app (all flavors)
# - Run unit tests
# - Run code quality tools (spotbugs, lint, checkstyle etc.)
###############################################################################
  - $if: 'tasks_for == "github-pull-request" && event["action"] in ["opened", "reopened", "synchronize"]'
    then:
      created: {$fromNow: ''}
      deadline: {$fromNow: '2 hours'}
      provisionerId: aws-provisioner-v1
      workerType: github-worker
      routes: []
      scopes: []
      payload:
        maxRunTime: 7200
        image: mozillamobile/focus-android:1.2
        command:
          - /bin/bash
          - --login
          - -cx
          - >-
            git fetch ${event.pull_request.head.repo.clone_url} ${event.pull_request.head.ref}
            && git config advice.detachedHead false
            && git checkout ${event.pull_request.head.sha}
            && echo "--" > .adjust_token
            && python tools/l10n/check_locales.py
            && ./gradlew --no-daemon clean assembleFocusX86Debug assembleKlarX86Nightly assembleRelease detektCheck ktlint lintFocusX86Debug lintKlarX86Nightly pmd checkstyle spotbugs assembleFocusX86DebugAndroidTest testFocusX86DebugUnitTest testKlarX86NightlyUnitTest
            && pip install "compare-locales>=5.0.2,<6.0"
            && compare-locales --validate l10n.toml .
        artifacts:
          public:
            type: directory
            path: /opt/focus-android/app/build/reports
            expires: {$fromNow: '1 week'}
      metadata:
        name: Focus for Android - Build - Pull Request
        description: Building Focus for Android (via Gradle) - triggered by a pull request.
        owner: ${event.pull_request.user.<EMAIL>
        source: ${event.repository.url}
###############################################################################
# Task: Builds on branches of the main repo
#
# Triggered whenever something is pushed/merged to the mozilla-mobile repo.
# Tags (which are considered to be pushes) are ignored.
#
# Creates the following task pipeline:
#
# Build -+--> Unit tests ----+- UI tests
#         \-> Code quality -/
#
###############################################################################
  - $if: 'tasks_for == "github-push"'
    then:
      $if: 'event.repository.fork == false && event.ref[:10] != "refs/tags/"'
      then:
        taskId: {$eval: as_slugid("decision_task")}
        # The next line won't be needed anymore after https://github.com/taskcluster/taskcluster-github/pull/273
        taskGroupId: {$eval: as_slugid("decision_task")}
        created: {$fromNow: ''}
        deadline: {$fromNow: '2 hours'}
        provisionerId: aws-provisioner-v1
        workerType: github-worker
        routes:
          - 'notify.irc-channel.#android-ci.on-any'
        scopes:
          - queue:create-task:aws-provisioner-v1/github-worker
          - queue:scheduler-id:taskcluster-github
          - secrets:get:project/focus/firebase
          - secrets:get:project/focus/nimbledroid
          - queue:route:notify.irc-channel.#android-ci.on-any
        payload:
          maxRunTime: 7200
          image: mozillamobile/focus-android:1.2
          features:
            taskclusterProxy: true
          env:
            TASK_ID: {$eval: as_slugid("decision_task")}
            MOBILE_HEAD_REPOSITORY: ${event.repository.clone_url}
            MOBILE_HEAD_BRANCH: ${event.ref}
            MOBILE_HEAD_REV: ${event.after}
          command:
            - /bin/bash
            - --login
            - -cx
            - >-
              git fetch origin
              && git config advice.detachedHead false
              && git checkout ${event.after}
              && python tools/taskcluster/schedule-master-build.py
          artifacts:
            public:
              type: directory
              path: /opt/focus-android/test_artifacts
              expires: {$fromNow: '1 week'}
        metadata:
          name: (Focus for Android) Schedule tasks
          description: Scheduling tasks for master push
          owner: <EMAIL>
          source: ${event.repository.url}
###############################################################################
# Task: Release builds
#
# Triggered when a new GitHub release is created (in any branch)
#
# - Builds release versions of Focus and Klar
# - Signs the builds with the release key
# - Uploads the builds to the "alpha" track on Google Play
###############################################################################
  - $if: 'tasks_for == "github-release"'
    then:
      $let:
        decision_task_id: {$eval: as_slugid("decision_task")}
        expires_in: {$fromNow: '1 year'}
        repository: https://github.com/mozilla-mobile/focus-android
        scheduler_id: taskcluster-github
      in:
        taskId: ${decision_task_id}
        taskGroupId: ${decision_task_id}  # Must be explicit because of Chain of Trust
        created: {$fromNow: ''}
        deadline: {$fromNow: '2 hours'}
        expires: ${expires_in}
        schedulerId: ${scheduler_id}   # Must be explicit because of Chain of Trust
        provisionerId: aws-provisioner-v1
        workerType: gecko-focus   # This workerType has ChainOfTrust enabled
        requires: all-completed   # Must be explicit because of Chain of Trust
        priority: highest
        retries: 5
        scopes:
          - queue:scheduler-id:${scheduler_id}
          - queue:create-task:highest:aws-provisioner-v1/gecko-focus
          - queue:create-task:highest:scriptworker-prov-v1/mobile-signing-v1
          - queue:create-task:highest:scriptworker-prov-v1/mobile-pushapk-v1
          - project:mobile:focus:releng:signing:cert:release-signing
          - project:mobile:focus:releng:signing:format:autograph_focus
          - project:mobile:focus:releng:googleplay:product:focus
          - secrets:get:project/focus/tokens
          - queue:route:index.project.mobile.focus.release.latest
        payload:
          maxRunTime: 600   # Decision should remain fast enough to schedule a handful of tasks
          image: mozillamobile/focus-android:1.2
          features:
            taskclusterProxy: true
            chainOfTrust: true
          env:
            TASK_ID: ${decision_task_id}
            SCHEDULER_ID: ${scheduler_id}
            MOBILE_HEAD_REPOSITORY: ${repository}
            MOBILE_HEAD_BRANCH: ${event.release.target_commitish}
            MOBILE_HEAD_REV: ${event.release.tag_name}
            MOBILE_TRIGGERED_BY: ${event.sender.login}
          command:
            - /bin/bash
            - --login
            - -cx
            - >-
              git fetch origin --tags
              && git config advice.detachedHead false
              && git checkout ${event.release.tag_name}
              && python tools/taskcluster/release.py \
                --tag ${event.release.tag_name} \
                --track alpha \
                --commit \
                --output /opt/focus-android/app/build/outputs/apk \
                --apk focusX86/release/app-focus-x86-release-unsigned.apk \
                --apk klarX86/release/app-klar-x86-release-unsigned.apk \
                --apk focusArm/release/app-focus-arm-release-unsigned.apk \
                --apk klarArm/release/app-klar-arm-release-unsigned.apk
          artifacts:
            public/task-graph.json:
              type: file
              path: /opt/focus-android/task-graph.json
              expires: ${expires_in}
            public/actions.json:
              type: file
              path: /opt/focus-android/actions.json
              expires: ${expires_in}
            public/parameters.yml:
              type: file
              path: /opt/focus-android/parameters.yml
              expires: ${expires_in}
        extra:
            tasks_for: ${tasks_for}
        metadata:
          name: (Focus for Android) Decision task (${event.release.tag_name})
          description: Scheduling tasks for releasing Focus/Klar
          owner: ${<EMAIL>
          source: ${repository}/raw/${event.release.tag_name}/.taskcluster.yml
# Nighly builds
  - $if: 'tasks_for == "cron"'
    then:
      $let:
        decision_task_id: {$eval: as_slugid("decision_task")}
        expires_in: {$fromNow: '1 year'}
        repository: https://github.com/mozilla-mobile/focus-android
        scheduler_id: focus-nightly-sched
      in:
        taskId: ${decision_task_id}
        taskGroupId: ${decision_task_id}  # Must be explicit because of Chain of Trust
        created: {$fromNow: ''}
        deadline: {$fromNow: '2 hours'}
        expires: ${expires_in}
        schedulerId: ${scheduler_id}    # Must be explicit because of Chain of Trust
        provisionerId: aws-provisioner-v1
        workerType: gecko-focus   # This workerType has ChainOfTrust enabled
        requires: all-completed   # Must be explicit because of Chain of Trust
        priority: medium
        retries: 5
        scopes:
          - queue:scheduler-id:${scheduler_id}
          - queue:create-task:highest:aws-provisioner-v1/gecko-focus
          - queue:create-task:highest:scriptworker-prov-v1/mobile-signing-v1
          - queue:create-task:highest:scriptworker-prov-v1/mobile-pushapk-v1
          - project:mobile:focus:releng:signing:cert:release-signing
          - project:mobile:focus:releng:signing:format:autograph_focus
          - project:mobile:focus:releng:googleplay:product:focus
          - secrets:get:project/focus/tokens
          - queue:route:index.project.mobile.focus.nightly.latest
        payload:
          maxRunTime: 600   # Decision should remain fast enough to schedule a handful of tasks
          image: mozillamobile/focus-android:1.2
          features:
            taskclusterProxy: true
            chainOfTrust: true
          env:
            TASK_ID: ${decision_task_id}
            SCHEDULER_ID: ${scheduler_id}
            MOBILE_HEAD_REPOSITORY: ${repository}
            MOBILE_HEAD_BRANCH: ${event.release.target_commitish}<commit_msg>Bug 1517732 - Expose routes.statuses because taskcluster-github now adds it<commit_after>version: 1
policy:
  pullRequests: public
tasks:
###############################################################################
# Task: Pull requests
#
# Triggered whenever a pull request is opened or updated.
#
# - Build the app (all flavors)
# - Run unit tests
# - Run code quality tools (spotbugs, lint, checkstyle etc.)
###############################################################################
  - $if: 'tasks_for == "github-pull-request" && event["action"] in ["opened", "reopened", "synchronize"]'
    then:
      created: {$fromNow: ''}
      deadline: {$fromNow: '2 hours'}
      provisionerId: aws-provisioner-v1
      workerType: github-worker
      scopes: []
      routes: []
      payload:
        maxRunTime: 7200
        image: mozillamobile/focus-android:1.2
        command:
          - /bin/bash
          - --login
          - -cx
          - >-
            git fetch ${event.pull_request.head.repo.clone_url} ${event.pull_request.head.ref}
            && git config advice.detachedHead false
            && git checkout ${event.pull_request.head.sha}
            && echo "--" > .adjust_token
            && python tools/l10n/check_locales.py
            && ./gradlew --no-daemon clean assembleFocusX86Debug assembleKlarX86Nightly assembleRelease detektCheck ktlint lintFocusX86Debug lintKlarX86Nightly pmd checkstyle spotbugs assembleFocusX86DebugAndroidTest testFocusX86DebugUnitTest testKlarX86NightlyUnitTest
            && pip install "compare-locales>=5.0.2,<6.0"
            && compare-locales --validate l10n.toml .
        artifacts:
          public:
            type: directory
            path: /opt/focus-android/app/build/reports
            expires: {$fromNow: '1 week'}
      metadata:
        name: Focus for Android - Build - Pull Request
        description: Building Focus for Android (via Gradle) - triggered by a pull request.
        owner: ${event.pull_request.user.login}@users.noreply.github.com
        source: ${event.repository.url}
###############################################################################
# Task: Builds on branches of the main repo
#
# Triggered whenever something is pushed/merged to the mozilla-mobile repo.
# Tags (which are considered to be pushes) are ignored.
#
# Creates the following task pipeline:
#
# Build -+--> Unit tests ----+- UI tests
#         \-> Code quality -/
#
###############################################################################
  - $if: 'tasks_for == "github-push"'
    then:
      $if: 'event.repository.fork == false && event.ref[:10] != "refs/tags/"'
      then:
        taskId: {$eval: as_slugid("decision_task")}
        # The next line won't be needed anymore after https://github.com/taskcluster/taskcluster-github/pull/273
        taskGroupId: {$eval: as_slugid("decision_task")}
        created: {$fromNow: ''}
        deadline: {$fromNow: '2 hours'}
        provisionerId: aws-provisioner-v1
        workerType: github-worker
        routes:
          - 'notify.irc-channel.#android-ci.on-any'
        scopes:
          - queue:create-task:aws-provisioner-v1/github-worker
          - queue:scheduler-id:taskcluster-github
          - secrets:get:project/focus/firebase
          - secrets:get:project/focus/nimbledroid
          - queue:route:notify.irc-channel.#android-ci.on-any
        payload:
          maxRunTime: 7200
          image: mozillamobile/focus-android:1.2
          features:
            taskclusterProxy: true
          env:
            TASK_ID: {$eval: as_slugid("decision_task")}
            MOBILE_HEAD_REPOSITORY: ${event.repository.clone_url}
            MOBILE_HEAD_BRANCH: ${event.ref}
            MOBILE_HEAD_REV: ${event.after}
          command:
            - /bin/bash
            - --login
            - -cx
            - >-
              git fetch origin
              && git config advice.detachedHead false
              && git checkout ${event.after}
              && python tools/taskcluster/schedule-master-build.py
          artifacts:
            public:
              type: directory
              path: /opt/focus-android/test_artifacts
              expires: {$fromNow: '1 week'}
        metadata:
          name: (Focus for Android) Schedule tasks
          description: Scheduling tasks for master push
          owner: <EMAIL>
          source: ${event.repository.url}
###############################################################################
# Task: Release builds
#
# Triggered when a new GitHub release is created (in any branch)
#
# - Builds release versions of Focus and Klar
# - Signs the builds with the release key
# - Uploads the builds to the "alpha" track on Google Play
###############################################################################
  - $if: 'tasks_for == "github-release"'
    then:
      $let:
        decision_task_id: {$eval: as_slugid("decision_task")}
        expires_in: {$fromNow: '1 year'}
        repository: https://github.com/mozilla-mobile/focus-android
        scheduler_id: taskcluster-github
      in:
        taskId: ${decision_task_id}
        taskGroupId: ${decision_task_id}  # Must be explicit because of Chain of Trust
        created: {$fromNow: ''}
        deadline: {$fromNow: '2 hours'}
        expires: ${expires_in}
        schedulerId: ${scheduler_id}   # Must be explicit because of Chain of Trust
        provisionerId: aws-provisioner-v1
        workerType: gecko-focus   # This workerType has ChainOfTrust enabled
        requires: all-completed   # Must be explicit because of Chain of Trust
        priority: highest
        retries: 5
        scopes:
          - queue:scheduler-id:${scheduler_id}
          - queue:create-task:highest:aws-provisioner-v1/gecko-focus
          - queue:create-task:highest:scriptworker-prov-v1/mobile-signing-v1
          - queue:create-task:highest:scriptworker-prov-v1/mobile-pushapk-v1
          - project:mobile:focus:releng:signing:cert:release-signing
          - project:mobile:focus:releng:signing:format:autograph_focus
          - project:mobile:focus:releng:googleplay:product:focus
          - secrets:get:project/focus/tokens
          - queue:route:index.project.mobile.focus.release.latest
        routes:
          - statuses  # Automatically added by taskcluster-github. It must be explicit because of Chain of Trust
        payload:
          maxRunTime: 600   # Decision should remain fast enough to schedule a handful of tasks
          image: mozillamobile/focus-android:1.2
          features:
            taskclusterProxy: true
            chainOfTrust: true
          env:
            TASK_ID: ${decision_task_id}
            SCHEDULER_ID: ${scheduler_id}
            MOBILE_HEAD_REPOSITORY: ${repository}
            MOBILE_HEAD_BRANCH: ${event.release.target_commitish}
            MOBILE_HEAD_REV: ${event.release.tag_name}
            MOBILE_TRIGGERED_BY: ${event.sender.login}
          command:
            - /bin/bash
            - --login
            - -cx
            - >-
              git fetch origin --tags
              && git config advice.detachedHead false
              && git checkout ${event.release.tag_name}
              && python tools/taskcluster/release.py \
                --tag ${event.release.tag_name} \
                --track alpha \
                --commit \
                --output /opt/focus-android/app/build/outputs/apk \
                --apk focusX86/release/app-focus-x86-release-unsigned.apk \
                --apk klarX86/release/app-klar-x86-release-unsigned.apk \
                --apk focusArm/release/app-focus-arm-release-unsigned.apk \
                --apk klarArm/release/app-klar-arm-release-unsigned.apk
          artifacts:
            public/task-graph.json:
              type: file
              path: /opt/focus-android/task-graph.json
              expires: ${expires_in}
            public/actions.json:
              type: file
              path: /opt/focus-android/actions.json
              expires: ${expires_in}
            public/parameters.yml:
              type: file
              path: /opt/focus-android/parameters.yml
              expires: ${expires_in}
        extra:
            tasks_for: ${tasks_for}
        metadata:
          name: (Focus for Android) Decision task (${event.release.tag_name})
          description: Scheduling tasks for releasing Focus/Klar
          owner: ${<EMAIL>
          source: ${repository}/raw/${event.release.tag_name}/.taskcluster.yml
# Nighly builds
  - $if: 'tasks_for == "cron"'
    then:
      $let:
        decision_task_id: {$eval: as_slugid("decision_task")}
        expires_in: {$fromNow: '1 year'}
        repository: https://github.com/mozilla-mobile/focus-android
        scheduler_id: focus-nightly-sched
      in:
        taskId: ${decision_task_id}
        taskGroupId: ${decision_task_id}  # Must be explicit because of Chain of Trust
        created: {$fromNow: ''}
        deadline: {$fromNow: '2 hours'}
        expires: ${expires_in}
        schedulerId: ${scheduler_id}    # Must be explicit because of Chain of Trust
        provisionerId: aws-provisioner-v1
        workerType: gecko-focus   # This workerType has ChainOfTrust enabled
        requires: all-completed   # Must be explicit because of Chain of Trust
        priority: medium
        retries: 5
        scopes:
          - queue:scheduler-id:${scheduler_id}
          - queue:create-task:highest:aws-provisioner-v1/gecko-focus
          - queue:create-task:highest:scriptworker-prov-v1/mobile-signing-v1
          - queue:create-task:highest:scriptworker-prov-v1/mobile-pushapk-v1
          - project:mobile:focus:releng:signing:cert:release-signing
          - project:mobile:focus:releng:signing:format:autograph_focus
          - project:mobile:focus:releng:googleplay:product:focus
          - secrets:get:project/focus/tokens
          - queue:route:index.project.mobile.focus.nightly.latest
        routes:
          - statuses  # Automatically added by taskcluster-github. It must be explicit because of Chain of Trust
        payload:
          maxRunTime: 600   # Decision should remain fast enough to schedule a handful of tasks
          image: mozillamobile/focus-android:1.2
          features:
            taskclusterProxy: true
            chainOfTrust: true
          env:
            TASK_ID: ${decision_task_id}
            SCHEDULER_ID: ${scheduler_id}
            MOBILE_HEAD_REPOSITORY: ${repository}
            MOBILE_HEAD_BRANCH: ${event.release.target_commitish}
{'fraction_non_alphanumeric': 0.14508220363426594, 'fraction_numerical': 0.00841265262955485, 'mean_word_length': 2.231283007145076, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 22, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1496670', 'n_tokens_mistral': 6070, 'n_tokens_neox': 5828, 'n_words': 1269}