Skip to content

Commit

Permalink
Add basic CI
Browse files Browse the repository at this point in the history
  • Loading branch information
glrf committed Jul 15, 2021
1 parent b0f8c4a commit 17a9936
Show file tree
Hide file tree
Showing 12 changed files with 324 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: "2"
plugins:
shellcheck:
enabled: true
govet:
enabled: true
gofmt:
enabled: true
golint:
enabled: true
checks:
return-statements:
enabled: false
exclude_patterns:
- "testdata/"
- "**/vendor/"
- "**/*_test.go"
- "config/"
- '**/spec/'
- '**/test/'
- '**/tests/'
- '**/zz_generated.deepcopy.go'
44 changes: 44 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: 🐛 Bug report
about: Create a report to help us improve 🎉
title: ''
labels: 'bug'

---

## Describe the bug

A clear and concise description of what the bug is.

## Additional context

Add any other context about the problem here.

## Logs

If applicable, add logs to help explain your problem.
```console

```

## Expected behavior

A clear and concise description of what you expected to happen.

## To Reproduce

Steps to reproduce the behavior:
1. Specs
```yaml

```
2. Commands
```bash

```

## Environment (please complete the following information):

- Image Version: e.g. v1.0
- K8s Version: e.g. v1.18
- K8s Distribution: e.g. OpenShift, Rancher, etc.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
36 changes: 36 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: 🚀 Feature request
about: Suggest an idea for this project 💡
title: ''
labels: 'enhancement'

---
## Summary

**As** "role name"\
**I want** "a feature or functionality"\
**So that** "I get certain business value"

## Context

Add more information here. You are completely free regarding form and length.

## Out of Scope

* List aspects that are explicitly not part of this feature

## Further links

* URLs of relevant Git repositories, PRs, Issues, etc.

## Acceptance criteria

<!--
If you already have ideas what the requirements are, please list them below in given-when-then expressions.
-->

* Given a precondition, when an action happens, then expect a result

## Implementation Ideas

* If applicable, shortly list possible implementation ideas
26 changes: 26 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Summary



<!--
Thank you for your pull request. Please provide a description above and
review the checklist below.
-->

## Checklist
<!--
Remove items that do not apply. For completed items, change [ ] to [x].
-->

- [ ] Keep pull requests small so they can be easily reviewed.
- [ ] Categorize the PR by setting a good title and adding one of the labels:
`bug`, `enhancement`, `documentation`, `change`, `breaking`,
as they show up in the changelog
- [ ] Update the documentation.
- [ ] Update tests.
- [ ] Link this PR to related issues.

<!--
NOTE: these things are not required to open a PR and can be done afterwards,
while the PR is open.
-->
30 changes: 30 additions & 0 deletions .github/changelog-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"pr_template": "- ${{TITLE}} (#${{NUMBER}})",
"categories": [
{
"title": "## 🚀 Features",
"labels": ["enhancement", "feature"]
},
{
"title": "## 🛠️ Minor Changes",
"labels": ["change"]
},
{
"title": "## 🔎 Breaking Changes",
"labels": ["breaking"]
},
{
"title": "## 🐛 Fixes",
"labels": ["bug", "fix"]
},
{
"title": "## 📄 Documentation",
"labels": ["documentation"]
},
{
"title": "## 🔗 Dependency Updates",
"labels": ["dependency"]
}
],
"template": "${{CATEGORIZED_COUNT}} changes since ${{FROM_TAG}}\n\n${{CHANGELOG}}"
}
26 changes: 26 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint

on:
pull_request: {}
push:
branches:
- master

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Determine Go version from go.mod
run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV
- uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run linters
run: make lint
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release

on:
push:
tags:
- "*"

jobs:
dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Determine Go version from go.mod
run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV
- uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Login to quay.io
run: docker login -u "${{ secrets.QUAY_IO_USERNAME }}" -p "${{ secrets.QUAY_IO_PASSWORD }}" quay.io
- name: Generate artifacts
run: make crd
- name: Build changelog from PRs with labels
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v2
with:
configuration: ".github/changelog-configuration.json"
# PreReleases still get a changelog, but the next full release gets a diff since the last full release,
# combining possible changelogs of all previous PreReleases in between. PreReleases show a partial changelog
# since last PreRelease.
ignorePreReleases: "${{ !contains(github.ref, '-rc') }}"
outputFile: .github/release-notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish releases
uses: goreleaser/goreleaser-action@v2
with:
args: release --release-notes .github/release-notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Determine Go version from go.mod
run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV
- uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run tests
run: make test
- name: Upload code coverage report to Code Climate
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: 818f46d463e8fffd6bc6358f89a4d29f80a11806162dcb03c630b3cbec2aeccc
with:
coverageLocations: cover.out:gocov
prefix: github.com/${{ github.repository }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bin/
testbin/

cover.out
.github/release-notes.md
29 changes: 29 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
archives:
- format: binary
name_template: "{{ .Binary }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
dockers:
- image_templates:
- "quay.io/vshn/statefulset-resize-controller:v{{ .Version }}"

# For prereleases, updating `latest` and the floating tags of the major
# version does not make sense. Only the image for the exact version should
# be pushed.
- "{{ if not .Prerelease }}quay.io/vshn/statefulset-resize-controller:v{{ .Major }}{{ end }}"

- "{{ if not .Prerelease }}quay.io/vshn/statefulset-resize-controller:latest{{ end }}"
release:
prerelease: auto
github:
owner: vshn
name: statefulset-resize-controller
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

all: fmt vet build

.PHONY: build
build:
go build

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

.PHONY: fmt
fmt: ## Run go fmt against code
go fmt ./...

.PHONY: vet
vet: ## Run go vet against code
go vet ./...

.PHONY: lint
lint: fmt vet ## Invokes the fmt and vet targets
@echo 'Check for uncommitted changes ...'
git diff --exit-code

0 comments on commit 17a9936

Please sign in to comment.