- job:
    name: lite-tf-m
    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
            paul.sokolovsky@linaro.org:
                - job-build
                - job-read
                - job-extended-read
                - job-configure
                - job-cancel
        - build-discarder:
            days-to-keep: 30
            num-to-keep: 30
            artifact-num-to-keep: 30
        - throttle:
            option: category
            categories: [lite-zephyr]
            matrix-builds: false
            matrix-configs: true
    parameters:
        - string:
            name: BRANCH
            default: 'master'
        - string:
            name: GIT_COMMIT
            default: 'd3c5cd90d792'
        - string:
            name: LAVA_SERVER
            default: 'validation.linaro.org/RPC2/'
        - string:
            name: QA_SERVER
            default: 'https://qa-reports.linaro.org'
        - string:
            name: QA_SERVER_GROUP
            default: 'lite'
        - string:
            name: QA_SERVER_PROJECT
            default: 'lite-tf-m'
        - string:
            name: USE_QA_SERVER
            default: '1'
    disabled: true
    node: master
    child-workspace: .
    display-name: 'DELETE ME'
    triggers:
        - timed: 'H 5 * * *'
    axes:
        - axis:
            type: slave
            name: label
            values:
                - docker-focal-amd64-lite
        - axis:
            type: user-defined
            name: ZEPHYR_TOOLCHAIN_VARIANT
            values:
                - gnuarmemb
        - axis:
            type: user-defined
            name: PLATFORM
            values:
                - AN521
    wrappers:
        - timestamps
        - credentials-binding:
            - text:
                credential-id: LAVA_USER
                variable: LAVA_USER
        - credentials-binding:
            - text:
                credential-id: LAVA_TOKEN
                variable: LAVA_TOKEN
        - credentials-binding:
            - text:
                credential-id: QA_REPORTS_TOKEN
                variable: QA_REPORTS_TOKEN
    builders:
        - shell: |
            rm -rf job-configs
            git clone --depth 1 https://git.linaro.org/ci/job/configs.git job-configs
        - shell: |
            ./job-configs/lite-tf-m/install-deps.sh
        - shell: |
            ./job-configs/lite-tf-m/build.sh
        - inject:
            properties-file: env_var_parameters
#        - build-name-setter:
#            template: '#${BUILD_NUMBER}-${GIT_COMMIT_ID}'
#            macro: true
        - linaro-publish-token
        - shell: |
            #!/bin/bash

            # Publish. Need to publish out of a directory to make files publicly accessible.
            test -d ${HOME}/bin || mkdir ${HOME}/bin
            wget -q https://git.linaro.org/ci/publishing-api.git/blob_plain/HEAD:/linaro-cp.py -O ${HOME}/bin/linaro-cp.py
            time python3 ${HOME}/bin/linaro-cp.py \
              --api_version 3 \
              --link-latest \
              out/ components/kernel/aeolus-2/tf-m/${BRANCH}/${PLATFORM}/${BUILD_NUMBER}

        - shell: |
            #!/bin/bash -ex

            rm -rf configs
            git clone --depth 1 https://git.linaro.org/ci/job/configs.git
            git clone --depth 1 https://github.com/pfalcon/lite-build-tools
            ./configs/lite-tf-m/submit-test.sh

#    publishers:
#        - email:
#            recipients: 'paul.sokolovsky@linaro.org'
