Skip to content
Snippets Groups Projects

Dev

6 files
+ 298
11
Compare changes
  • Side-by-side
  • Inline

Files

+ 23
11
@@ -16,6 +16,8 @@
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml
image: gcc:7.3.0
stages: # List of stages for jobs, and their order of execution
- build
- test
@@ -25,25 +27,35 @@ build-job: # This job runs in the build stage, which runs first.
stage: build
script:
- echo "Compiling the code..."
- g++ quadratic_equation.cpp test.cpp main.cpp
- echo "Compile complete."
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == 'staging' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'main'
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == 'dev' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'staging'
- if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == 'dev'
unit-test-job: # This job runs in the test stage.
stage: test # It only starts when the job in the build stage completes successfully.
script:
- echo "Running unit tests... This will take about 60 seconds."
- sleep 60
- echo "Code coverage is 90%"
lint-test-job: # This job also runs in the test stage.
stage: test # It can run at the same time as unit-test-job (in parallel).
script:
- echo "Linting code... This will take about 10 seconds."
- sleep 10
- echo "No lint issues found."
- echo "Running unit tests..."
- g++ quadratic_equation.cpp test.cpp main.cpp -o exec_file
- ./exec_file test
- echo "Unit tests complete"
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == 'staging' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'main'
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == 'dev' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'staging'
- if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == 'dev'
deploy-job: # This job runs in the deploy stage.
stage: deploy # It only runs when *both* jobs in the test stage complete successfully.
environment: production
script:
- echo "Deploying application..."
- g++ quadratic_equation.cpp test.cpp main.cpp -o exec_file
- echo "Application successfully deployed."
artifacts:
paths:
- exec_file
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == 'staging' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'main'
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == 'dev' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'staging'
\ No newline at end of file
Loading