Skip to content

Commit 8ac4012

Browse files
committed
Use Github Actions
Replacing Travis CI.
1 parent 61d84b2 commit 8ac4012

File tree

7 files changed

+110
-69
lines changed

7 files changed

+110
-69
lines changed

.github/workflows/ci.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI
2+
on:
3+
# don't double build on PRs.
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
tags-ignore:
9+
- '**'
10+
11+
jobs:
12+
build:
13+
name: Build and test
14+
runs-on: ubuntu-20.04
15+
steps:
16+
17+
- name: Set up Go 1.15
18+
uses: actions/setup-go@v2
19+
with:
20+
go-version: 1.15
21+
id: go
22+
23+
- name: Check out
24+
uses: actions/checkout@v2
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Create k8s cluster
29+
uses: helm/[email protected]
30+
with:
31+
version: v0.9.0
32+
33+
- name: Build
34+
run: make build
35+
36+
- name: Lint
37+
run: make lint
38+
39+
- name: Test
40+
run: make test
41+
42+
- name: E2e
43+
run: make e2e
44+
45+
- name: Coverage
46+
run: make coverall
47+
env:
48+
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: release
2+
3+
on:
4+
push:
5+
# Sequence of patterns matched against refs/tags
6+
tags:
7+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
8+
9+
jobs:
10+
goreleaser:
11+
runs-on: ubuntu-20.04
12+
steps:
13+
14+
- name: Set up Go 1.15
15+
uses: actions/setup-go@v2
16+
with:
17+
go-version: 1.15
18+
id: go
19+
20+
- name: Check out code
21+
uses: actions/checkout@v2
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Log into Docker registry
26+
run: echo "${{ secrets.DOCKER_TOKEN }}" | docker login -u ${{ github.actor }} --password-stdin
27+
28+
- name: Run GoReleaser
29+
uses: goreleaser/[email protected]
30+
with:
31+
version: v0.148.0
32+
args: release --rm-dist --skip-sign
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.travis.yml

-42
This file was deleted.

Makefile

+25-24
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,45 @@ export GO111MODULE := on
33

44
all: build
55

6-
tools:
7-
which golangci-lint || ( \
8-
curl -sfL "https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_VERSION}/golangci-lint-${GOLANGCI_VERSION}-linux-amd64.tar.gz" | \
9-
tar xz --strip-components 1 --wildcards '*/golangci-lint' && \
10-
chmod 755 golangci-lint && \
11-
mv golangci-lint ${GOPATH}/bin/ \
12-
)
13-
which goveralls || go get github.com/mattn/goveralls
14-
15-
lint:
16-
@# govet, errcheck etc are already on by default. this -E enable extra linters:
17-
golangci-lint run -E gofmt,golint,unconvert,dupl,goimports,misspell,maligned,stylecheck
6+
ifndef $(GOPATH)
7+
GOPATH=$(shell go env GOPATH)
8+
export GOPATH
9+
endif
10+
11+
${GOPATH}/bin/golangci-lint:
12+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
13+
sh -s -- -b ${GOPATH}/bin v${GOLANGCI_VERSION}
14+
15+
${GOPATH}/bin/goveralls:
16+
GO111MODULE=off go get github.com/mattn/goveralls
17+
18+
tools: ${GOPATH}/bin/golangci-lint ${GOPATH}/bin/goveralls
1819

1920
man:
2021
go run assets/manpage.go
2122

22-
fmt:
23-
go fmt ./...
24-
2523
build:
2624
env CGO_ENABLED=0 go build
2725

2826
install:
2927
env CGO_ENABLED=0 go install
3028

3129
clean:
32-
rm -rf dist/
30+
rm -rf dist/ profile.cov katafygio katafygio.8.gz
3331
go clean
3432

35-
coverall:
36-
goveralls -coverprofile=profile.cov -service=travis-ci -package github.com/bpineau/katafygio/pkg/...
37-
38-
e2e:
39-
kubectl get ns >/dev/null || exit 1
33+
e2e: build
34+
kubectl version
4035
go test -count=1 -v assets/e2e_test.go
4136

4237
test:
43-
go test github.com/bpineau/katafygio/...
44-
go test -race -cover -coverprofile=profile.cov github.com/bpineau/katafygio/...
38+
go test -covermode atomic -coverprofile=profile.cov ./...
39+
40+
lint: ${GOPATH}/bin/golangci-lint
41+
${GOPATH}/bin/golangci-lint run --timeout 5m \
42+
-E gofmt,golint,unconvert,dupl,goimports,maligned,stylecheck # extra linters
43+
44+
coverall: ${GOPATH}/bin/goveralls
45+
${GOPATH}/bin/goveralls -coverprofile=profile.cov -service=github
4546

46-
.PHONY: tools lint fmt install clean coverall test all
47+
.PHONY: tools man build install clean e2e test lint coverall

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# katafygio
22

3-
[![Build Status](https://travis-ci.org/bpineau/katafygio.svg?branch=master)](https://travis-ci.org/bpineau/katafygio)
3+
[![Build Status](https://github.com/bpineau/katafygio/workflows/CI/badge.svg)](https://github.com/bpineau/katafygio/actions)
44
[![Coverage Status](https://coveralls.io/repos/github/bpineau/katafygio/badge.svg?branch=master)](https://coveralls.io/github/bpineau/katafygio?branch=master)
55
[![Go Report Card](https://goreportcard.com/badge/github.com/bpineau/katafygio)](https://goreportcard.com/report/github.com/bpineau/katafygio)
66

assets/e2e_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestMain(m *testing.M) {
6464
ctx, cancel := context.WithCancel(context.Background())
6565

6666
go func() {
67-
cmd := exec.CommandContext(ctx, "katafygio", "-e", dumpPath)
67+
cmd := exec.CommandContext(ctx, "../katafygio", "-e", dumpPath)
6868
err := cmd.Run()
6969
if err != nil && err.Error() != "signal: killed" {
7070
fmt.Printf("failed to spawn katafygio: %s", err.Error())

pkg/client/client_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const nonExistentPath = "\\/non / existent / $path$"
1111
func TestClientSet(t *testing.T) {
1212
here, _ := os.Getwd()
1313
_ = os.Setenv("HOME", here+"/../../assets")
14-
cs, err := New("", "", "")
14+
cs, err := New("", "", here+"/../../assets/.kube/config")
1515
if err != nil {
1616
t.Fatal(err)
1717
}

0 commit comments

Comments
 (0)