diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..84c048a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/build/ diff --git a/Dockerfile b/Dockerfile index 8093ca6..955287e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,6 @@ -FROM codeclimate/alpine-ruby:b36 +FROM alpine:3.2 -WORKDIR /usr/src/app -COPY bin/ /usr/src/app +ADD build/codeclimate-golint /usr/src/app/ RUN adduser -u 9000 -D app USER app diff --git a/bin/build b/bin/build new file mode 100755 index 0000000..4d2f602 --- /dev/null +++ b/bin/build @@ -0,0 +1,18 @@ +#!/bin/bash +set -ex + +IMAGE="$1" +: "${IMAGE:=codeclimate/codeclimate-golint}" + +DIR=$( cd "$( dirname "${0}" )" && pwd ) +SRC_ROOT=$( cd "$DIR/.." && pwd ) +cd "$SRC_ROOT" + +BUILD_SCRIPT="cd /src && "\ +"go get -t -d -v ./... && "\ +"rm -rf build && mkdir build && "\ +"go build -o build/codeclimate-golint ." + +docker run -v "$SRC_ROOT:/src" yunspace/alpine-golang /bin/sh -c "$BUILD_SCRIPT" + +docker build -t "$IMAGE" . diff --git a/bin/codeclimate-golint b/bin/codeclimate-golint deleted file mode 100755 index e82318f..0000000 Binary files a/bin/codeclimate-golint and /dev/null differ diff --git a/circle.yml b/circle.yml index 1b334ca..2147860 100644 --- a/circle.yml +++ b/circle.yml @@ -3,21 +3,23 @@ machine: - docker environment: CLOUDSDK_CORE_DISABLE_PROMPTS: 1 - image_name: codeclimate-golint - -dependencies: - pre: - - echo $gcloud_json_key_base64 | sed 's/ //g' | base64 -d > /tmp/gcloud_key.json - - curl https://sdk.cloud.google.com | bash - - gcloud auth activate-service-account $gcloud_account_email --key-file /tmp/gcloud_key.json - - gcloud docker -a + PRIVATE_REGISTRY: us.gcr.io/code_climate test: override: - - docker build -t=$registry_root/$image_name:b$CIRCLE_BUILD_NUM . + - ./bin/build $PRIVATE_REGISTRY/$CIRCLE_PROJECT_REPONAME:b$CIRCLE_BUILD_NUM deployment: registry: branch: master + owner: codeclimate-community commands: - - docker push $registry_root/$image_name:b$CIRCLE_BUILD_NUM + - echo $gcloud_json_key_base64 | sed 's/ //g' | base64 -d > /tmp/gcloud_key.json + - curl https://sdk.cloud.google.com | bash + - gcloud auth activate-service-account --key-file /tmp/gcloud_key.json + - gcloud docker -a + - docker push $PRIVATE_REGISTRY/$CIRCLE_PROJECT_REPONAME:b$CIRCLE_BUILD_NUM + +notify: + webhooks: + - url: https://cc-slack-proxy.herokuapp.com/circle diff --git a/codeclimate-golint b/codeclimate-golint deleted file mode 100755 index 44c8ccb..0000000 Binary files a/codeclimate-golint and /dev/null differ diff --git a/codeclimate-golint.go b/codeclimate-golint.go index 6ee3794..c2c30d2 100644 --- a/codeclimate-golint.go +++ b/codeclimate-golint.go @@ -42,7 +42,7 @@ func main() { Description: "Could not read file", Location: &engine.Location{ Path: path, - Lines: &engine.Position{ + Lines: &engine.LinesOnlyPosition{ Begin: 1, End: 1, }, @@ -97,7 +97,7 @@ func codeClimateLocation(l *lint.Problem, path string, rootPath string) *engine. return &engine.Location{ Path: strings.SplitAfter(path, rootPath)[1], - Lines: &engine.Position{ + Lines: &engine.LinesOnlyPosition{ Begin: position.Line, End: position.Line, },