Skip to content

Commit

Permalink
Merge pull request #19 from Financial-Times/feature/UPPSF-666-update-…
Browse files Browse the repository at this point in the history
…orb-circleci

Update circleCI to Orb and module migration
  • Loading branch information
rnov committed Nov 30, 2020
2 parents 1df6473 + 4f546f4 commit 30af223
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 296 deletions.
68 changes: 17 additions & 51 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,20 @@
version: 2
jobs:
build:
working_directory: /go/src/github.com/Financial-Times/upp-next-video-content-collection-mapper
docker:
- image: golang:1
environment:
CIRCLE_TEST_REPORTS: /tmp/test-results
CIRCLE_COVERAGE_REPORT: /tmp/coverage-results
steps:
- checkout
- 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
- 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
- run:
name: Run tests
command: go test -race -cover -coverprofile=${CIRCLE_COVERAGE_REPORT}/coverage.out ./... | go-junit-report > ${CIRCLE_TEST_REPORTS}/junit.xml
- run:
name: Upload coverage
command: goveralls -coverprofile=${CIRCLE_COVERAGE_REPORT}/coverage.out -service=circle-ci -repotoken=${COVERALLS_TOKEN}
- store_test_results:
path: /tmp/test-results
dockerfile:
working_directory: /upp-next-video-content-collection-mapper
docker:
- image: docker:18.03
steps:
- checkout
- setup_docker_engine
- run:
name: Build Dockerfile
command: docker build .
version: 2.1

orbs:
ft-golang-ci: financial-times/golang-ci@1

workflows:
version: 2
test-and-build-docker:
tests_and_docker:
jobs:
- build
- dockerfile:
- ft-golang-ci/build-and-test:
name: build-and-test-project

- ft-golang-ci/docker-build:
name: build-docker-image
requires:
- build
- build-and-test-project
snyk-scanning:
jobs:
- ft-golang-ci/scan:
name: scan-dependencies
context: cm-team-snyk
31 changes: 11 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
FROM golang:1

ENV PROJECT=upp-next-video-content-collection-mapper
ENV BUILDINFO_PACKAGE="github.com/Financial-Times/service-status-go/buildinfo."

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."

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 and build app
RUN $GOPATH/bin/dep ensure -vendor-only
COPY . ${PROJECT}
WORKDIR ${PROJECT}

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="-s -w -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}" \
&& echo "Build flags: ${LDFLAGS}"
&& 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"'" \
&& echo "Build flags: $LDFLAGS" \
&& CGO_ENABLED=0 go build -mod=readonly -o /artifacts/${PROJECT} -ldflags="${LDFLAGS}"

# Multi-stage build - copy 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/* /

CMD [ "/upp-next-video-content-collection-mapper" ]
CMD [ "/upp-next-video-content-collection-mapper" ]
164 changes: 0 additions & 164 deletions Gopkg.lock

This file was deleted.

58 changes: 0 additions & 58 deletions Gopkg.toml

This file was deleted.

5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ Download the source code, dependencies and test dependencies:

go get -u github.com/Financial-Times/upp-next-video-content-collection-mapper
cd $GOPATH/src/github.com/Financial-Times/upp-next-video-content-collection-mapper
dep ensure -v -vendor-only
go build .
go build -mod=readonly

## Running locally

1. Run the tests and install the binary:

go test -race
go test -mod=readonly -race -cover ./... -v
go install

2. Run the binary (using the `help` flag to see the available optional arguments):
Expand Down
25 changes: 25 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module github.com/Financial-Times/upp-next-video-content-collection-mapper

go 1.14

require (
github.com/Financial-Times/go-fthealth v0.0.0-20171204124831-1b007e2b37b7
github.com/Financial-Times/go-logger v0.0.0-20171020134212-ec38b420999c
github.com/Financial-Times/message-queue-go-producer v0.1.1-0.20170622111849-0bb065111416
github.com/Financial-Times/message-queue-gonsumer v0.0.0-20170622111749-6f96a5cb1e34
github.com/Financial-Times/service-status-go v0.0.0-20160323111542-3f5199736a3d
github.com/Financial-Times/uuid-utils-go v0.0.0-20170516110427-e22658edd0f1
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/gorilla/handlers v1.2.1
github.com/hashicorp/go-version v0.0.0-20170202080759-03c5bf6be031 // indirect
github.com/jawher/mow.cli v0.0.0-20161123225447-0de3d3b4ed00
github.com/onsi/ginkgo v1.14.2 // indirect
github.com/onsi/gomega v1.10.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/satori/go.uuid v1.1.1-0.20170321230731-5bf94b69c6b6
github.com/sirupsen/logrus v1.0.5-0.20180129181852-768a92a02685 // indirect
github.com/stretchr/testify v1.1.5-0.20170130113145-4d4bfba8f1d1
github.com/willf/bitset v1.1.2 // indirect
gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
)
Loading

0 comments on commit 30af223

Please sign in to comment.