diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..e4e5b27ded53b7ace8e1f2d56ea1a4e5b9b8f7bf --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,109 @@ +variables: + MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository" + +image: registry.forgemia.inra.fr/agroclim/common/docker-projets-java:latest + +stages: + - build + - test + - install + - code-check + - deploy + +cache: + paths: + - .m2/repository + - target + - www-client/target + - www-server/target + - www-shared/target + +build_job: + stage: build + script: + - echo "Maven compile started" + - mvn clean compile test-compile + - ls -lha /usr/bin/tokei + - /usr/bin/tokei --version + artifacts: + when: always + paths: + - target + - www-client/target + - www-server/target + - www-shared/target + +test_job: + stage: test + needs: ["build_job"] + script: + - echo "Maven test started" + - mvn test org.jacoco:jacoco-maven-plugin:report-aggregate + artifacts: + when: always + paths: + - target + - www-client/target + - www-server/target + - www-shared/target + reports: + junit: + - target/surefire-reports/TEST-*.xml + - target/failsafe-reports/TEST-*.xml + +install_job: + stage: install + needs: ["test_job"] + script: + - echo "Maven packaging started" + - mvn install -DskipTests + artifacts: + when: always + paths: + - .m2/repository + +checkstyle_job: + stage: code-check + needs: ["install_job"] + script: + - mvn checkstyle:checkstyle + +pmd_job: + stage: code-check + needs: ["install_job"] + script: + - mvn pmd:pmd + +cpd_job: + stage: code-check + needs: ["install_job"] + script: + - mvn pmd:cpd + +cobertura_job: + stage: deploy + needs: ["test_job"] + script: + # convert report from jacoco to cobertura, using relative project path + - python /opt/cover2cover.py + www-client/target/site/jacoco-aggregate/jacoco.xml + www-server/target/site/jacoco-aggregate/jacoco.xml + www-shared/target/site/jacoco-aggregate/jacoco.xml + $CI_PROJECT_DIR/www-client/src/main/java/ + $CI_PROJECT_DIR/www-server/src/main/java/ + $CI_PROJECT_DIR/www-shared/src/main/java/ + > target/cobertura.xml + +# https://agroclim.pages.mia.inra.fr/agrometinfo/www/ +pages: + stage: deploy + needs: ["install_job"] + script: + - mvn site -DskipTests + - mv www-client/target/site/ target/site/www-client + - mv www-server/target/site/ target/site/www-server + - mv www-shared/target/site/ target/site/www-shared + artifacts: + paths: + - target/site + publish: target/site diff --git a/bin/sloccount.sh b/bin/sloccount.sh index 2ad699326333ec88a11c6c2ee4edf6a7a9b507fa..5b15d000e001dbdf9758f648d3c028e9de32bd9f 100755 --- a/bin/sloccount.sh +++ b/bin/sloccount.sh @@ -1,28 +1,24 @@ #!/bin/bash - +ROOT_DIR=$(dirname $(dirname $0)) TOKEI2CLOC=$(dirname $0)/tokei2cloc.py -TOKEITGZ=tokei-v7.0.3-x86_64-unknown-linux-gnu.tar.gz -if [ ! -f bin/tokei ]; then - mkdir -p ~/tmp bin - if [ ! -f ~/tmp/$TOKEITGZ ]; then - wget "https://github.com/Aaronepower/tokei/releases/download/v7.0.3/$TOKEITGZ" -O ~/tmp/$TOKEITGZ +TOKEI=$(command -v tokei) +if [ ! -x "$TOKEI" ]; then + TOKEITGZ=tokei-x86_64-unknown-linux-gnu.tar.gz + if [ ! -f bin/tokei ]; then + mkdir -p ~/tmp + if [ ! -f ~/tmp/$TOKEITGZ ]; then + wget "https://github.com/Aaronepower/tokei/releases/download/v12.1.2/$TOKEITGZ" -O ~/tmp/$TOKEITGZ + fi + tar zxf ~/tmp/$TOKEITGZ -C bin fi - tar zxf ~/tmp/$TOKEITGZ -C bin + TOKEI=bin/tokei fi -if [ -f bin/tokei ]; then - mkdir -p target - bin/tokei -f -o json src | $TOKEI2CLOC > target/cloc.xml - exit +if [ ! -f $TOKEI ]; then + echo "Strange, $TOKEI does not exist!" + exit 1 fi -SLOCCOUNT=$(which sloccount); -if [ "$SLOCCOUNT" != "" ]; then - DATADIR=$(dirname $0)/.slocdata; - if [ ! -f $DATADIR ]; then - mkdir -p $DATADIR; - fi - mkdir -p target ; - /usr/bin/sloccount --datadir $DATADIR --duplicates --wide --details src > target/sloccount.sc; -else - echo "sloccount not found!"; -fi +echo "tokei is installed at $TOKEI" +$TOKEI --version +mkdir -p $ROOT_DIR/target +$TOKEI -f -o json $ROOT_DIR/www-client/src $ROOT_DIR/www-server/src $ROOT_DIR/www-shared/src | $TOKEI2CLOC > $ROOT_DIR/target/cloc.xml diff --git a/bin/tokei2cloc.py b/bin/tokei2cloc.py index f554a074a9120d303609e3593ca02bae0638f5aa..bc41a97876ca9d42b55f6a2aaa1e2590312f3d01 100755 --- a/bin/tokei2cloc.py +++ b/bin/tokei2cloc.py @@ -1,29 +1,12 @@ #!/usr/bin/env python3 # -*- coding: UTF-8 -*- -# -# data.pheno.fr - Phenological data portal of TEMPO -# Copyright © 2019 TEMPO (contact-tempo@inrae.fr) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -# $Id: tokei2cloc.py 77 2019-01-11 17:24:18Z omaury $ +# $Id$ # # Author : Olivier Maury # Creation Date : 2019-01-15 10:30:29 +0200 -# Last Revision : $Date: 2019-01-11 18:24:18 +0100 (ven., 11 janv. 2019) $ -# Revision : $Rev: 77 $ +# Last Revision : $Date$ +# Revision : $Rev$ u""" [1mNOM[m %prog - Tokei2Cloc @@ -38,10 +21,10 @@ u""" Olivier Maury [1mVERSION[m - $Date: 2019-01-11 18:24:18 +0100 (ven., 11 janv. 2019) $ + $Date$ """ -__revision__ = "$Rev: 77 $" +__revision__ = "$Rev$" __author__ = "Olivier Maury" import json import sys @@ -52,8 +35,10 @@ results = json.loads(sys.stdin.read()) nb_files = 0 nb_lines = 0 for lang in results: - nb_files += len(results[lang]['stats']) - nb_lines += int(results[lang]['lines']) + nb_files += len(results[lang]['reports']) + nb_lines += int(results[lang]['blanks']) + nb_lines += int(results[lang]['code']) + nb_lines += int(results[lang]['comments']) print("""<?xml version="1.0"?><results> <header> @@ -73,11 +58,11 @@ total_blank = 0 total_comment = 0 total_code = 0 for lang in results: - for result in results[lang]['stats']: - blank = int(result['blanks']) - comment = int(result['comments']) - code = int(result['code']) - print(""" <file name="%s" blank="%d" comment="%d" code="%d" language="%s" />""" % + for result in results[lang]['reports']: + blank = int(result['stats']['blanks']) + comment = int(result['stats']['comments']) + code = int(result['stats']['code']) + print(""" <file name="%s" blank="%d" comment="%d" code="%d" language="%s" />""" % (result['name'], blank, comment, code, lang)) total_blank += blank total_comment += comment diff --git a/config/checkstyle-suppressions.xml b/config/checkstyle-suppressions.xml index 7f911a720bc3fc8977ddb0654eefb48f4f3b2526..0e5d10bddd6d1ed5a8114921f219d9218fbbeb9d 100644 --- a/config/checkstyle-suppressions.xml +++ b/config/checkstyle-suppressions.xml @@ -5,4 +5,8 @@ <suppressions> <suppress checks=".*" files="[/\\]generated-sources[/\\]" /> <suppress checks="JavadocPackage|MagicNumber" files="[/\\]src[/\\]test[/\\]" /> + <!-- www-client/config/checkstyle-suppressions.xml --> + <suppress checks="MagicNumber" files="ColorSequences.java" /> + <!-- www-server/config/checkstyle-suppressions.xml --> + <suppress checks="DesignForExtension" files=".*Resource.java" /> </suppressions> diff --git a/www-client/pom.xml b/www-client/pom.xml index 37cf75ab2090462b9b34546a9968ee2496311eb6..353709bc47ebb0a679737e1719d08971efb22101 100644 --- a/www-client/pom.xml +++ b/www-client/pom.xml @@ -25,6 +25,7 @@ </properties> <dependencies> + <!-- AgroMetInfo --> <dependency> <groupId>${project.groupId}</groupId> <artifactId>www-shared</artifactId> @@ -37,6 +38,7 @@ <version>${project.version}</version> <classifier>sources</classifier> </dependency> + <!-- GWT --> <dependency> <groupId>org.gwtproject</groupId> <artifactId>gwt-user</artifactId> diff --git a/www-server/pom.xml b/www-server/pom.xml index 182a39fe365e61369b3b4ba7cb646f47fb7c24ea..e2d5bb89fb7012c35c7fee25556d35335a8be382 100644 --- a/www-server/pom.xml +++ b/www-server/pom.xml @@ -187,6 +187,25 @@ </dependency> </dependencies> + <repositories> + <repository> + <id>sava-gitlab-maven</id> + <url>https://forgemia.inra.fr/api/v4/projects/5817/packages/maven</url> + </repository> + </repositories> + + <distributionManagement> + <repository> + <id>sava-gitlab-maven</id> + <url>https://forgemia.inra.fr/api/v4/projects/5817/packages/maven</url> + </repository> + + <snapshotRepository> + <id>sava-gitlab-maven</id> + <url>https://forgemia.inra.fr/api/v4/projects/5817/packages/maven</url> + </snapshotRepository> + </distributionManagement> + <build> <resources> <resource>