diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 64b372da1c3f8fc7e9e12173dd274a3d421db08c..8bd0ae3ffb39afb352316d0953e6b36af7545b34 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,34 +16,63 @@ # This specific template is located at: # https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml -stages: # List of stages for jobs, and their order of execution - - build - - test - - deploy - -build-job: # This job runs in the build stage, which runs first. +include: +- template: Jobs/SAST.gitlab-ci.yml +- template: Security/Dependency-Scanning.gitlab-ci.yml +cache: + paths: + - ".m2/repository" +variables: + MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository" +stages: +- build +- test +- package +build-musicmanager: stage: build + image: maven:3.8-openjdk-18 script: - - echo "Compiling the code..." - - echo "Compile complete." - -unit-test-job: # This job runs in the test stage. - stage: test # It only starts when the job in the build stage completes successfully. + - echo 'Starting Build Stage' + - mvn compile +test-musicmanager: + stage: test + image: maven:3.8-openjdk-18 + services: + - mariadb + - mongo + variables: + MYSQL_ROOT_PASSWORD: ultr4_s4ve_pwd + MYSQL_DATABASE: musicmanagerdb + MYSQL_USER: musicmanageruser + MONGO_INITDB_ROOT_USERNAME: musicmanageruser + MONGO_INITDB_ROOT_PASSWORD: sup3r_s4ve_pwd 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." - -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 + - echo 'Starting Test Stage' + - mvn test -Dtest='!NoSqlManagerTest,!SqlDbManagerTest, !AudioTrackApiControllerTest' + artifacts: + reports: + junit: + - target/surefire-reports/TEST-*.xml + - target/failsafe-reports/TEST-*.xml +package-musicmanager: + stage: package + image: maven:3.8-openjdk-18 + services: + - mariadb + - mongo + variables: + MYSQL_ROOT_PASSWORD: ultr4_s4ve_pwd + MYSQL_DATABASE: musicmanagerdb + MYSQL_USER: musicmanageruser + MONGO_INITDB_ROOT_USERNAME: musicmanageruser + MONGO_INITDB_ROOT_PASSWORD: sup3r_s4ve_pwd script: - - echo "Deploying application..." - - echo "Application successfully deployed." + - echo 'Starting Package Stage' + - mvn package -Dtest='!NoSqlManagerTest,!SqlDbManagerTest, !AudioTrackApiControllerTest' + only: + refs: + - main + artifacts: + paths: + - target/*.jar + expire_in: 2 days