Skip to content

Commit

Permalink
PMM-7602 Add GitHub Action (#53)
Browse files Browse the repository at this point in the history
* PMM-7602 Add GitHub Action

* PMM-7602 Point actions to forked repo.

* PMM-7602 Removed travis.

* PMM-7602 Use go modules.

* PMM-7602 Fix check.

* PMM-7602 Fix mod.

* PMM-7602 Fix setup.

* PMM-7602 Fix setup.

* PMM-7602 Fix setup.

* add environment

* PMM-7602 Fix tests.

* PMM-7602 Fix codecov

* PMM-7602 defines what to use go get or go install

* PMM-7602 Improve go get/install

* PMM-7602 Improve get promu.

* PMM-7602 Use tools module for tooling.

* PMM-7602 Fix mods.

* PMM-7602 Fix path

* PMM-7602 Fix gocoverutil

Co-authored-by: Denys Kondratenko <[email protected]>
  • Loading branch information
askomorokhov and denisok authored Jun 3, 2021
1 parent faea4e0 commit c0d2255
Show file tree
Hide file tree
Showing 739 changed files with 1,895 additions and 402,460 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Go

on: [push, pull_request]

jobs:
test:
name: Test
strategy:
matrix:
go-version:
- 1.15
- 1.16
include:
- go-version: tip
os: ubuntu-latest
may-fail: true
runs-on: ubuntu-latest
# The environment this job references
environment:
name: CI
steps:
- name: Set up Go release
if: matrix.go-version != 'tip'
uses: percona-platform/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Set up Go tip
if: matrix.go-version == 'tip'
env:
# to avoid error due to `go version` accepting -v flag with an argument since 1.15
GOFLAGS: ""
run: |
git clone --depth=1 https://go.googlesource.com/go $HOME/gotip
cd $HOME/gotip/src
./make.bash
echo "GOROOT=$HOME/gotip" >> $GITHUB_ENV
echo "$HOME/gotip/bin" >> $GITHUB_PATH
- name: Checkout code
uses: percona-platform/checkout@v2
- name: Build
run: make build
- name: Run checks
run: |
go build -modfile=tools/go.mod -o bin/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint
go build -modfile=tools/go.mod -o bin/reviewdog github.com/reviewdog/reviewdog/cmd/reviewdog
bin/golangci-lint run -c=.golangci-required.yml --out-format=line-number | env REVIEWDOG_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} bin/reviewdog -f=golangci-lint -level=error -reporter=github-pr-check
bin/golangci-lint run -c=.golangci.yml --out-format=line-number | env REVIEWDOG_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} bin/reviewdog -f=golangci-lint -level=error -reporter=github-pr-review
- name: Run Tests
env:
AWS_ACCESS_KEY: AKIAZPBRO3QWCEHJTL35
AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }}
run: make test-race
- name: Run Codecov
env:
AWS_ACCESS_KEY: AKIAZPBRO3QWCEHJTL35
AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }}
run: make codecov
- name: Build tarball
run: make tarball
- name: Build tarball
run: make docker
- name: Run debug commands on failure
if: ${{ failure() }}
run: |
env
go version
go env
pwd
git status
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
/.vscode/
rds_exporter
config.yml
bin/
coverage.txt
2 changes: 2 additions & 0 deletions .promu.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
go:
cgo: false
repository:
path: github.com/percona/rds_exporter
build:
flags: -a -tags netgo
ldflags: |
Expand Down
246 changes: 0 additions & 246 deletions Gopkg.lock

This file was deleted.

4 changes: 0 additions & 4 deletions Gopkg.toml

This file was deleted.

16 changes: 7 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

GO := GO15VENDOREXPERIMENT=1 go
PROMU := $(GOPATH)/bin/promu
GO := go
PROMU := bin/promu
pkgs = $(shell $(GO) list ./...)

PREFIX ?= $(shell pwd)
BIN_DIR ?= $(shell pwd)
DOCKER_IMAGE_NAME ?= $(shell basename $(shell pwd))
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))


all: format build test

style:
Expand Down Expand Up @@ -58,19 +57,18 @@ docker:
promu:
@GOOS=$(shell uname -s | tr A-Z a-z) \
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \
$(GO) get -u github.com/prometheus/promu
$(GO) build -modfile=tools/go.mod -o bin/promu github.com/prometheus/promu

ci-reviewdog: ## Runs reviewdog checks.
bin/golangci-lint run -c=.golangci-required.yml --out-format=line-number | bin/reviewdog -f=golangci-lint -level=error -reporter=github-pr-check
bin/golangci-lint run -c=.golangci.yml --out-format=line-number | bin/reviewdog -f=golangci-lint -level=error -reporter=github-pr-review
check:
bin/golangci-lint run -c=.golangci.yml --out-format=line-number

travis: build ci-reviewdog test-race codecov tarball docker

codecov: gocoverutil
@gocoverutil -coverprofile=coverage.txt test $(pkgs)
@bin/gocoverutil -coverprofile=coverage.txt test $(pkgs)
@curl -s https://codecov.io/bash | bash -s - -X fix

gocoverutil:
@$(GO) get -u github.com/AlekSi/gocoverutil
@$(GO) build -modfile=tools/go.mod -o bin/gocoverutil github.com/AlekSi/gocoverutil

.PHONY: all style format build test vet tarball docker promu
Loading

0 comments on commit c0d2255

Please sign in to comment.