Skip to content

Update scalastyle, switch to Scala-based parsing, adopt new Engines requirements #8

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 17 commits into from
Dec 11, 2017

Conversation

jsippel
Copy link
Contributor

@jsippel jsippel commented Nov 16, 2017

No description provided.

@ivanobulo
Copy link

@chrishulton can you give a heads up when you'll be able to review this PR?

},
"languages" : ["Scala"],
"version": "0.1.0",
"spec_version": "0.0.1"
Copy link

Choose a reason for hiding this comment

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

Is the engine compatible with the most recent version of the spec? 0.3.1?

Choose a reason for hiding this comment

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

I think it is. The value 0.0.1 is in the SPEC.md file thus I've used it as an example.

@@ -0,0 +1,15 @@
{
Copy link

Choose a reason for hiding this comment

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

The spec expects this file at /engine.json. Could you add a COPY to the dockerfile?

COPY engine.json /

Choose a reason for hiding this comment

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

Done

### Building release docker image
1. Run `sbt assembly && cp target/scala-2.12/codeclimate-scalastyle-assembly-<version>.jar ./`.
This will create assembled jar with all dependencies.
2. Run `docker build -t codeclimate/codeclimate-scalastyle .`
Copy link

Choose a reason for hiding this comment

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

This is fine for now, but it would be great to have this step integrated within the docker image build process, maybe via a multi-stage Dockerfile: https://docs.docker.com/engine/userguide/eng-image/multistage-build

Choose a reason for hiding this comment

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

As I understand SBT build tool is not supported thus this is the only workaround I could think of.

Choose a reason for hiding this comment

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

There are quite a few SBT images out there. Docker definitely can run it. Or have I misunderstood your words?

Choose a reason for hiding this comment

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

Oh, I get what you are saying. Basically use a docker image with sbt to build and assembly package and copy it into the final image. I'll do that.

@@ -0,0 +1,3 @@
target
.idea

Copy link

Choose a reason for hiding this comment

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

This repo might benefit from a .dockerignore file as well.

I don't think the build.sbt or codeclimate-scalastyle-assembly-0.1.0.jar files need to be within the final image.

Choose a reason for hiding this comment

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

codeclimate-scalastyle-assembly-0.1.0.jar is required - it has all the logic for the engine. It is copied as "/usr/src/app/engine-core.jar".
Only files in "src/main/resources/docker" and this jar file are included in the docker image.

Copy link

Choose a reason for hiding this comment

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

I think once it's COPY'd in, as /usr/src/app/engine-core.jar you can leave the original jar out of the final image.

So if a .dockerignore file included codeclimate-scalastyle-assembly-0.1.0.jar, that would remove the duplicate file, right?

Choose a reason for hiding this comment

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

Dockerfile only copies these files:

COPY codeclimate-scalastyle-assembly-0.1.0.jar /usr/src/app/engine-core.jar
COPY src/main/resources/docker /usr/src/app
COPY src/main/resources/docker/engine.json /

Thus codeclimate-scalastyle-assembly-0.1.0.jar is included only once in the docker image.

Adding it to .dockerignore will break the build process because Docker wouldn't be able to find this jar.

Copy link

Choose a reason for hiding this comment

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

Ahh, I see. You're right. Thought there was a broader COPY further down, but after looking again, there isn't. LGTM.

.codeclimate.yml Outdated
@@ -1,3 +1,9 @@
engines:
scalastyle:
enabled: true
config:
config: src/main/resources/scalastyle_project.xml
include_paths:
Copy link

Choose a reason for hiding this comment

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

include_paths isn't normally provided by the user in this way. Code Climate will compute the include_paths, which represent the valid workspace for an engine, based on the exclude_paths at the top level of a Code Climate configuration file. The include_paths are provided within /config.json during an engine run: https://github.com/codeclimate/spec/blob/master/SPEC.md#which-files-to-analyze

Choose a reason for hiding this comment

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

Good to know. I've implemented as you've suggested.

@dblandin dblandin changed the base branch from master to channel/beta December 11, 2017 18:12
@dblandin
Copy link

Going to go ahead and merge this in for release to a beta channel.

@jsippel @ivanobulo Thanks! Nice work!

@dblandin dblandin merged commit 80609af into codeclimate-community:channel/beta Dec 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants