Skip to content

Initial Setup #1

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 12 commits into from
Sep 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 12 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
FROM java:8-jre
FROM groovy:jre8-alpine

MAINTAINER Sivakumar Kailasam
MAINTAINER "Code Climate <[email protected]>"

RUN cd /tmp && \
wget http://dl.bintray.com/groovy/maven/apache-groovy-binary-2.4.6.zip && \
unzip apache-groovy-binary-2.4.6.zip && \
mv groovy-2.4.6 /groovy && \
rm apache-groovy-binary-2.4.6.zip
USER root

ENV GROOVY_HOME /groovy
ENV PATH $GROOVY_HOME/bin/:$PATH
RUN apk update && \
apk add ca-certificates wget curl jq && \
update-ca-certificates

RUN groupadd app -g 9000 && useradd -g 9000 -u 9000 -r -s /bin/false app
RUN adduser -u 9000 -D app

COPY ./bin /usr/src/app/bin
RUN /usr/src/app/bin/install-pmd.sh

VOLUME /code
WORKDIR /code
COPY . /usr/src/app
RUN chown -R app:app /usr/src/app

USER app

CMD ["/usr/src/app/pmd.groovy", "--codeFolder=/code","--configFile=/config.json"]
CMD ["/usr/src/app/pmd.groovy", "--codeFolder=/code", "--configFile=/config.json"]
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.PHONY: image test

IMAGE_NAME ?= codeclimate/codeclimate-pmd

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

test: image
docker run --rm $(IMAGE_NAME) sh -c "echo Nothing to do yet!"

26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
## codeclimate-pmd
# Code Climate PMD Engine

`codeclimate-pmd` is a Code Climate engine that wraps the [PMD](https://pmd.github.io) static analysis tool. You can run it on your command line using the Code Climate CLI, or on our hosted analysis platform.

### Installation

1. If you haven't already, [install the Code Climate CLI](https://github.com/codeclimate/codeclimate).
2. Run `codeclimate engines:enable pmd`. This command both installs the engine and enables it in your `.codeclimate.yml` file.
3. You're ready to analyze! Browse into your project's folder and run `codeclimate analyze`.
4. To add you custom PMD rules, open `.codeclimate.yml` and add a `config` entry pointing to your `ruleset.xml` file:
```yml
engines:
pmd:
enabled: true
config: ruleset.xml
```

### Need help?

For help with PMD, [check out their documentation](https://pmd.github.io/).

If you're running into a Code Climate issue, first check out [our PMD engine docs][cc-docs-pmd] and look over this project's [GitHub Issues](https://github.com/codeclimate/codeclimate-rubocop/issues),
as your question may have already been covered. If not, [go ahead and open a support ticket with us](https://codeclimate.com/help).

[cc-docs-pmd]: https://docs.codeclimate.com/docs/pmd
27 changes: 27 additions & 0 deletions bin/install-pmd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -euo pipefail

LIB_DIR=/usr/src/app/lib

download_latest_pmd() {
curl -s https://api.github.com/repos/pmd/pmd/releases/latest | \
jq -c '.assets[] | select(.name | contains("bin")) | .browser_download_url' | \
xargs wget -O pmd.zip
}

install_pmd() {
download_latest_pmd
unzip pmd.zip
mv ${LIB_DIR}/pmd-bin*/* ${LIB_DIR}/pmd
}

cleanup() {
rmdir ${LIB_DIR}/pmd-bin*
rm pmd.zip
}

mkdir -p ${LIB_DIR}/pmd
cd ${LIB_DIR}

install_pmd
cleanup
Copy link

Choose a reason for hiding this comment

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

This all seems like it's begging to be a Makefile WDYT?

Copy link
Contributor Author

@filipesperandio filipesperandio Sep 7, 2017

Choose a reason for hiding this comment

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

@gordondiggs Don't think so. It is only meant to run building the image. I could have all this in the Dockerfile itself but looks ugly.

36 changes: 36 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
machine:
services:
- docker

dependencies:
override:
- >
docker run
--env CIRCLE_BRANCH
--env CIRCLE_PROJECT_REPONAME
--env CIRCLE_TOKEN
--env GCR_JSON_KEY
--volume /var/run/docker.sock:/var/run/docker.sock
codeclimate/patrick pull || true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gordondiggs Will was suggesting skip patrick and pull/push directly to docker hub. I will do so in a new PR.

- make image
Copy link

Choose a reason for hiding this comment

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

These make commands seem valid but you haven't written them yet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refresh?


test:
override:
- make test

deployment:
registry:
branch: /master|channel\/[\w-]+/
owner: codeclimate
commands:
- >
docker run
--env CIRCLE_BUILD_NUM
--env CIRCLE_PROJECT_REPONAME
--env GCR_JSON_KEY
--volume /var/run/docker.sock:/var/run/docker.sock
codeclimate/patrick push gcr

notify:
webhooks:
- url: https://cc-slack-proxy.herokuapp.com/circle
8 changes: 4 additions & 4 deletions engine.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "codeclimate-pmd",
"description": "Static code analysis tool for Java",
"maintainer": {
"name": "sivakumar-kailasam",
"email": "sivakumar.ur.friend@gmail.com "
},
"maintainer": {
"name": "Code Climate",
"email": "hello@codeclimate.com"
},
"languages": [
"Java"
],
Expand Down
237 changes: 0 additions & 237 deletions lib/pmd/LICENSE

This file was deleted.

6 changes: 0 additions & 6 deletions lib/pmd/bin/bgastviewer.bat

This file was deleted.

Loading