# stage description
# generate
#  creates the actual test jobs via python script
# run-tests
#  execute the generated test jobs
#  the ordering is mainly random
#  the python generator can schedule some jobs on specific positions

stages:
  - generator
  - run-test-jobs


variables:
  # container version of the generated jobs
  # should be merged with ALPAKA_GITLAB_CI_CONTAINER_VERSION
  # see: script/job_generator/generate_job_yaml.py
  ALPAKA_GITLAB_CI_GENERATOR_CONTAINER_VERSION: "3.0"

generate:
  stage: generator
  image: alpine:latest
  script:
    - apk update && apk add python3~=3.10 py3-pip
    - pip3 install -r script/job_generator/requirements.txt
    - python3 script/job_generator/job_generator.py ${ALPAKA_GITLAB_CI_GENERATOR_CONTAINER_VERSION} --compile-only -o compile_only.yml
    - python3 script/job_generator/job_generator.py ${ALPAKA_GITLAB_CI_GENERATOR_CONTAINER_VERSION} --runtime-only -o runtime.yml
    - cat compile_only.yml
    - cat runtime.yml
  artifacts:
    paths:
      - compile_only.yml
      - runtime.yml
    expire_in: 1 week
  interruptible: true

run-compile-only-test:
  stage: run-test-jobs
  trigger:
    include:
      - artifact: compile_only.yml
        job: generate
    strategy: depend

run-runtime-test:
  stage: run-test-jobs
  trigger:
    include:
      - artifact: runtime.yml
        job: generate
    strategy: depend
