# This CI config file is not used in this repository but instead referenced
# from each student project (https://gitlab.epfl.ch/help/ci/pipelines/settings#custom-ci-configuration-path)
# and used to grade them.

workflow:
  rules:
    # Don't run the CI on commit messages contain "[no-ci]", used to deploy
    # assignments without overloading the CI.
    - if: $CI_COMMIT_MESSAGE !~ /\[no-ci\]/

stages:
  - build
  - grade

variables:
  OUTPUT_DIR: "-"

compile:
  stage: build
  timeout: 15m
  image: lampepfl2022/cs206:compile
  tags:
    - cs210
  except:
    - tags
    - master
    - exercise-1
    - exercise-2
    - exercise-3
    - exercise-4
    - exercise-5
    - exercise-6
    - exercise-7
    - exercise-8
  script:
    - sbt packageSubmission
  # Output of this job that needs to be stored to be reused in the grade job below
  artifacts:
    expire_in: 1 day
    paths:
      - submission.jar

grade:
  stage: grade
  timeout: 15m
  except:
    - tags
    - master
    - exercise-1
    - exercise-2
    - exercise-3
    - exercise-4
    - exercise-5
    - exercise-6
    - exercise-7
    - exercise-8
  tags:
    - cs210
  image:
    name: lampepfl2022/cs206:grader-${CI_COMMIT_BRANCH}
    entrypoint: [""]
  allow_failure: true
  before_script:
    - mkdir -p /shared/submission/
    - cp submission.jar /shared/submission/submission.jar
  script:
    - cd /grader
    - /grader/grade
    - grep -q /shared/feedback.json '"fractionalScore": 1.00'
