---
# Suggested tools that can save round-trips to github and a lot of time:
#
# yamllint .travis.yml
# ~/.gem/ruby/2.7.0/bin/travis lint .travis.yml
# yaml merge-expand .travis.yml exp.yml && diff -b -u .travis.yml exp.yml

language: c
# Ubuntu 20.04 LTS
dist: focal

git:
  depth: false

services:
  - docker

# We don't need the strict sequence of stages; for now we use stages
# only as presentation labels. Nothing in stage "tests" will run if
# anything in buildonly fails; in the future we may want to get rid of
# stages.
stages:
  - buildonly
  - tests


# 'name:'-less jobs appear with their env, e.g.: PLATFORM=tgl
jobs:
  include:

    # stage buildonly

    - &build-platform
      stage: buildonly
      before_install:
        &docker-pull-sof
        docker pull thesofproject/sof && docker tag thesofproject/sof sof
      script:
        ./scripts/docker-run.sh ./scripts/xtensa-build-all.sh -r $PLATFORM
      env: PLATFORM='jsl'

    - <<: *build-platform
      env: PLATFORM='sue'

    - <<: *build-platform
      env: PLATFORM='tgl'

    - <<: *build-platform
      env: PLATFORM='tgl-h'

    - name: "./scripts/build-tools.sh Release"
      before_install: *docker-pull-sof
      script: CMAKE_BUILD_TYPE=Release ./scripts/docker-run.sh ./scripts/build-tools.sh

    # stage tests

    - &qemuboottest
      stage: tests
      script:
        - echo CONFIG_HAVE_AGENT=n > src/arch/xtensa/configs/override/no-agent.config
        - ./scripts/docker-run.sh ./scripts/xtensa-build-all.sh -o no-agent -r $PLATFORM
        - ./scripts/docker-qemu.sh ../sof.git/scripts/qemu-check.sh $PLATFORM
      env: PLATFORM='byt cht'
      before_install:
        - *docker-pull-sof
        - docker pull thesofproject/sofqemu &&
            docker tag thesofproject/sofqemu sofqemu

    - <<: *qemuboottest
      env: PLATFORM='bdw hsw'

    - <<: *qemuboottest
      env: PLATFORM='apl skl kbl'

    - <<: *qemuboottest
      env: PLATFORM='cnl icl'

    - <<: *qemuboottest
      env: PLATFORM='imx8 imx8x imx8m'


    - name: testbench
      before_install: *docker-pull-sof
      script:
        # testbench needs some topologies
        - ./scripts/docker-run.sh ./scripts/build-tools.sh -t
        - ./scripts/docker-run.sh ./scripts/rebuild-testbench.sh
        - ./scripts/host-testbench.sh


    - name: doxygen

      before_install: sudo apt-get -y install ninja-build doxygen graphviz

      script:

        # Show ALL warnings. Warnings don't cause doxygen to fail (yet).
        - mkdir -p doxybuild && pushd doxybuild && cmake -GNinja -S ../doc &&
             ninja -v doc
        - popd

        # Build again (it's very quick) and report a failure in Travis if
        # any issue. This time doxygen stops on the first issue.
        - printf 'WARN_AS_ERROR = YES\n' >> doc/sof.doxygen.in
        - ninja -C doxybuild -v doc

notifications:
  irc:
    channels:
      - "chat.freenode.net#sof"
    on_success: always
    on_failure: always
