Skip to content

Commit

Permalink
Merge pull request #11 from Financial-Times/feature/add-audio-support
Browse files Browse the repository at this point in the history
Feature/add audio support
  • Loading branch information
Emil Olosutean committed Oct 12, 2018
2 parents 705522f + 1202634 commit fd22616
Show file tree
Hide file tree
Showing 9 changed files with 300 additions and 198 deletions.
30 changes: 13 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,41 @@ jobs:
build:
working_directory: /go/src/github.com/Financial-Times/upp-next-video-content-collection-mapper
docker:
- image: golang:1.8.3
- image: circleci/golang:1.10
environment:
GOPATH: /go
CIRCLE_TEST_REPORTS: /tmp/test-results
CIRCLE_COVERAGE_REPORT: /tmp/coverage-results
steps:
- checkout
- run:
name: External Dependencies
name: External dependencies
command: |
go get -u github.com/mattn/goveralls
go get -u github.com/jstemmer/go-junit-report
go get -u github.com/kardianos/govendor
go get -u github.com/haya14busa/goverage
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
- run:
name: Test Results
name: Make result folders
command: |
mkdir -p ${CIRCLE_TEST_REPORTS}
mkdir -p ${CIRCLE_COVERAGE_REPORT}
- run:
name: Govendor Sync
command: govendor sync -v
name: Download vendored dependencies
command: dep ensure -v -vendor-only
- run:
name: Go Build
name: Go build
command: go build -v
- run:
name: Run Tests
command: |
govendor test -race -v +local | /go/bin/go-junit-report > ${CIRCLE_TEST_REPORTS}/main.xml
goverage -covermode=atomic -race -coverprofile=${CIRCLE_COVERAGE_REPORT}/coverage.out ./...
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: /go/bin/goveralls -coverprofile=${CIRCLE_COVERAGE_REPORT}/coverage.out -service=circle-ci -repotoken=$COVERALLS_TOKEN
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:1.12.6-git
- image: docker:18.03
steps:
- checkout
- setup_docker_engine
Expand All @@ -55,4 +51,4 @@ workflows:
- build
- dockerfile:
requires:
- build
- build
50 changes: 26 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
FROM golang:1.8-alpine
FROM golang:1.10-alpine

ENV PROJECT=upp-next-video-content-collection-mapper
COPY . /${PROJECT}-sources/

RUN apk --no-cache --virtual .build-dependencies add git \
&& ORG_PATH="github.com/Financial-Times" \
&& REPO_PATH="${ORG_PATH}/${PROJECT}" \
&& mkdir -p $GOPATH/src/${ORG_PATH} \
# Linking the project sources in the GOPATH folder
&& ln -s /${PROJECT}-sources $GOPATH/src/${REPO_PATH} \
&& cd $GOPATH/src/${REPO_PATH} \
&& BUILDINFO_PACKAGE="${ORG_PATH}/${PROJECT}/vendor/${ORG_PATH}/service-status-go/buildinfo." \
&& 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"'" \
&& echo "Build flags: $LDFLAGS" \
&& echo "Fetching dependencies..." \
&& go get -u github.com/kardianos/govendor \
&& $GOPATH/bin/govendor sync \
&& go build -ldflags="${LDFLAGS}" \
&& mv ${PROJECT} /${PROJECT} \
&& apk del .build-dependencies \
&& rm -rf $GOPATH /var/cache/apk/* $GOPATH/src /${PROJECT}-sources /usr/local/go
# Include code
ENV ORG_PATH="github.com/Financial-Times"
ENV SRC_FOLDER="${GOPATH}/src/${ORG_PATH}/${PROJECT}"
COPY . ${SRC_FOLDER}
WORKDIR ${SRC_FOLDER}

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

# Install dependancies and build app
RUN $GOPATH/bin/dep ensure -vendor-only
RUN BUILDINFO_PACKAGE="${ORG_PATH}/${PROJECT}/vendor/${ORG_PATH}/service-status-go/buildinfo." \
&& 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}"


# 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/* /

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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Gopkg.toml example
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true


[[constraint]]
name = "github.com/Financial-Times/go-fthealth"
version = "0.4.0"

[[constraint]]
name = "github.com/Financial-Times/go-logger"
version = "0.0.3"

[[constraint]]
name = "github.com/Financial-Times/message-queue-go-producer"
version = "0.2.0"

[[constraint]]
name = "github.com/Financial-Times/message-queue-gonsumer"
version = "0.4.0"

[[constraint]]
name = "github.com/Financial-Times/service-status-go"
version = "0.1.0"

[[constraint]]
name = "github.com/Financial-Times/uuid-utils-go"
version = "1.0.1"

[[constraint]]
name = "github.com/gorilla/handlers"
version = "1.2.1"

[prune]
go-tests = true
unused-packages = true
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@ Get the related content references from the Next video content ("related" field)
Download the source code, dependencies and test dependencies:

go get -u github.com/kardianos/govendor
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
govendor sync
dep ensure -v -vendor-only
go build .

## Running locally

1. Run the tests and install the binary:

govendor sync
govendor test -v -race
go test -race
go install

2. Run the binary (using the `help` flag to see the available optional arguments):
Expand Down
7 changes: 6 additions & 1 deletion queuehandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"net/http"
"strings"
"time"

"github.com/Financial-Times/message-queue-go-producer/producer"
Expand Down Expand Up @@ -36,7 +37,11 @@ func (h *queueHandler) init() {

func (h *queueHandler) queueConsume(m consumer.Message) {
if m.Headers["Origin-System-Id"] != nextVideoOrigin {
log.WithField("queue_topic", h.consumerConfig.Topic).Infof("Ignoring message with different Origin-System-Id: %v", m.Headers["Origin-System-Id"])
log.WithTransactionID(m.Headers["X-Request-Id"]).WithField("queue_topic", h.consumerConfig.Topic).Infof("Ignoring message with different Origin-System-Id: %v", m.Headers["Origin-System-Id"])
return
}
if strings.Contains(m.Headers["Content-Type"], "audio") {
log.WithTransactionID(m.Headers["X-Request-Id"]).WithField("queue_topic", h.consumerConfig.Topic).Infof("Ignoring message with Content-Type: %v", m.Headers["Content-Type"])
return
}
lastModified := m.Headers["Message-Timestamp"]
Expand Down
Loading

0 comments on commit fd22616

Please sign in to comment.