From 7f0e4ad4487cf03288af7519434f5d54844f47e1 Mon Sep 17 00:00:00 2001 From: Duco van Amstel Date: Thu, 4 Apr 2019 21:54:51 +0100 Subject: Add CI fixes and improvements (#780) * Update GolangCI-lint and lint config The `algo` parameter for the `unparam` linter has been removed and we should thus no longer specify it. Also, bumping the GolangCI-lint version to the latest available minor release. See: mvdan/unparam@e6a6d1c51b6f03ac1a9d120f1ea07bc3a3f0e0b9 * Fix and improve bintray CI script * Further CI setup improvements * Split-out CI steps into stand-alone scripts --- ci/bintray.sh | 7 +++++-- ci/lint.sh | 17 +++++++++++++++++ ci/test.sh | 17 +++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100755 ci/lint.sh create mode 100755 ci/test.sh (limited to 'ci') diff --git a/ci/bintray.sh b/ci/bintray.sh index b0fb7d6a..c7e8a81e 100755 --- a/ci/bintray.sh +++ b/ci/bintray.sh @@ -1,5 +1,8 @@ -#!/bin/bash -go version | grep go1.11 || exit +#!/usr/bin/env bash +set -u -e -x -o pipefail + +go version | grep go1.12 || exit + VERSION=$(git describe --tags) mkdir ci/binaries GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -X main.githash=$(git log --pretty=format:'%h' -n 1)" -o ci/binaries/matterbridge-$VERSION-windows-amd64.exe diff --git a/ci/lint.sh b/ci/lint.sh new file mode 100755 index 00000000..f68c2c92 --- /dev/null +++ b/ci/lint.sh @@ -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 diff --git a/ci/test.sh b/ci/test.sh new file mode 100755 index 00000000..5d9c258d --- /dev/null +++ b/ci/test.sh @@ -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 -- cgit v1.2.3