Skip to content

Commit

Permalink
Basic CI for lint and test (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
sozercan committed Jan 21, 2021
1 parent 7df0cff commit 69850e5
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: test
on:
push:
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"

jobs:
lint:
name: "Lint"
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Install golangci-lint
run: |
mkdir -p $GITHUB_WORKSPACE/bin
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $GITHUB_WORKSPACE/bin v${GOLANGCILINT_VERSION}
env:
GOLANGCILINT_VERSION: 1.35.2

- name: Make lint
run: |
make lint
test:
name: "Unit test"
runs-on: ubuntu-latest
timeout-minutes: 5
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

- name: Install kubebuilder
run: |
curl -L -O "https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${KUBEBUILDER_VERSION}/kubebuilder_${KUBEBUILDER_VERSION}_linux_amd64.tar.gz" &&\
tar -zxvf kubebuilder_${KUBEBUILDER_VERSION}_linux_amd64.tar.gz &&\
sudo mv kubebuilder_${KUBEBUILDER_VERSION}_linux_amd64 /usr/local/kubebuilder
env:
KUBEBUILDER_VERSION: 2.3.1

- name: Unit test
run: make test

- name: Codecov Upload
uses: codecov/codecov-action@v1
with:
flags: unittests
file: ./cover.out
fail_ci_if_error: false
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
all: lint test

lint:
golangci-lint -v run ./... --timeout 5m

test:
go test ./... -coverprofile cover.out

0 comments on commit 69850e5

Please sign in to comment.