Skip to content

Commit

Permalink
Use Github Actions
Browse files Browse the repository at this point in the history
Replacing Travis CI.
  • Loading branch information
bpineau committed Nov 30, 2020
1 parent 61d84b2 commit 569463a
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 25 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI
on:
# don't double build on PRs.
pull_request:
push:
branches:
- master
tags-ignore:
- '**'

jobs:
build:
name: Build and test
runs-on: ubuntu-20.04
steps:

- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15
id: go

- name: Check out
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Create k8s cluster
uses: helm/kind-action@v1.0.0
with:
version: v0.9.0

- name: Build
run: make build

- name: Lint
run: make lint

- name: Test
run: make test

- name: E2e
run: make e2e

- name: Coverage
run: make coverall
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: release

on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:
goreleaser:
runs-on: ubuntu-20.04
steps:

- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Log into Docker registry
run: echo "${{ secrets.DOCKER_TOKEN }}" | docker login -u ${{ github.actor }} --password-stdin

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: v0.148.0
args: release --rm-dist --skip-sign
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46 changes: 23 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,44 @@ export GO111MODULE := on

all: build

tools:
which golangci-lint || ( \
curl -sfL "https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_VERSION}/golangci-lint-${GOLANGCI_VERSION}-linux-amd64.tar.gz" | \
tar xz --strip-components 1 --wildcards '*/golangci-lint' && \
chmod 755 golangci-lint && \
mv golangci-lint ${GOPATH}/bin/ \
)
which goveralls || go get github.com/mattn/goveralls

lint:
@# govet, errcheck etc are already on by default. this -E enable extra linters:
golangci-lint run -E gofmt,golint,unconvert,dupl,goimports,misspell,maligned,stylecheck
ifndef $(GOPATH)
GOPATH=$(shell go env GOPATH)
export GOPATH
endif

${GOPATH}/bin/golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
sh -s -- -b ${GOPATH}/bin v${GOLANGCI_VERSION}

${GOPATH}/bin/goveralls:
GO111MODULE=off go get github.com/mattn/goveralls

tools: ${GOPATH}/bin/golangci-lint ${GOPATH}/bin/goveralls

man:
go run assets/manpage.go

fmt:
go fmt ./...

build:
env CGO_ENABLED=0 go build

install:
env CGO_ENABLED=0 go install

clean:
rm -rf dist/
rm -rf dist/ profile.cov katafygio katafygio.8.gz
go clean

coverall:
goveralls -coverprofile=profile.cov -service=travis-ci -package github.com/bpineau/katafygio/pkg/...

e2e:
e2e: build
kubectl get ns >/dev/null || exit 1
go test -count=1 -v assets/e2e_test.go

test:
go test github.com/bpineau/katafygio/...
go test -race -cover -coverprofile=profile.cov github.com/bpineau/katafygio/...
go test -covermode atomic -coverprofile=profile.cov ./...

lint: ${GOPATH}/bin/golangci-lint
${GOPATH}/bin/golangci-lint run -E gofmt,golint,unconvert,dupl,goimports,misspell,maligned,stylecheck # -E are extra linters

coverall: ${GOPATH}/bin/goveralls
${GOPATH}/bin/goveralls -coverprofile=profile.cov -service=github

.PHONY: tools lint fmt install clean coverall test all
.PHONY: tools man build install clean e2e test lint coverall
2 changes: 1 addition & 1 deletion assets/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestMain(m *testing.M) {
ctx, cancel := context.WithCancel(context.Background())

go func() {
cmd := exec.CommandContext(ctx, "katafygio", "-e", dumpPath)
cmd := exec.CommandContext(ctx, "../katafygio", "-e", dumpPath)
err := cmd.Run()
if err != nil && err.Error() != "signal: killed" {
fmt.Printf("failed to spawn katafygio: %s", err.Error())
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const nonExistentPath = "\\/non / existent / $path$"
func TestClientSet(t *testing.T) {
here, _ := os.Getwd()
_ = os.Setenv("HOME", here+"/../../assets")
cs, err := New("", "", "")
cs, err := New("", "", here+"/../../assets/.kube/config")
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 569463a

Please sign in to comment.