2020-04-06 20:02:10 +05:30
|
|
|
os: linux
|
|
|
|
dist: xenial
|
2018-02-16 03:16:20 +05:30
|
|
|
language: go
|
|
|
|
go:
|
2020-04-06 19:07:22 +05:30
|
|
|
- "1.14"
|
2018-02-16 03:16:20 +05:30
|
|
|
|
|
|
|
stages:
|
2020-04-06 22:07:05 +05:30
|
|
|
- Tests
|
|
|
|
- name: Deploy
|
2020-04-22 05:20:33 +05:30
|
|
|
if: env(TRAVIS_PULL_REQUEST) IS false AND (branch = master OR tag IS present) AND commit_message !~ /(\[skip deploy\])/
|
2018-02-16 03:16:20 +05:30
|
|
|
|
2018-02-16 23:28:29 +05:30
|
|
|
install:
|
2018-02-16 03:16:20 +05:30
|
|
|
- go get -u github.com/golang/dep/cmd/dep
|
2018-02-16 23:28:29 +05:30
|
|
|
- dep ensure
|
2018-02-16 03:16:20 +05:30
|
|
|
|
2020-04-06 22:07:05 +05:30
|
|
|
cache:
|
|
|
|
directories:
|
|
|
|
- $GOPATH/pkg/dep
|
|
|
|
|
2018-02-16 03:16:20 +05:30
|
|
|
jobs:
|
|
|
|
include:
|
2020-04-06 22:07:05 +05:30
|
|
|
# Tests stage
|
2020-04-06 21:42:10 +05:30
|
|
|
- name: Unit tests
|
2020-04-06 22:07:05 +05:30
|
|
|
stage: Tests
|
2020-04-21 04:50:45 +05:30
|
|
|
services:
|
|
|
|
- redis
|
2018-02-16 03:16:20 +05:30
|
|
|
script:
|
2020-04-21 04:50:45 +05:30
|
|
|
- go test -v -race --tags redis -coverprofile=coverage.txt -covermode=atomic ./...
|
2020-01-06 02:05:10 +05:30
|
|
|
- bash <(curl -s https://codecov.io/bash)
|
|
|
|
|
2020-04-21 19:01:36 +05:30
|
|
|
- name: FOSSA
|
|
|
|
stage: Tests
|
2020-04-22 05:14:11 +05:30
|
|
|
if: branch = master
|
2020-04-21 19:01:36 +05:30
|
|
|
before_script:
|
|
|
|
- curl https://raw.githubusercontent.com/fossas/fossa-cli/master/install.sh | bash
|
|
|
|
script:
|
|
|
|
- fossa init
|
2020-04-22 05:14:11 +05:30
|
|
|
- fossa analyze
|
|
|
|
# Disable until https://github.com/fossas/fossa-cli/issues/596 will be resolved
|
|
|
|
# - fossa test
|
2020-04-06 21:42:10 +05:30
|
|
|
|
|
|
|
# Deploy stage
|
|
|
|
- name: Docker image
|
2020-04-06 22:07:05 +05:30
|
|
|
stage: Deploy
|
2020-01-06 02:05:10 +05:30
|
|
|
services:
|
|
|
|
- docker
|
2018-02-16 03:16:20 +05:30
|
|
|
script:
|
2020-01-06 02:05:10 +05:30
|
|
|
- docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
|
|
|
|
- export DOCKER_TAG="${TRAVIS_TAG:-dev}"
|
|
|
|
- export APP_VERSION="${TRAVIS_TAG:-dev-${TRAVIS_COMMIT:0:7}}"
|
|
|
|
- >
|
|
|
|
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64
|
|
|
|
go build
|
|
|
|
-o release/chrly
|
2020-04-23 23:13:36 +05:30
|
|
|
-ldflags "-extldflags '-static' -X github.com/elyby/chrly/version.version=$APP_VERSION -X github.com/elyby/chrly/version.commit=$TRAVIS_COMMIT"
|
2020-01-06 02:05:10 +05:30
|
|
|
main.go
|
|
|
|
- docker build -t elyby/chrly:$DOCKER_TAG .
|
|
|
|
- docker push elyby/chrly:$DOCKER_TAG
|
|
|
|
- |
|
2020-04-23 23:30:19 +05:30
|
|
|
if [ ! -z ${TRAVIS_TAG:+x} ]; then
|
2020-01-06 02:05:10 +05:30
|
|
|
docker tag elyby/chrly:$DOCKER_TAG elyby/chrly:latest
|
|
|
|
docker push elyby/chrly:latest
|
|
|
|
fi
|