default:
  tags:
    - pipeline

stages:
  - download_prerequisites
  - monitor

workflow:
  rules:
    - if: '$CI_COMMIT_BRANCH == "main"'
      when: always
    - when: never

download_prerequisites:
  image: public.ecr.aws/tuxsuite/tuxsuite:latest
  stage: download_prerequisites
  script:
    - curl -fsSOL https://raw.githubusercontent.com/Linaro/squad-client-utils/master/squad-show-or-cancel-jobs
    - chmod +x squad-show-or-cancel-jobs
  needs: []
  artifacts:
    paths:
      - squad-show-or-cancel-jobs
    when: always

monitor:
  image: squadproject/squad-report:latest
  stage: monitor
  variables:
    DAYS: 15
  script:
    - apt update && apt install -y python3-pip
    - pip install squad-client
    - ./squad-show-or-cancel-jobs --group ${QA_GROUP} --project inux-mainline-master --days=${DAYS}

  artifacts:
    paths:
      - ${CI_PROJECT_DIR}/latest-checked-sha.txt
    when: always
  needs:
    - job: download_prerequisites
      artifacts: true
