Commit f96458b4 authored by James Knee's avatar James Knee
Browse files

lab5 CI pipeline

parent ea0ac96e
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ stages:
  - lab2
  - lab3
  - lab4
  - lab5
  - tests

include:
@@ -14,3 +15,4 @@ include:
  - local: 'ci_cd/lab2.yml'    # Lab 2
  - local: 'ci_cd/lab3.yml'    # Lab 3
  - local: 'ci_cd/lab4.yml'    # Lab 4
  - local: 'ci_cd/lab5.yml'    # Lab 5
 No newline at end of file

ci_cd/lab5.yml

0 → 100644
+98 −0
Original line number Diff line number Diff line
### Lab 5
prebuild_lab_5:
  stage: lab5
  script:
    - echo "Changes Detected (if any):";
    - git diff --name-only $CI_COMMIT_SHA~ $CI_COMMIT_SHA || echo "No changes found";
    - FILES_ADDED=$(git diff --name-only --diff-filter=A HEAD~1 | wc -l)
    - |
    
      # Check if lab5.cpp exists
      if [ ! -f "lab5.cpp" ]; then
        echo "lab5.cpp does not exist";
        exit 1;
      fi

      # Check that only one file was checked in
      if [ "FILES_ADDED" -ne 1 ]; then
        echo "Error: Only one file should be committed.";
        exit 1;
      fi
      
      # Check if lab4.cpp has been merged into master
      if git ls-tree -r origin/master --name-only | grep -q 'lab4.cpp'; then
        echo "Lab 4 complete";
      else
        echo "Please have lab 4 merged first";
        exit 1;
      fi
    - git clone https://agile.bu.edu/gitlab/configs/ec327/lab-configs/current.git base_5
  artifacts:
    paths:
      - base_5
  rules:
    - if: '$CI_COMMIT_REF_NAME == "lab5"'
  tags: [c++-17]

prebuild_lab_5_SKIP:
  stage: lab5
  script:
    - echo "SKIPPING Lab 5 checks because the branch name is not 'lab5'"
  rules:
    - if: '$CI_COMMIT_REF_NAME != "lab5"'
  tags: [c++-17]

compile_lab_5:
  stage: lab5
  script:
    - echo "Compiling lab5.cpp"
    - g++ -c lab5.cpp
  artifacts:
    paths:
      - base_5
  dependencies:
    - prebuild_lab_5
  rules:
    - if: '$CI_COMMIT_REF_NAME == "lab5"'
  tags: [c++-17]

lint_lab_5:
  stage: lab5
  script:
    - echo "Static code check of lab5.cpp"
    - cppcheck --check-config --enable=all --inconclusive --error-exitcode=1 lab5.cpp tests/LabFive.cpp
  allow_failure: false
  artifacts:
    paths:
      - base_5
  dependencies:
    - prebuild_lab_5
  rules:
    - if: '$CI_COMMIT_REF_NAME == "lab5"'
  tags: [cppcheck]

test_lab_5:
  stage: lab5
  script:
    - echo "Testing Lab 5";
    - git clone https://agile.bu.edu/gitlab/configs/ec327/lab-configs/current.git base_5
    - cp lab5.cpp base_5/tests
    - cd base_5/tests
    - make lab5
  dependencies:
    - compile_lab_5
  rules:
    - if: '$CI_COMMIT_REF_NAME == "lab5"'
  tags: [c++-17]

# trigger internal tests only upon a merge request into master
internal_tests_lab_5:
 stage: tests
 script:
   - git clone https://trachten-gitlab:$INTERNAL_LAB_TESTS@agile.bu.edu/gitlab/ec327/ec327-staff/lab-tests.git
   - cp -f lab5.cpp lab-tests/internal_tests/
   - cd lab-tests/internal_tests
   - make lab5
 rules:
   - if: '$CI_COMMIT_REF_NAME == "lab5" && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"'
 tags: [ c++-17 ]