before_script:
  - "source ~gitlab-runner/cicd_support/cicd_support.shinc" 


after_script:
  - "echo Test Complete."

stages:
  - clean
  - build
  - protect_bins
  - test
  - deploy


#
# Cleaning
#
.do-nightly-clean: &do-nightly-clean
  stage: clean
  script:
    - ./cicd_testing/do-clean.sh 

# per os items
do-nightly-clean-ubuntu18:
  <<: *do-nightly-clean
  tags:
    - ubuntu18

# per os items
do-nightly-clean-ubuntu16:
  <<: *do-nightly-clean
  tags:
    - ubuntu16

# per os items
do-nightly-clean-centos76:
  <<: *do-nightly-clean
  tags:
    - centos76

do-nightly-clean-arm32:
  <<: *do-nightly-clean
  tags:
    - arm32

do-nightly-clean-arm64:
  <<: *do-nightly-clean
  tags:
    - arm64

do-nightly-clean-ubuntu20:
  <<: *do-nightly-clean
  tags:
    - ubuntu20


#
# Building
#
# template
.do-build: &do-build
  stage: build
  script:
    - ./cicd_testing/do-build.sh


# per os items
do-build-ubuntu18:
  <<: *do-build
  tags:
    - ubuntu18

do-build-ubuntu16:
  <<: *do-build
  tags:
    - ubuntu16

do-build-centos76:
  <<: *do-build
  tags:
    - centos76

do-build-arm32:
  <<: *do-build
  tags:
    - arm32

do-build-arm64:
  <<: *do-build
  tags:
    - arm64

do-build-ubuntu20:
  <<: *do-build
  tags:
    - ubuntu20


#
# gather artifacts and ship them tox 86 boxes
#
.gather-bins: &do_gather
        stage: build
        script:
            - ./cicd_testing/do-gather-bins.sh
        artifacts:               
            expire_in: 1 day
            paths:
                - artifacts/

gather-bins-arm32:
        <<: *do_gather
        tags:
            - arm32

gather-bins-arm64:
        <<: *do_gather
        tags:
            - arm64

#
# gather artifacts and ship them tox 86 boxes
#
.protect-arm-bins: &prot_bins
        stage: protect_bins
        script:
            - ./cicd_testing/do-prot-bins.sh
        artifacts:               
            expire_in: 1 day
            paths:
                - artifacts/

protect-arm-ubuntu18:
        <<: *prot_bins
        tags:
            - ubuntu18

protect-bins-ubuntu16:
        <<: *prot_bins
        tags:
            - ubuntu16

#
# gather artifacts and ship them tox 86 boxes
#
.test_arm_bins: &test_arm_bins
        stage: test
        script:
            - ./cicd_testing/do-test-bins.sh
        artifacts:               
            expire_in: 1 day
            paths:
                - artifacts/

test-bins-arm32:
        <<: *test_arm_bins
        tags:
            - arm32

test-bins-arm64:
        <<: *test_arm_bins
        tags:
            - arm64


#
# test_quick for EH handling
#
.basic_eh_tests: &basic_eh-tests
  stage: test
  script:
    - ./cicd_testing/eh-tests.sh

basic_eh-tests-ubuntu18:
  <<: *basic_eh-tests
  tags:
    - ubuntu18

basic_eh-tests-ubuntu16:
  <<: *basic_eh-tests
  tags:
    - ubuntu16

basic_eh-tests-centos76:
  <<: *basic_eh-tests
  tags:
    - centos76

basic_eh-tests-ubuntu20:
  <<: *basic_eh-tests
  tags:
    - ubuntu20

#
# test_cmds.sh fixcalls
#
.builtin-xforms: &builtin-xforms
  stage: test
  script:
    - ./cicd_testing/builtin-xforms.sh

builtin-xforms-ubuntu18:
  <<: *builtin-xforms
  tags:
    - ubuntu18

builtin-xforms-ubuntu16:
  <<: *builtin-xforms
  tags:
    - ubuntu16

builtin-xforms-centos76:
  <<: *builtin-xforms
  tags:
    - centos76

builtin-xforms-ubuntu20:
  <<: *builtin-xforms
  tags:
    - ubuntu20


# doesn't work yet
#builtin-xforms-arm32:
#  <<: *builtin-xforms
#  tags:
#    - arm32

builtin-xforms-arm64:
  <<: *builtin-xforms
  tags:
    - arm64


#
# elfdep test
#

# template
.elfdep: &elfdep
  stage: test
  script:
    - ./cicd_testing/elfdep.sh

elfdep-ubuntu18:
  <<: *elfdep
  tags:
    - ubuntu18
    
elfdep-ubuntu16:
  <<: *elfdep
  tags:
    - ubuntu16

elfdep-centos76:
  <<: *elfdep
  tags:
    - centos76
elfdep-ubuntu20:
  <<: *elfdep
  tags:
    - ubuntu20


#
# deploy a docker image
#
deploy-u18:
  stage: deploy
  script:
    - ./cicd_testing/deploy.sh
  tags:
    - ubuntu18
