Skip to content

Commit d78cde1

Browse files
committed
Update engine infructure
* Added engine specification * Switched from generic date built to engine/lint version pair for image rebuild trigger. The version is stored in the engine spec under `version` key. It's format is `<engine version>/<lint master head sha1>`. * Bump engine version whenever the code in this repository changes. * Run `make update` to update the lint version part. * Switched to newer Go version.
1 parent a1a3ea1 commit d78cde1

File tree

6 files changed

+59
-17
lines changed

6 files changed

+59
-17
lines changed

DATE_BUILT

Lines changed: 0 additions & 1 deletion
This file was deleted.

Dockerfile

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
FROM alpine:3.4
1+
FROM alpine:edge
22

3-
MAINTAINER Code Climate <hello@codeclimate.com>
3+
LABEL maintainer="Code Climate <hello@codeclimate.com>"
4+
5+
RUN adduser -u 9000 -D app
46

57
WORKDIR /usr/src/app
8+
9+
COPY engine.json /engine.json
610
COPY codeclimate-golint.go /usr/src/app/codeclimate-golint.go
7-
COPY DATE_BUILT /usr/src/app/DATE_BUILT
811

9-
RUN apk --update add go git && \
12+
RUN apk add --no-cache --virtual .dev-deps musl-dev go git && \
1013
export GOPATH=/tmp/go GOBIN=/usr/local/bin && \
11-
go get -d . && \
14+
go get -d -t -v . && \
15+
export LIBRARY_PATH=/usr/lib32:$LIBRARY_PATH && \
1216
go install codeclimate-golint.go && \
13-
apk del go git && \
14-
rm -rf "$GOPATH" && \
15-
rm /var/cache/apk/*
17+
apk del .dev-deps && \
18+
rm -rf "$GOPATH"
1619

20+
USER app
1721
WORKDIR /code
1822
VOLUME /code
1923

20-
RUN adduser -u 9000 -D app
21-
USER app
22-
2324
CMD ["/usr/local/bin/codeclimate-golint"]

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
.PHONY: image
1+
.PHONY: update image
22

33
IMAGE_NAME ?= codeclimate/codeclimate-golint
44

5-
image:
5+
update:
6+
docker run \
7+
--rm --interactive \
8+
-v $(PWD)/engine.json:/engine.json \
9+
-v $(PWD)/bin/update:/usr/local/bin/update \
10+
alpine:edge \
11+
/usr/local/bin/update
12+
13+
image: update
614
docker build --rm -t $(IMAGE_NAME) .

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,20 @@ engines:
2828
### Building
2929
3030
```console
31-
docker build -t codeclimate/codeclimate-golint .
31+
make image
3232
```
3333

3434
### Updating
3535

3636
`golint` doesn't version releases, so in order to get the latest version & force
37-
a new docker image build, we have a `DATE_BUILT` file: to force an update of
38-
golint, run `date > DATE_BUILT` locally & then rebuild the docker image.
37+
a new docker image build, we have to update the `engine.json` file.
38+
39+
```console
40+
make update
41+
```
42+
43+
This will update the engine version with the latest `golint` version. After that
44+
rebuild the image as usually.
3945

4046
### Need help?
4147

bin/update

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
apk add --no-cache curl jq
6+
head_sha=$(
7+
curl -s $(
8+
curl -s "https://api.github.com/repos/golang/lint/git/refs/heads/master" |
9+
jq -r .object.url
10+
) |
11+
jq -r .sha
12+
)
13+
full_version="$(jq -r .version /engine.json | cut -d / -f 1)/${head_sha}"
14+
jq ".version=\"${full_version}\"" /engine.json > /tmp/engine.json &&
15+
cat /tmp/engine.json > /engine.json

engine.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "golint",
3+
"description": "Golint is a linter for Go source code.",
4+
"maintainer": {
5+
"name": "Code Climate",
6+
"email": "hello@codeclimate.com"
7+
},
8+
"languages": [
9+
"Go"
10+
],
11+
"version": "1.0.0/6aaf7c34af0f4c36a57e0c429bace4d706d8e931",
12+
"spec_version": "0.3.1"
13+
}

0 commit comments

Comments
 (0)