Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI configuration #4

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: 🐛 Bug report
description: Create a report to help us improve 🎉
labels:
- bug

body:
- type: textarea
id: description
attributes:
label: Description
description: A clear and concise description of what the bug is.
validations:
required: true
- type: textarea
id: context
attributes:
label: Additional Context
description: Add any other context about the problem here.
validations:
required: false
- type: textarea
id: logs
attributes:
label: Logs
description: If applicable, add logs to help explain the bug.
render: shell
validations:
required: false
- type: textarea
id: expected_behavior
attributes:
label: Expected Behavior
description: A clear and concise description of what you expected to happen.
validations:
required: true
- type: textarea
id: reproduction_steps
attributes:
label: Steps To Reproduce
description: Describe steps to reproduce the behavior
validations:
required: false
- type: textarea
id: version
attributes:
label: Versions
placeholder: v1.2.3 [, Kubernetes 1.21]
validations:
required: true
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
67 changes: 67 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: 🚀 Feature request
description: Suggest an idea for this project 💡
labels:
- enhancement

body:
- type: textarea
id: summary
attributes:
label: Summary
value: |
**As** role name\
**I want** a feature or functionality\
**So that** I get certain business value
description: This user story helps us to quickly understand what this idea is about.
validations:
required: true
- type: textarea
id: context
attributes:
label: Context
description: Add more information here. You are completely free regarding form and length.
validations:
required: true
- type: textarea
id: out_of_scope
attributes:
label: Out of Scope
description: List aspects that are explicitly not part of this feature
placeholder: |
- ...
- ...
- ...
validations:
required: false
- type: textarea
id: links
attributes:
label: Further links
description: URLs of relevant Git repositories, PRs, Issues, etc.
placeholder: |
- #567
- https://kubernetes.io/docs/reference/
validations:
required: false
- type: textarea
id: acceptance_criteria
attributes:
label: Acceptance Criteria
description: If you already have ideas what the detailed requirements are, please list them below in given-when-then expressions.
placeholder: |
- Given a precondition, when an action happens, then expect a result

```gherkin
Given a precondition
When an action happens
Then expect a result
```
validations:
required: false
- type: textarea
id: implementation_idea
attributes:
label: Implementation Ideas
description: If applicable, shortly list possible implementation ideas
validations:
required: false
19 changes: 19 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Summary

* Short summary of what's included in the PR
* Give special note to breaking changes

## Checklist

- [ ] Categorize the PR by setting a good title and adding one of the labels:
`bug`, `enhancement`, `documentation`, `change`, `breaking`, `dependency`
as they show up in the changelog
- [ ] Update tests.
- [ ] Link this PR to related issues.

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

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

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
go:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- 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@v4
with:
go-version: ${{ env.GO_VERSION }}

- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Run build
run: make build
27 changes: 27 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Lint

on:
pull_request: {}

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- 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@v4
with:
go-version: ${{ env.GO_VERSION }}

- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Run linters
run: make lint
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Release

on:
push:
tags:
- "*"

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: "${{ github.repository }}:${{ github.ref }}"

- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build changelog from PRs with labels
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v4
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: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}

- name: Create Release
uses: ncipollo/release-action@v1
with:
body: ${{steps.build_changelog.outputs.changelog}}
prerelease: "${{ contains(github.ref, '-rc') }}"
# Ensure target branch for release is "main"
commit: main
token: ${{ secrets.GITHUB_TOKEN }}
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Test

on:
pull_request:
branches:
- main
push:
branches:
- main

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

- 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@v4
with:
go-version: ${{ env.GO_VERSION }}

- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Run tests
run: make test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alerts_exporter
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.PHONY: all
all: lint test build

.PHONY: build
build:
go build -o alerts_exporter .

.PHONY: test
test:
go test ./...

.PHONY: lint
lint:
test -z "$$(go fmt ./...)"
go vet ./...