From e48761402f9dd406d881e064fc683d6d9b3d2cda Mon Sep 17 00:00:00 2001 From: Tim Schubert <tim.schubert@tu-bs.de> Date: Mon, 19 Mar 2018 12:55:21 +0100 Subject: [PATCH] Add checkstyle CI --- checkstyle-runner/Dockerfile | 16 +++ checkstyle-runner/gitlab-ci.yml | 8 ++ checkstyle-runner/tubs_checks.xml | 205 ++++++++++++++++++++++++++++++ notes.md | 16 +++ 4 files changed, 245 insertions(+) create mode 100644 checkstyle-runner/Dockerfile create mode 100644 checkstyle-runner/gitlab-ci.yml create mode 100644 checkstyle-runner/tubs_checks.xml diff --git a/checkstyle-runner/Dockerfile b/checkstyle-runner/Dockerfile new file mode 100644 index 0000000..4792f71 --- /dev/null +++ b/checkstyle-runner/Dockerfile @@ -0,0 +1,16 @@ +FROM java:8-jdk + +WORKDIR /checkstyle + +ADD tubs_checks.xml /checkstyle + +ENV CHECKSTYLE_VERSION=7.6.1 + +RUN curl -sLO https://sourceforge.net/projects/checkstyle/files/checkstyle/${CHECKSTYLE_VERSION}/checkstyle-${CHECKSTYLE_VERSION}-all.jar && mv checkstyle-${CHECKSTYLE_VERSION}-all.jar checkstyle.jar + +# gitlab runner does not use entrypoint like this +# https://docs.gitlab.com/runner/executors/docker.html#the-entrypoint +#ENTRYPOINT ["java","-jar","checkstyle.jar","-c","tubs_checks.xml"] + +# default option, use file names to check +#CMD ["-v"] \ No newline at end of file diff --git a/checkstyle-runner/gitlab-ci.yml b/checkstyle-runner/gitlab-ci.yml new file mode 100644 index 0000000..eebf662 --- /dev/null +++ b/checkstyle-runner/gitlab-ci.yml @@ -0,0 +1,8 @@ +image: y0067212/checkstyle-ips + +checkstyle: + script: + - java -jar checkstyle.jar -c tubs_checks.xml . + artifacts: + paths: + - checkstyle/ diff --git a/checkstyle-runner/tubs_checks.xml b/checkstyle-runner/tubs_checks.xml new file mode 100644 index 0000000..d1b866b --- /dev/null +++ b/checkstyle-runner/tubs_checks.xml @@ -0,0 +1,205 @@ +<?xml version="1.0"?> +<!DOCTYPE module PUBLIC + "-//Puppy Crawl//DTD Check Configuration 1.2//EN" + "http://www.puppycrawl.com/dtds/configuration_1_2.dtd"> + +<!-- + Checkstyle configuration that checks the sun coding conventions from: + + - the Java Language Specification at + http://java.sun.com/docs/books/jls/second_edition/html/index.html + + - the Sun Code Conventions at http://java.sun.com/docs/codeconv/ + + - the Javadoc guidelines at + http://java.sun.com/j2se/javadoc/writingdoccomments/index.html + + - the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html + - some best practices + Checkstyle is very configurable. Be sure to read the documentation at + http://checkstyle.sf.net (or in your downloaded distribution). + Most Checks are configurable, be sure to consult the documentation. + To completely disable a check, just comment it out or delete it from the file. + Finally, it is worth reading the documentation. +--> + +<module name="Checker"> + <!-- Checks that a package.html file exists for each package. --> + <!-- See http://checkstyle.sf.net/config_javadoc.html#PackageHtml --> + <!-- <module name="PackageHtml"/> --> + <!-- Checks whether files end with a new line. --> + <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile --> + + <!--module name="NewlineAtEndOfFile"> + <property name="fileExtensions" value="java"/> + </module--> + + <!-- Checks that property files contain the same keys. --> + <!-- See http://checkstyle.sf.net/config_misc.html#Translation --> + <!--module name="Translation"/--> + + <module name="FileLength"/> + <!-- keine tabs erlauben --> + <!--module name="FileTabCharacter"> + <property name="eachLine" value="true"/> + </module--> + + <!-- <module name="JavadocPackage"/> --> + + <module name="TreeWalker"> + <property name="tabWidth" value="4"/> + + <!-- Strings werden nicht mit == oder != verglichen --> + <module name="StringLiteralEquality"/> + + + + <!-- Checks for Javadoc comments. --> + <!-- See http://checkstyle.sf.net/config_javadoc.html --> + + <module name="JavadocStyle"> + <property name="scope" value="private"/> + <property name="excludeScope" value="package"/> + <property name="checkFirstSentence" value="false"/> + <property name="checkEmptyJavadoc" value="true"/> + </module> + + <module name="JavadocMethod"> + <property name="allowMissingPropertyJavadoc" value="true"/> + <property name="scope" value="package"/> + <property name="ignoreMethodNamesRegex" value="^main$"/> + </module> + + <module name="JavadocType"> + <property name="authorFormat" value="^.+ [0-9]{7}\s+(Gruppe|[gG]roup)\s+[1-9][0-9]?[a-zA-Z]?" /> + </module> + + <module name="JavadocVariable"> + <property name="scope" value="public"/> + <property name="tokens" value="VARIABLE_DEF"/> + </module> + + <!-- Checks for Naming Conventions. --> + <!-- See http://checkstyle.sf.net/config_naming.html --> + <module name="ConstantName"/> + <!-- <module name="LocalFinalVariableName"/> --> + <module name="LocalVariableName"/> + <module name="MemberName"/> + <module name="MethodName"/> + <module name="ParameterName"/> + <module name="StaticVariableName"/> + <module name="TypeName"/> + + <!-- Checks for Headers --> + <!-- See http://checkstyle.sf.net/config_header.html --> + <!-- <module name="Header"> --> + <!-- The follow property value demonstrates the ability --> + <!-- to have access to ANT properties. In this case it uses --> + <!-- the ${basedir} property to allow Checkstyle to be run --> + <!-- from any directory within a project. See property --> + <!-- expansion, --> + <!-- http://checkstyle.sf.net/config.html#properties --> + <!-- <property --> + <!-- name="headerFile" --> + <!-- value="${basedir}/java.header"/> --> + <!-- </module> --> + + <!-- Checks for imports --> + <!-- See http://checkstyle.sf.net/config_import.html --> + <!-- <module name="AvoidStarImport"/> --> + <module name="IllegalImport"/> <!-- defaults to sun.* packages --> + <module name="RedundantImport"/> + <module name="UnusedImports"/> + + <!-- Checks for Size Violations. --> + <!-- See http://checkstyle.sf.net/config_sizes.html --> + + <!-- module name="MethodLength"/ --> + + <!-- Checks for whitespace --> + <!-- See http://checkstyle.sf.net/config_whitespace.html --> + <!-- module name="EmptyForInitializerPad"> + <property name="option" value="space"/> + </module --> + + <!-- module name="EmptyForIteratorPad"> + <property name="option" value="space"/> + </module --> + + <module name="MethodParamPad"/> + <module name="NoWhitespaceAfter"/> + <module name="NoWhitespaceBefore"/> + <module name="OperatorWrap"/> + <module name="TypecastParenPad"/> + + <module name="WhitespaceAfter"/> + <module name="WhitespaceAround"/> + + <!-- Modifier Checks --> + <!-- See http://checkstyle.sf.net/config_modifiers.html --> + <!-- module name="ModifierOrder"/ --> + + <!-- Checks for blocks. You know, those {}'s --> + <!-- See http://checkstyle.sf.net/config_blocks.html --> + <!-- module name="AvoidNestedBlocks"/ --> + <module name="EmptyBlock"/> + <module name="LeftCurly"/> + <module name="NeedBraces"/> + <module name="RightCurly"/> + + <!-- Checks for common coding problems --> + <!-- See http://checkstyle.sf.net/config_coding.html --> + <!-- <module name="AvoidInlineConditionals"/> --> + <module name="EmptyStatement"/> + <!-- <module name="EqualsHashCode"/> --> + <module name="IllegalInstantiation"/> + <module name="InnerAssignment"/> + <!-- module name="MissingSwitchDefault"/--> + <!-- module name="FallThrough"/--> + <module name="DefaultComesLast"/> + + <module name="OneStatementPerLine"/> + <!-- <module name="StringLiteralEquality"/> --> + + <!-- Checks for class design --> + <!-- See http://checkstyle.sf.net/config_design.html --> + <!-- <module name="DesignForExtension"/> --> + <module name="FinalClass"/> + <!-- <module name="FinalLocalVariable"/> --> + <!-- <module name="HideUtilityClassConstructor"/> --> + + <module name="LineLength"> + <property name="max" value="150"/> + </module> + + <module name="VisibilityModifier"/> + <!-- module name="DeclarationOrder"/ --> + <!-- <module name="RequireThis"/> --> + + <!-- module name="RequireThis"> + <property name="checkFields" value="false"/> + <property name="checkMethods" value="false"/> + </module --> + + <!-- Miscellaneous other checks. --> + <!-- See http://checkstyle.sf.net/config_misc.html --> + <module name="ArrayTypeStyle"/> + <module name="GenericWhitespace"/> + + <module name="TodoComment"/> + <module name="UpperEll"/> + + <module name="Indentation"> <!-- einrueckung von 4 leerzeichen --> + <property name="basicOffset" value="4"/> + <property name="caseIndent" value="4"/> + </module> + + <!-- <module name="CyclomaticComplexity"> --> + <!-- <property name="max" value="7"/> --> + <!-- </module> --> + + <module name="IllegalCatch"/> + <module name="IllegalThrows"/> + + </module> +</module> diff --git a/notes.md b/notes.md index d4adce9..4501d05 100644 --- a/notes.md +++ b/notes.md @@ -44,3 +44,19 @@ ## (optional) sync script - (one-way) sync students and groups from [Stud.IP REST API](http://docs.studip.de/develop/Entwickler/RESTAPI) to [Gitlab REST API](https://docs.gitlab.com/ce/api/) + +# Replicate (TODO: ansible playbook) + +- install gitlab +- install docker +- copy gitlab.rb +- partially protected +- default project limit = 0 +- shared runner for checkstyle + +- protected runner for + + + setting protected tags + + running jplag + +- script for creating repos and groups