Skip to content

Commit

Permalink
Merge pull request #10 from camaoag/ci_add_github_actions
Browse files Browse the repository at this point in the history
ci: add tests on all branches and release workflow
  • Loading branch information
secustor committed Jun 28, 2021
2 parents c7fd705 + 991ed2d commit 70b8acb
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 2 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Go

on:
push:
branches:
- '**'
- '!master'
pull_request:
branches: [ master ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ^1.16
id: go
- name: Get dependencies
run: make get-dependencies

- name: Ensure that all files are properly formatted
run: |
FILES=$(gofmt -s -l .)
if [ -n "${FILES}" ]; then
printf "Following files are not formatted: \n%s" "$FILES"
exit 1
fi
- name: GO vet
run: make vet

- name: Test
run: make unit-test

- name: Test building
run: make build
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release

on: workflow_dispatch

jobs:
release:
name: 'Release to GitHub'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Go setup
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ^1.16
id: go

- name: Get dependencies
run: make get-dependencies

# Go test
- name: Ensure that all files are properly formatted
run: |
FILES=$(gofmt -s -l .)
if [ -n "${FILES}" ]; then
printf "Following files are not formatted: \n%s" "$FILES"
exit 1
fi
- name: GO vet
run: make vet

- name: Test
run: make test

- name: Test building
run: make build

# Prepare release
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 13
- name: Add execution plugin
run: npm install @semantic-release/exec
- name: Release to GitHub
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: npx semantic-release
7 changes: 7 additions & 0 deletions .releaserc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
branches:
- master
plugins:
- "@semantic-release/commit-analyzer"
- "@semantic-release/release-notes-generator"
- - "@semantic-release/github"
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ KUBEBUILDER_VERSION=2.3.1
TEST_ZONE_NAME ?= example.com.

# Run tests
test: tests/kubebuilder
test: unit-test tests/kubebuilder
TEST_ZONE_NAME=$(TEST_ZONE_NAME) go test -v ./... -coverprofile cover.out

.PHONY: unit-test
unit-test:
go test -v -race ./pkg/...

tests/kubebuilder:
curl -fsSL https://github.com/kubernetes-sigs/kubebuilder/releases/download/v$(KUBEBUILDER_VERSION)/kubebuilder_$(KUBEBUILDER_VERSION)_$(OS)_$(ARCH).tar.gz -o kubebuilder-tools.tar.gz
mkdir tests/kubebuilder
Expand All @@ -36,12 +40,20 @@ tests/kubebuilder:
clean-kubebuilder:
rm -Rf tests/kubebuilder

compile:
build:
CGO_ENABLED=0 go build -v -o target/cert-manager-webhook-pinto main.go

docker-build:
docker build . --platform=$(OS)/$(ARCH) -t $(FULL_IMAGE):$(IMAGE_TAG)-$(ARCH)

.PHONY: get-dependencies
get-dependencies:
go get -v -t -d ./...

.PHONY: vet
vet:
go vet ./...

.PHONY: fmt-fix
fmt-fix:
gofmt -s -w .
Expand Down

0 comments on commit 70b8acb

Please sign in to comment.