diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f73ad4c..fc62202 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,17 +1,61 @@ -code_quality: - image: docker:stable - variables: - DOCKER_DRIVER: overlay2 - allow_failure: true +#Trying to set up the CI, probably won't work +image: gradle:jdk13 + +stages: + - build + - test + - code_quality + - deploy + +#Sets up the docker +smarthut_deploy: + stage: deploy + image: docker:latest services: - - docker:stable-dind + - docker:dind + variables: + DOCKER_DRIVER: overlay + before_script: + - docker version + - docker info + - docker login -u smarthutsm -p $CI_DOCKER_PASS #GiovanniRoberto script: - - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/') - - docker run - --env SOURCE_CODE="$PWD" - --volume "$PWD":/code - --volume /var/run/docker.sock:/var/run/docker.sock - "registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code + - "docker build -t smarthutsm/smarthut:${CI_COMMIT_BRANCH} --pull ." + - "docker push smarthutsm/smarthut:${CI_COMMIT_BRANCH}" + after_script: + - docker logout + + +#base checks for the code +build: + stage: build + script: + - gradle clean + - gradle assemble artifacts: + paths: + - build/libs/*.jar + expire_in: 1 week + +#Runs the various tests and creates a report on the test coverage +test: + stage: test + script: + - gradle test + artifacts: + paths: + - build/test-results/test/TEST-*.xml reports: - codequality: gl-code-quality-report.json + junit: build/test-results/test/TEST-*.xml + +#Runs a quality check on the code and creates a report on the codes +code_quality: + stage: code_quality + script: + - gradle cpdCheck + artifacts: + paths: + - build/reports/cpd/cpdCheck.xml + #create a report on the quality of the code + expose_as: 'Code Quality Report' + allow_failure: true diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7a6dc45 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM openjdk:13-jdk-alpine +ENV DB_URL "" +ENV DB_USER "" +ENV DB_PASS "" +ARG JAR_FILE=build/libs/smarthut*.jar +COPY ${JAR_FILE} app.jar +EXPOSE 8080 +ENTRYPOINT ["java","-jar","/app.jar"] diff --git a/build.gradle b/build.gradle index d4f0bd4..d23270b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,21 +1,24 @@ plugins { id 'org.springframework.boot' version '2.2.4.RELEASE' id 'io.spring.dependency-management' version '1.0.9.RELEASE' + id "de.aaschmid.cpd" version "3.1" id 'java' } -group = 'ch.usi.inf.sa4.sanmarinoes.' +group = 'ch.usi.inf.sa4.sanmarinoes' version = '0.0.1-SNAPSHOT' -sourceCompatibility = "11" +sourceCompatibility = '11' repositories { mavenCentral() - jcenter() } dependencies { compile 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final' + compile "org.springframework.boot:spring-boot-starter-websocket" + implementation 'org.springframework.boot:spring-boot-starter' + implementation 'com.sun.mail:javax.mail:1.6.2' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-security' diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f3d88b1 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 52d63d1..a2bf131 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Thu Feb 20 21:04:58 CET 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip