diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cf23018..1cbbf30 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -26,14 +26,20 @@ build-src: except: - master - tags - script: + before_script: - apt update - apt install -y curl gnupg git make golang + - mkdir -p /go/src /go/bin /go/pkg + - export GOPATH=/go + - export PATH=$PATH:/go/bin + - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + - ln -s $CI_PROJECT_DIR /go/src/$CI_PROJECT_NAME - curl -sL https://deb.nodesource.com/setup_10.x | bash - - apt update - apt install -y nodejs - npm install -g html-minifier@3.5.7 uglify-js@3.4.1 sass@1.5.1 - - mkdir -p src/gitlab.com/commento && cd src/gitlab.com/commento && ln -s $CI_PROJECT_DIR && cd $CI_PROJECT_NAME + script: + - cd /go/src/$CI_PROJECT_NAME - make devel - make prod @@ -58,12 +64,17 @@ go-test: POSTGRES_PASSWORD: postgres POSTGRES_DB: commento_test COMMENTO_POSTGRES: postgres://postgres:postgres@postgres/commento_test?sslmode=disable - GOPATH: $CI_PROJECT_DIR except: - master - tags + before_script: + - mkdir -p /go/src /go/bin /go/pkg + - export GOPATH=/go + - export PATH=$PATH:/go/bin + - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + - ln -s $CI_PROJECT_DIR /go/src/$CI_PROJECT_NAME script: - - mkdir -p src/gitlab.com/commento && cd src/gitlab.com/commento && ln -s $CI_PROJECT_DIR && cd $CI_PROJECT_NAME + - cd /go/src/$CI_PROJECT_NAME - make test go-fmt: diff --git a/Dockerfile b/Dockerfile index 8b47f1b..3c23dd3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,8 @@ FROM golang:1.10.2-alpine AS api-build COPY ./api /go/src/commento-ce/api WORKDIR /go/src/commento-ce/api -RUN apk update && apk add bash make git +RUN apk update && apk add bash make git curl +RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh RUN make prod -j$(($(nproc) + 1)) diff --git a/Gopkg.lock b/api/Gopkg.lock similarity index 100% rename from Gopkg.lock rename to api/Gopkg.lock diff --git a/Gopkg.toml b/api/Gopkg.toml similarity index 100% rename from Gopkg.toml rename to api/Gopkg.toml diff --git a/api/Makefile b/api/Makefile index cb6bf8b..7285014 100644 --- a/api/Makefile +++ b/api/Makefile @@ -25,15 +25,15 @@ clean: # later down the line). devel-go: - go get -v . + dep ensure go build -i -v -o $(GO_DEVEL_BUILD_BINARY) prod-go: - go get -v . + dep ensure go build -i -v -o $(GO_PROD_BUILD_BINARY) test-go: - go get -v . + dep ensure go test -v . $(shell mkdir -p $(GO_DEVEL_BUILD_DIR) $(GO_PROD_BUILD_DIR))