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


after_script:
  - "echo Test Complete."

stages:
  - gather
  - build
  - cross-protect
  - test
  - deploy



#
# gather artifacts and ship them to x86 boxes
#
.gather-bins: &do_gather
        stage: gather
        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

#
# protect gathered arm binaries on an x86 box.
#
.protect-arm-bins: &prot_bins
        needs: [gather-bins-arm32, gather-bins-arm64]
        stage: cross-protect
        script:
            - ./cicd_testing/do-clean.sh 
            - ./cicd_testing/do-build.sh
            - ./cicd_testing/do-prot-bins.sh
        artifacts:               
            expire_in: 1 day
            paths:
                - artifacts/

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

#
# Test the cross-protected binaries.
#
.test_arm_bins: &test_arm_bins
        needs: [protect-arm-ubuntu22]
        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

#
# Cleaning, build, test for x86 on various OSes
#
.test: &test
  needs: []
  stage: test
  script:
    - ./cicd_testing/do-clean.sh 
    - ./cicd_testing/do-build.sh
    - ./cicd_testing/libc_test.sh
    - ./cicd_testing/eh-tests.sh
    - ./cicd_testing/builtin-xforms.sh
    - ./cicd_testing/elfdep.sh
    - ./cicd_testing/go_tests.sh
    - ./cicd_testing/rust_tests.sh



test-arm32: 
  needs: []
  stage: test
  script:
    - ./cicd_testing/do-clean.sh 
    - ./cicd_testing/do-build.sh
  tags:
    - arm32

test-arm64: 
    needs: []
    stage: test
    script:
      - ./cicd_testing/do-clean.sh 
      - ./cicd_testing/do-build.sh
      - ./cicd_testing/builtin-xforms.sh
    tags:
      - arm64
      
# per os items
test-coss9:
  <<: *test
  tags:
    - coss9

test-ubuntu20:
  <<: *test
  tags:
    - ubuntu20

test-ubuntu22:
  <<: *test
  tags:
    - ubuntu22


#
# deploy a docker image
#
deploy-u22:
  needs: [test-coss9,  test-ubuntu20, test-ubuntu22, test-arm32, test-arm64, test-bins-arm32, test-bins-arm64]
  stage: deploy
  script:
    - ./cicd_testing/do-clean.sh 
    - ./cicd_testing/do-build.sh
    - ./cicd_testing/deploy.sh
  tags:
    - ubuntu22
