- job:
    name: zephyr-net
    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: 'main'
        - string:
            name: GIT_COMMIT
            default: 'HEAD'
        - 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: 'zephyr-net'
        - string:
            name: USE_QA_SERVER
            default: '1'
        - string:
            name: CCACHE_CTRL
            default: ''
#        - string:
#            name: TWISTER_EXTRA
#            default: '--testsuite-root samples/net/sockets/dumb_http_server'
    disabled: false
    node: master
    child-workspace: .
    display-name: "Zephyr networking tests"
    triggers:
        - timed: 'H H/12 * * *'
    axes:
        - axis:
            type: slave
            name: label
            values:
                - docker-focal-amd64-lite
        - axis:
            type: user-defined
            name: ZEPHYR_TOOLCHAIN_VARIANT
            values:
#                - gnuarmemb
                - zephyr
        - axis:
            type: user-defined
            name: PLATFORM
            values:
                # - 96b_carbon
                # - 96b_nitrogen
                # - arduino_101
                # - arduino_101_ble
                # - arduino_due
                # - bbc_microbit
                # - cc3200_launchxl
                # - cc3220sf_launchxl
                # - disco_l475_iot1
                - frdm_k64f
                # - frdm_kw41z
    execution-strategy:
        combination-filter: |
             ZEPHYR_TOOLCHAIN_VARIANT=="zephyr" || (ZEPHYR_TOOLCHAIN_VARIANT=="gnuarmemb" && !(PLATFORM=="arduino_101" || PLATFORM=="qemu_x86"))
    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:
            !include-raw: lite-common/header.sh
        - shell:
            !include-raw: lite-common/install-toolchains.sh
        - shell: |
            echo TWISTER_EXTRA="--testsuite-root samples/net/sockets/dumb_http_server --testsuite-root samples/net/sockets/dumb_http_server_mt -x=BUILD_VERSION=ci_build_version" >env_var_parameters
        - inject:
            properties-file: env_var_parameters
        - shell:
            !include-raw: zephyr-net/builders.sh
        - inject:
            properties-file: env_var_parameters
        - build-name-setter:
            template: '#${BUILD_NUMBER}-${GIT_COMMIT_ID}'
            macro: true
        - linaro-publish-token
        - inject:
            properties-file: env_var_parameters
        - shell: |
            #!/bin/bash

            # Publish
            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/${PLATFORM} components/kernel/zephyr-net/${BRANCH}/${ZEPHYR_TOOLCHAIN_VARIANT}/${PLATFORM}/${BUILD_NUMBER}

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

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

#    publishers:
#        - email:
#            recipients: 'first.last@linaro.org'
