### Lab 0
prebuild_lab_0:
  stage: lab0
  script:
    - |
      # Check if lab0.cpp exists
      if [ ! -f "lab0.cpp" ]; then
        echo "lab0.cpp does not exist";
        exit 1;
      fi
      
      # Check if lab-1.cpp has been merged into master
      git fetch origin master  # Fetch the latest master branch
      if git ls-tree -r origin/master --name-only | grep -q 'lab-1.cpp'; then
        echo "Lab -1 complete";
      else
        echo "Please complete lab -1 first";
        exit 1;
      fi
    - git clone https://agile.bu.edu/gitlab/configs/ec327/lab-configs/current.git base_0
  artifacts:
    paths:
      - base_0
  rules:
    - changes:
        - lab0.cpp
  tags: [c++-17]

compile_lab_0:
  stage: lab0
  script:
    - echo "Compiling lab0.cpp"
    - g++ -c lab0.cpp
  artifacts:
    paths:
      - base_0
  rules:
    - changes:
        - lab0.cpp
  dependencies:
    - prebuild_lab_0
  tags: [c++-17]

lint_lab_0:
  stage: lab0
  script:
    - echo "Static code check of lab0.cpp"
    - cppcheck --check-config --enable=all --inconclusive --error-exitcode=1 lab0.cpp tests/LabZero.cpp
  allow_failure: false
  artifacts:
    paths:
      - base_0
  rules:
    - changes:
        - lab0.cpp
  dependencies:
    - prebuild_lab_0
  tags: [cppcheck]

test_lab_0:
  stage: lab0
  script:
    - echo "Testing Lab 0";
    - git clone https://agile.bu.edu/gitlab/configs/ec327/lab-configs/current.git base_0
    - cp lab0.cpp base_0/tests
    - cd base_0/tests
    - make lab0
  rules:
    - changes:
        - lab0.cpp
  dependencies:
    - compile_lab_0
  tags: [c++-17]