Merge branch 'ci-cd' into 'dev'

Added an initial pipeline for the continous integration

See merge request sa4-2020/the-sanmarinoes/backend!32
This commit is contained in:
Claudio Maggioni 2020-03-12 17:55:50 +01:00
commit f1fc5a83c1
5 changed files with 72 additions and 18 deletions

View file

@ -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

8
Dockerfile Normal file
View file

@ -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"]

View file

@ -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'

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View file

@ -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