stages:
  - Prepare
  - Environment
  - Build_and_Test

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - _gitlab-ci/testdata

before_script:
  - docker info

P_Testdata:
  stage: Prepare
  only:
    - schedules
  script:
    - rm -rf _gitlab-ci/testdata
    - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.kn.e-technik.tu-dortmund.de/falkenberg/falcon-testdata.git _gitlab-ci/testdata

E_Arch:
  stage: Environment
  only:
    - schedules
  script:
    - cd $CI_PROJECT_DIR/_gitlab-ci/docker/Archlinux
    - docker rmi ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/archlinux_base:latest || true
    - docker build --no-cache -t ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/archlinux_base:latest --target archlinux_base --build-arg OS_VERSION=latest .

E_Ubnt20_full:
  stage: Environment
  only:
    - schedules
  script:
    - cd $CI_PROJECT_DIR/_gitlab-ci/docker/Ubuntu
    - docker rmi ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt20_full:latest || true
    - docker build --no-cache -t ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt20_full:latest --build-arg OS_VERSION=focal --build-arg INCLUDE_CMNALIB=true --build-arg INCLUDE_UHD=true --build-arg INCLUDE_LIMESDR=true .

E_Ubnt18_minimal:
  stage: Environment
  only:
    - schedules
  script:
    - cd $CI_PROJECT_DIR/_gitlab-ci/docker/Ubuntu
    - docker rmi ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt18_minimal:latest || true
    - docker build --no-cache -t ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt18_minimal:latest --build-arg OS_VERSION=bionic .

E_Ubnt18_minimal_embed_srslte:
  stage: Environment
  only:
    - schedules
  script:
    - cd $CI_PROJECT_DIR/_gitlab-ci/docker/Ubuntu
    - docker rmi ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt18_minimal_embed_srslte:latest || true
    - docker build --no-cache -t ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt18_minimal_embed_srslte:latest --build-arg OS_VERSION=bionic --build-arg INCLUDE_SRSLTE=false .

E_Ubnt18_cmnalib:
  stage: Environment
  only:
    - schedules
  script:
    - cd $CI_PROJECT_DIR/_gitlab-ci/docker/Ubuntu
    - docker rmi ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt18_cmnalib:latest || true
    - docker build --no-cache -t ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt18_cmnalib:latest --build-arg OS_VERSION=bionic --build-arg INCLUDE_CMNALIB=true .

E_Ubnt18_cmnalib_uhd:
  stage: Environment
  only:
    - schedules
  script:
    - cd $CI_PROJECT_DIR/_gitlab-ci/docker/Ubuntu
    - docker rmi ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt18_cmnalib_uhd:latest || true
    - docker build --no-cache -t ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt18_cmnalib_uhd:latest --build-arg OS_VERSION=bionic --build-arg INCLUDE_CMNALIB=true --build-arg INCLUDE_UHD=true .

E_Ubnt18_uhd:
  stage: Environment
  only:
    - schedules
  script:
    - cd $CI_PROJECT_DIR/_gitlab-ci/docker/Ubuntu
    - docker rmi ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt18_uhd:latest || true
    - docker build --no-cache -t ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt18_uhd:latest --build-arg OS_VERSION=bionic --build-arg INCLUDE_UHD=true .

E_Ubnt18_full:
  stage: Environment
  only:
    - schedules
  script:
    - cd $CI_PROJECT_DIR/_gitlab-ci/docker/Ubuntu
    - docker rmi ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt18_full:latest || true
    - docker build --no-cache -t ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt18_full:latest --build-arg OS_VERSION=bionic --build-arg INCLUDE_CMNALIB=true --build-arg INCLUDE_UHD=true --build-arg INCLUDE_LIMESDR=true .

B_Arch:
  stage: Build_and_Test
  script:
    - docker run --rm -v `pwd`/.:/falcon -v /tmp:/tmp/tmp-host -i ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/archlinux_base:latest /falcon/_gitlab-ci/testscripts/./test_all.sh ~/falcon-build /tmp

B_Ubnt20_full:
  stage: Build_and_Test
  script:
    - docker run --rm -v `pwd`/.:/falcon -v /tmp:/tmp/tmp-host -i ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt20_full:latest /falcon/_gitlab-ci/testscripts/./test_all.sh ~/falcon-build /tmp

B_Ubnt18_minimal:
  stage: Build_and_Test
  script:
    - docker run --rm -v `pwd`/.:/falcon -v /tmp:/tmp/tmp-host -i ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt18_minimal:latest /falcon/_gitlab-ci/testscripts/./test_all.sh ~/falcon-build /tmp

B_Ubnt18_minimal_embed_srslte:
  stage: Build_and_Test
  script:
    - docker run --rm -v `pwd`/.:/falcon -v /tmp:/tmp/tmp-host -i ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt18_minimal_embed_srslte:latest /falcon/_gitlab-ci/testscripts/./test_all.sh ~/falcon-build /tmp

B_Ubnt18_cmnalib:
  stage: Build_and_Test
  script:
    - docker run --rm -v `pwd`/.:/falcon -v /tmp:/tmp/tmp-host -i ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt18_cmnalib:latest /falcon/_gitlab-ci/testscripts/./test_all.sh ~/falcon-build /tmp

B_Ubnt18_cmnalib_uhd:
  stage: Build_and_Test
  script:
    - docker run --rm -v `pwd`/.:/falcon -v /tmp:/tmp/tmp-host -i ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt18_cmnalib_uhd:latest /falcon/_gitlab-ci/testscripts/./test_all.sh ~/falcon-build /tmp

B_Ubnt18_full:
  stage: Build_and_Test
  script:
    - docker run --rm -v `pwd`/.:/falcon -v /tmp:/tmp/tmp-host -i ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/ubnt18_full:latest /falcon/_gitlab-ci/testscripts/./test_all.sh ~/falcon-build /tmp

