Skip to content

Commit

Permalink
UPPSF-1150 Refactored project
Browse files Browse the repository at this point in the history
- Integrated go modules
- Extracted constants to yaml configuration
- Restructured project with a proper cmd/pkg structure
- Set proper visibility to all structs and interfaces
- Fixed tests to comply with the new structure
- Added new UPPLogger
- Extracted client and server HTTP boilerplate outside of main.go
- Added docker-compose.yml and Makefile
  • Loading branch information
Tsvetan Dimitrov committed Feb 20, 2020
1 parent 19cc9dd commit f952bbf
Show file tree
Hide file tree
Showing 46 changed files with 1,390 additions and 1,241 deletions.
21 changes: 5 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,16 @@ jobs:
- run:
name: External dependencies
command: |
go get -u github.com/mattn/goveralls
go get -u github.com/jstemmer/go-junit-report
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
GO111MODULE=off go get -u github.com/mattn/goveralls
GO111MODULE=off go get -u github.com/jstemmer/go-junit-report
- run:
name: Make result folders
command: |
mkdir -p ${CIRCLE_TEST_REPORTS}
mkdir -p ${CIRCLE_COVERAGE_REPORT}
- run:
name: Download vendored dependencies
command: dep ensure -v -vendor-only
- run:
name: Go build
command: go build -v
command: go build -mod=readonly -v ./cmd/content-rw-elasticsearch
- run:
name: Run tests
command: go test -race -cover -coverprofile=${CIRCLE_COVERAGE_REPORT}/coverage.out ./... | go-junit-report > ${CIRCLE_TEST_REPORTS}/junit.xml
Expand All @@ -47,7 +43,7 @@ jobs:
dredd:
working_directory: /go/src/github.com/Financial-Times/content-rw-elasticsearch
docker:
- image: bankrs/golang-dredd:go1.10.0-dredd5.1.5
- image: bankrs/golang-dredd:go1.13.7-dredd11.2.19
environment:
GOPATH: /go
ELASTICSEARCH_SAPI_ENDPOINT: http://localhost:9000
Expand All @@ -57,16 +53,9 @@ jobs:
- run:
name: Load ersatz-fixtures.yml to ersatz image
command: "curl -X POST --data-binary @_ft/ersatz-fixtures.yml -H \"Content-type: text/x-yaml\" http://localhost:9000/__configure"
- run:
name: External Dependencies
command: |
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
- run:
name: Download vendored dependencies
command: dep ensure -v -vendor-only
- run:
name: Go Build
command: go build -v
command: go build -mod=readonly -v ./cmd/content-rw-elasticsearch
- run:
name: Dredd API Testing
command: dredd
Expand Down
20 changes: 18 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
*.iml
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
vendor/

# IntelliJ files
*.iml
.idea

/content-rw-elasticsearch
vendor/*/
15 changes: 5 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,28 @@ ENV PROJECT=content-rw-elasticsearch

ENV ORG_PATH="github.com/Financial-Times"
ENV SRC_FOLDER="${GOPATH}/src/${ORG_PATH}/${PROJECT}"
ENV BUILDINFO_PACKAGE="${ORG_PATH}/${PROJECT}/vendor/${ORG_PATH}/service-status-go/buildinfo."
ENV BUILDINFO_PACKAGE="${ORG_PATH}/service-status-go/buildinfo."

COPY . ${SRC_FOLDER}
WORKDIR ${SRC_FOLDER}

# Set up our extra bits in the image
RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh

# Install dependancies
RUN $GOPATH/bin/dep ensure -vendor-only

# Build app
RUN VERSION="version=$(git describe --tag --always 2> /dev/null)" \
&& DATETIME="dateTime=$(date -u +%Y%m%d%H%M%S)" \
&& REPOSITORY="repository=$(git config --get remote.origin.url)" \
&& REVISION="revision=$(git rev-parse HEAD)" \
&& BUILDER="builder=$(go version)" \
&& LDFLAGS="-X '"${BUILDINFO_PACKAGE}$VERSION"' -X '"${BUILDINFO_PACKAGE}$DATETIME"' -X '"${BUILDINFO_PACKAGE}$REPOSITORY"' -X '"${BUILDINFO_PACKAGE}$REVISION"' -X '"${BUILDINFO_PACKAGE}$BUILDER"'" \
&& CGO_ENABLED=0 go build -a -o /artifacts/${PROJECT} -ldflags="${LDFLAGS}" \
&& CGO_ENABLED=0 go build -mod=readonly -a -o /artifacts/${PROJECT} -ldflags="${LDFLAGS}" ./cmd/${PROJECT} \
&& echo "Build flags: ${LDFLAGS}"

# Multi-stage build - copy only the certs and the binary into the image
FROM scratch
WORKDIR /
COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=0 /artifacts/* /

# Copy things specific for this service
COPY ./runtime/referenceSchema.json /
## Copy things specific for this service
#COPY configs /configs

CMD [ "/content-rw-elasticsearch" ]
238 changes: 0 additions & 238 deletions Gopkg.lock

This file was deleted.

Loading

0 comments on commit f952bbf

Please sign in to comment.