Skip to content

Commit

Permalink
Split-out CI steps into stand-alone scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Helcaraxan committed Mar 31, 2019
1 parent 6f0bb90 commit 01734b1
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ run:
# concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 1m
deadline: 2m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1
Expand Down
72 changes: 28 additions & 44 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,48 @@
language: go
go_import_path: github.com/42wim/matterbridge

# we have everything vendored
# We have everything vendored so this helps TravisCI not run `go get ...`.
install: true

git:
depth: 200

branches:
only:
- master

notifications:
email: false

env:
global:
- GOOS=linux GOARCH=amd64
- GO111MODULE=on
- GOLANGCI_VERSION="v1.15.0"
branches:
only:
- master

matrix:
jobs:
include:
- go: 1.11.x
env: GO111MODULE=off
- go: 1.11.x
env: GO111MODULE=on
- go: 1.12.x
env: GO111MODULE=on

before_script:
# Get version info from tags.
- MY_VERSION="$(git describe --tags)"
# Retrieve the golangci-lint linter binary.
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b ${GOPATH}/bin ${GOLANGCI_VERSION}
# Retrieve and prepare CodeClimate's test coverage reporter.
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build

script:
# Ensure that the module files are being kept correctly and that vendored dependencies are up-to-date.
- go mod tidy
- go mod vendor
- git diff --exit-code --quiet || (echo "Please run 'go mod tidy' to clean up the 'go.mod' and 'go.sum' files."; false)

# Run the linter.
- golangci-lint run

# Run all the tests with the race detector and generate coverage.
- go test -v -race -coverprofile c.out ./...

after_script:
# Upload test coverage to CodeClimate.
- ./cc-test-reporter after-build --exit-code ${TRAVIS_TEST_RESULT}
- stage: lint
# Run linting in one Go environment only.
script: ./ci/lint.sh
go: 1.12.x
env:
- GO111MODULE=on
- GOLANGCI_VERSION="v1.15.0"
- stage: test
# Run tests in a combination of Go environments.
script: ./ci/test.sh
go: 1.11.x
env:
- GO111MODULE=off
- script: ./ci/test.sh
go: 1.11.x
env:
- GO111MODULE=on
- script: ./ci/test.sh
go: 1.12.x
env:
- GO111MODULE=on
- REPORT_COVERAGE=1

deploy:
on:
all_branches: true
condition: env(TRAVIS_GO_VERSION) = 1.12.x
condition: env(TRAVIS_GO_VERSION) = 1.12.x AND env(GO111MODULE) = on
before_deploy:
# Run the build script to generate the necessary binaries and images.
- /bin/bash ci/bintray.sh
Expand Down
3 changes: 1 addition & 2 deletions ci/bintray.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash

#!/usr/bin/env bash
set -u -e -x -o pipefail

go version | grep go1.12 || exit
Expand Down
17 changes: 17 additions & 0 deletions ci/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -u -e -x -o pipefail

if [[ -n "${GOLANGCI_VERSION-}" ]]; then
# Retrieve the golangci-lint linter binary.
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b ${GOPATH}/bin ${GOLANGCI_VERSION}
fi

# Run the linter.
golangci-lint run

if [[ "${GO111MODULE-off}" == "on" ]]; then
# If Go modules are active then check that dependencies are correctly maintained.
go mod tidy
go mod vendor
git diff --exit-code --quiet || (echo "Please run 'go mod tidy' to clean up the 'go.mod' and 'go.sum' files."; false)
fi
17 changes: 17 additions & 0 deletions ci/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -u -e -x -o pipefail

if [[ -n "${REPORT_COVERAGE+cover}" ]]; then
# Retrieve and prepare CodeClimate's test coverage reporter.
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
fi

# Run all the tests with the race detector and generate coverage.
go test -v -race -coverprofile c.out ./...

if [[ -n "${REPORT_COVERAGE+cover}" && "${TRAVIS_SECURE_ENV_VARS}" == "true" ]]; then
# Upload test coverage to CodeClimate.
./cc-test-reporter after-build
fi

0 comments on commit 01734b1

Please sign in to comment.