Skip to content

Extreme make over #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Oct 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8dfe9e2
Initial commit.
filipesperandio Oct 3, 2017
61aa0ab
Remove unecessary files
filipesperandio Oct 4, 2017
7708991
Ignore .gradle and IntelliJ files
filipesperandio Oct 4, 2017
6f85636
Use specific versions of sonarlint-core and sonarlit-client-api that …
filipesperandio Oct 4, 2017
21d6b53
Override Sonarlint's classes to add CC's JsonReport
filipesperandio Oct 4, 2017
02ac0f5
Give classpath priority to sonalint-core and sonarlint-client-api
filipesperandio Oct 4, 2017
6bdd3d5
Keep license header
filipesperandio Oct 4, 2017
174fecf
Move log messages to stderr
filipesperandio Oct 4, 2017
115ebd1
Give app a proper name
filipesperandio Oct 4, 2017
c38ac39
Make app classes first priority on classpath - so we can override wha…
filipesperandio Oct 4, 2017
c634643
Docker setup
filipesperandio Oct 4, 2017
359b560
Save a few MBs on docker image
filipesperandio Oct 4, 2017
7e908b8
Optimize docker layers by caching project dependencies
filipesperandio Oct 4, 2017
0de0f6f
Add sanitity check test
filipesperandio Oct 4, 2017
edb0c7e
Add CircleCI config
filipesperandio Oct 4, 2017
27cec4a
Remove files for restructure
filipesperandio Oct 4, 2017
b361a70
Merge branch 'master' of github.com:filipesperandio/codeclimate-sonar…
filipesperandio Oct 4, 2017
f79ebde
Smarter ignores
filipesperandio Oct 4, 2017
d865975
Sonar needs writable directory on alaysis, keep it documented
filipesperandio Oct 4, 2017
803d487
Fix problem with gradle base Docker image using its parent instead
filipesperandio Oct 4, 2017
2e71f79
Remove extraline
filipesperandio Oct 6, 2017
f1ce0da
Bring back NOTICE/LICENSE/README
filipesperandio Oct 6, 2017
7a323c5
Dockerfile improvements
filipesperandio Oct 6, 2017
3c80af9
Improve dependencies caching
filipesperandio Oct 9, 2017
77c76a0
Remove gradle wrapper
filipesperandio Oct 9, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
**/.sonarlint

# ---- Maven
# ---- Build related
.gradle/
build/
target/
dependency-reduced-pom.xml
**/*.class

# ---- IntellijIDEA
*.iws
*.iml
*.ipr
*.iws
.idea/

# ---- Eclipse
Expand All @@ -19,12 +22,13 @@ dependency-reduced-pom.xml
Icon?
# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

# ---- Windows
# Windows image file caches
Thumbs.db
Thumbs.db
# Folder config file
Desktop.ini
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

60 changes: 31 additions & 29 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
FROM maven:3.3.9-jdk-8-alpine
FROM java:8-jdk-alpine

MAINTAINER Code Climate

# Create user and app directory
RUN adduser -u 9000 -D app
COPY . /usr/src/app
RUN chown -R app:app /usr/src/app
VOLUME /code

# Package the app with Maven
WORKDIR /usr/src/app
RUN mvn package
# Increase Java memory limits
ENV JAVA_OPTS="-XX:+UseParNewGC -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10 -Xss4096k"

# Unzip the packaged app
RUN mkdir /usr/src/app/dest
RUN unzip /usr/src/app/target/sonarlint-cli-*.zip \
-d /usr/src/app/dest
RUN cp -R /usr/src/app/dest/sonarlint-cli-*/* \
/usr/src/app/dest
ENV GRADLE_VERSION=4.2.1
ENV GRADLE_HOME=/opt/gradle
ENV GRADLE_FOLDER=$GRADLE_HOME
ENV GRADLE_USER_HOME=$GRADLE_HOME
ENV PATH=$GRADLE_HOME/bin:$PATH

RUN mkdir -p $GRADLE_USER_HOME && \
chown -R app:app $GRADLE_USER_HOME && \
chmod g+s $GRADLE_USER_HOME && \
apk update && \
apk add --virtual .build-dependencies ca-certificates wget && \
update-ca-certificates && \
wget https://downloads.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip && \
unzip gradle-${GRADLE_VERSION}-bin.zip -d /opt && \
mv /opt/gradle-${GRADLE_VERSION}/* $GRADLE_HOME && \
rm -f gradle-${GRADLE_VERSION}-bin.zip && \
apk del .build-dependencies

# Specify the /code volume
# as needed by CC
VOLUME /code
WORKDIR /usr/src/app

# Create a writeable directory for the code
RUN mkdir -p /code-read-write
RUN chown -R app:app /code-read-write
RUN chmod -R 777 /code-read-write
# Cache dependencies
COPY build.gradle ./
RUN gradle infra

# Increase Java memory limits
ENV JAVA_OPTS="-XX:+UseParNewGC -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10 -Xss4096k"
COPY . ./
RUN chown -R app:app ./

RUN gradle clean build -x test

# Switch to app user, copy code to writable
# directory, and run the engine
USER app
ENTRYPOINT []
WORKDIR /code-read-write
CMD cp -R /code/* . && \
/usr/src/app/dest/bin/sonarlint \
--src 'src/main/**/*.java'
WORKDIR /code
CMD cp -R /code /tmp/ && /usr/src/app/build/codeclimate-sonar /tmp/code
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like sonarlint supports a SONARLINT_USER_HOME environment variable. Could that be used to redirect the tool's output to another directory, leaving the source code under analysis untouched in /code?

SonarSource/sonarlint-core@220729b#diff-fc98b7a351de15143748ac690d4fc601

Trying to find a way to avoid this cp -R workaround.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dblandin Didn't work. That reference seems outdated.
I think we can override it somewhere, but I would like to approach this in a separate PR as well. If it is OK for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me 👍

9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.PHONY: image test

IMAGE_NAME ?= codeclimate/codeclimate-sonar-java

image:
docker build --rm -t $(IMAGE_NAME) .

test: image
docker run --rm -ti -w /usr/src/app -u root $(IMAGE_NAME) gradle clean test
155 changes: 0 additions & 155 deletions appveyor.ps1

This file was deleted.

21 changes: 0 additions & 21 deletions appveyor.yml

This file was deleted.

46 changes: 0 additions & 46 deletions assembly.xml

This file was deleted.

16 changes: 16 additions & 0 deletions bin/codeclimate-sonar
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env sh

BUILD_DIR=$(dirname $0)
APP=$(find ${BUILD_DIR}/libs -name "codeclimate*.jar" | tr "\n" ":")
LIBS=$(find ${BUILD_DIR}/libs -name "*.jar" | tr "\n" ":")
CORE=$(find ${BUILD_DIR}/libs -name "sonarlint-core*.jar" -or -name "sonarlint-client-api*.jar" | tr "\n" ":")

CODE_DIR=$1; shift

java \
-cp ${APP}:${CORE}:${LIBS} \
-Djava.awt.headless=true \
-Dsonarlint.home="${BUILD_DIR}" \
-Dproject.home="${CODE_DIR}" \
-Dorg.freemarker.loggerLibrary=none \
cc.App --src "**/*.java" $@
Loading