- job:
    name: ledge-ts
    project-type: matrix
    defaults: global
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
                - job-workspace
            everyone-flat:
                - job-read
                - job-extended-read
                - job-build
                - job-cancel
        - build-discarder:
            days-to-keep: 90
            num-to-keep: 10
    parameters:
        - string:
            name: GIT_URL
            default: 'https://git.codelinaro.org/linaro/dependable-boot/meta-ts.git'
        - string:
            name: GIT_BRANCH
            default: 'master'
        - string:
            name: PUB_DEST
            default: 'components/ledge/ts/${BUILD_NUMBER}/${MACHINE}/'
        - string:
            name: LAVA_SERVER
            default: 'ledge.validation.linaro.org/RPC2/'
        - string:
            name: QA_SERVER
            default: 'https://qa-reports.linaro.org'
        - string:
            name: QA_SERVER_PROJECT
            default: 'ledge'
        - string:
            name: QA_SERVER_TEAM
            default: 'ledge'
        - string:
            name: AUTH_GROUPS
            default: 'linaro'
        - string:
            name: BB_CLEANALL_PKGS
            default: ''
    disabled: false
    node: master
    display-name: 'Trusted Substrate build'
    axes:
        - axis:
            type: user-defined
            name: MACHINE
            values:
                - 'qemuarm64-secureboot'
                - 'synquacer'
                - 'stm32mp157c-dk2'
                - 'stm32mp157c-ev1'
                - 'rpi4'
                - 'rockpi4b'
                - 'zynqmp-starter'
        - axis:
            type: user-defined
            name: DISTRO
            values:
                - rpb
        - axis:
            type: slave
            name: label
            values:
                - docker-buster-amd64
    execution-strategy:
        sequential: false
    wrappers:
        - timeout:
            timeout: 400
        - timestamps
        - ssh-agent-credentials:
            users:
                - 'OE_COMMIT_BOT_KEY'
        - credentials-binding:
            - text:
                credential-id: QA_REPORTS_TOKEN
                variable: QA_REPORTS_TOKEN
    builders:
        - shell: |
            #!/bin/bash

            # Mapping for MACHINE -> DEVICE_TYPE
            case "${MACHINE}" in
              ledge-ti-am572x)
                DEVICE_TYPE=x15-bl_uefi
                ;;
              ledge-qemux86-64)
                DEVICE_TYPE=qemux86_64uefi
                ;;
              ledge-qemuarm)
                DEVICE_TYPE=qemuarmuefi
                ;;
              qemuarm64-secureboot)
                DEVICE_TYPE=qemuarm64uefi
                ;;
              ledge-synquacer)
                DEVICE_TYPE=synquacer
                ;;
              ledge-stm32mp157c-dk2)
                DEVICE_TYPE=stm32mp157c-dk2
                ;;
              *)
                echo "Skip DEVICE_TYPE for ${MACHINE}"
                ;;
            esac

            echo "DEVICE_TYPE=${DEVICE_TYPE}" > device_type_parameters
        - inject:
            properties-file: device_type_parameters
        - shell:
            !include-raw: ledge/ts/builders.sh
        - inject:
            properties-file: post_build_lava_parameters
        - linaro-publish-token
        - shell:
            !include-raw: rpb-openembedded/publishers.sh
        - shell:
            !include-raw: ledge/ts/submit_for_testing.sh
    publishers:
        - groovy-postbuild:
            script:
                !include-raw:
                  - openembedded-lkft/postbuild.groovy
        - email:
            recipients: 'maxim.uvarov@linaro.org ilias.apalodimas@linaro.org'
