Skip to content

Commit 4c1d697

Browse files
Initial implementation
0 parents  commit 4c1d697

23 files changed

+918
-0
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: 🐛 Bug report
2+
description: Create a report to help us improve 🎉
3+
labels:
4+
- bug
5+
6+
body:
7+
- type: textarea
8+
id: description
9+
attributes:
10+
label: Description
11+
description: A clear and concise description of what the bug is.
12+
validations:
13+
required: true
14+
- type: textarea
15+
id: context
16+
attributes:
17+
label: Additional Context
18+
description: Add any other context about the problem here.
19+
validations:
20+
required: false
21+
- type: textarea
22+
id: logs
23+
attributes:
24+
label: Logs
25+
description: If applicable, add logs to help explain the bug.
26+
render: shell
27+
validations:
28+
required: false
29+
- type: textarea
30+
id: expected_behavior
31+
attributes:
32+
label: Expected Behavior
33+
description: A clear and concise description of what you expected to happen.
34+
validations:
35+
required: true
36+
- type: textarea
37+
id: reproduction_steps
38+
attributes:
39+
label: Steps To Reproduce
40+
description: Describe steps to reproduce the behavior
41+
validations:
42+
required: false
43+
- type: textarea
44+
id: version
45+
attributes:
46+
label: Versions
47+
placeholder: v1.2.3 [, Kubernetes 1.21]
48+
validations:
49+
required: true

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
blank_issues_enabled: false
2+
3+
contact_links:
4+
- name: ❓ Question
5+
url: https://github.com/appuio/promtool-jsonnet/discussions
6+
about: Ask or discuss with us, we're happy to help 🙋
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: 🚀 Feature request
2+
description: Suggest an idea for this project 💡
3+
labels:
4+
- enhancement
5+
6+
body:
7+
- type: textarea
8+
id: summary
9+
attributes:
10+
label: Summary
11+
value: |
12+
**As** role name\
13+
**I want** a feature or functionality\
14+
**So that** I get certain business value
15+
description: This user story helps us to quickly understand what this idea is about.
16+
validations:
17+
required: true
18+
- type: textarea
19+
id: context
20+
attributes:
21+
label: Context
22+
description: Add more information here. You are completely free regarding form and length.
23+
validations:
24+
required: true
25+
- type: textarea
26+
id: out_of_scope
27+
attributes:
28+
label: Out of Scope
29+
description: List aspects that are explicitly not part of this feature
30+
placeholder: |
31+
- ...
32+
- ...
33+
- ...
34+
validations:
35+
required: false
36+
- type: textarea
37+
id: links
38+
attributes:
39+
label: Further links
40+
description: URLs of relevant Git repositories, PRs, Issues, etc.
41+
placeholder: |
42+
- #567
43+
- https://kubernetes.io/docs/reference/
44+
validations:
45+
required: false
46+
- type: textarea
47+
id: acceptance_criteria
48+
attributes:
49+
label: Acceptance Criteria
50+
description: If you already have ideas what the detailed requirements are, please list them below in given-when-then expressions.
51+
placeholder: |
52+
- Given a precondition, when an action happens, then expect a result
53+
54+
```gherkin
55+
Given a precondition
56+
When an action happens
57+
Then expect a result
58+
```
59+
validations:
60+
required: false
61+
- type: textarea
62+
id: implementation_idea
63+
attributes:
64+
label: Implementation Ideas
65+
description: If applicable, shortly list possible implementation ideas
66+
validations:
67+
required: false

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Summary
2+
3+
* Short summary of what's included in the PR
4+
* Give special note to breaking changes
5+
6+
## Checklist
7+
8+
- [ ] Categorize the PR by setting a good title and adding one of the labels:
9+
`bug`, `enhancement`, `documentation`, `change`, `breaking`, `dependency`
10+
as they show up in the changelog
11+
- [ ] Update tests.
12+
- [ ] Link this PR to related issues.
13+
14+
<!--
15+
Remove items that do not apply. For completed items, change [ ] to [x].
16+
17+
NOTE: these things are not required to open a PR and can be done afterwards,
18+
while the PR is open.
19+
-->

.github/changelog-configuration.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"pr_template": "- ${{TITLE}} (#${{NUMBER}})",
3+
"categories": [
4+
{
5+
"title": "## 🚀 Features",
6+
"labels": [
7+
"enhancement"
8+
]
9+
},
10+
{
11+
"title": "## 🛠️ Minor Changes",
12+
"labels": [
13+
"change"
14+
]
15+
},
16+
{
17+
"title": "## 🔎 Breaking Changes",
18+
"labels": [
19+
"breaking"
20+
]
21+
},
22+
{
23+
"title": "## 🐛 Fixes",
24+
"labels": [
25+
"bug"
26+
]
27+
},
28+
{
29+
"title": "## 📄 Documentation",
30+
"labels": [
31+
"documentation"
32+
]
33+
},
34+
{
35+
"title": "## 🔗 Dependency Updates",
36+
"labels": [
37+
"dependency"
38+
]
39+
}
40+
],
41+
"template": "${{CATEGORIZED_COUNT}} changes since ${{FROM_TAG}}\n\n${{CHANGELOG}}"
42+
}

.github/common.libsonnet

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
local formatLabels = function(labels)
2+
local lf = std.join(', ', std.map(function(l) '%s="%s"' % [l, labels[l]], std.objectFields(labels)));
3+
'{%s}' % [lf];
4+
5+
// returns a series object with correctly formatted labels.
6+
// labels can be modified post creation using `_labels`.
7+
local series = function(name, labels, values) {
8+
_name:: name,
9+
_labels:: labels,
10+
series: self._name + formatLabels(self._labels),
11+
values: values,
12+
};
13+
14+
// returns a test object with the given series and samples. Sample interval is 30s
15+
// the evaluation time is set one hour in the future since all our queries operate on a 1h window
16+
local test = function(name, series, query, samples, interval='30s', eval_time='1h') {
17+
name: name,
18+
interval: interval,
19+
input_series: if std.isArray(series) then series else std.objectValues(series),
20+
promql_expr_test: [
21+
{
22+
expr: query,
23+
eval_time: eval_time,
24+
exp_samples: if std.isArray(samples) then samples else [samples],
25+
},
26+
],
27+
};
28+
29+
{
30+
series: series,
31+
formatLabels: formatLabels,
32+
test: test,
33+
}

.github/workflows/build.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
push:
8+
branches:
9+
- master
10+
11+
jobs:
12+
go:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Determine Go version from go.mod
18+
run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV
19+
20+
- uses: actions/setup-go@v4
21+
with:
22+
go-version: ${{ env.GO_VERSION }}
23+
24+
- uses: actions/cache@v3
25+
with:
26+
path: ~/go/pkg/mod
27+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
28+
restore-keys: |
29+
${{ runner.os }}-go-
30+
31+
- name: Run build
32+
run: make build

.github/workflows/lint.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Lint
2+
3+
on:
4+
pull_request: {}
5+
6+
jobs:
7+
lint:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- name: Determine Go version from go.mod
13+
run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV
14+
15+
- uses: actions/setup-go@v4
16+
with:
17+
go-version: ${{ env.GO_VERSION }}
18+
19+
- uses: actions/cache@v3
20+
with:
21+
path: ~/go/pkg/mod
22+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
23+
restore-keys: |
24+
${{ runner.os }}-go-
25+
26+
- name: Run linters
27+
run: make lint

.github/workflows/release.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
jobs:
9+
goreleaser:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Determine Go version from go.mod
17+
run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV
18+
19+
- uses: actions/setup-go@v4
20+
with:
21+
go-version: ${{ env.GO_VERSION }}
22+
23+
- name: Set up QEMU
24+
uses: docker/setup-qemu-action@v3
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
- uses: actions/cache@v3
30+
with:
31+
path: ~/go/pkg/mod
32+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
33+
restore-keys: |
34+
${{ runner.os }}-go-
35+
36+
- name: Login to ghcr.io
37+
uses: docker/login-action@v3
38+
with:
39+
registry: ghcr.io
40+
username: ${{ github.repository_owner }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Build changelog from PRs with labels
44+
id: build_changelog
45+
uses: mikepenz/release-changelog-builder-action@v3
46+
with:
47+
configuration: ".github/changelog-configuration.json"
48+
# PreReleases still get a changelog, but the next full release gets a diff since the last full release,
49+
# combining possible changelogs of all previous PreReleases in between.
50+
# PreReleases show a partial changelog since last PreRelease.
51+
ignorePreReleases: "${{ !contains(github.ref, '-rc') }}"
52+
outputFile: .github/release-notes.md
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
56+
- name: Publish releases
57+
uses: goreleaser/goreleaser-action@v4
58+
with:
59+
args: release --release-notes .github/release-notes.md
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
REGISTRY: ghcr.io
63+
IMAGE_NAME: ${{ github.repository }}

.github/workflows/test.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
push:
8+
branches:
9+
- master
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Determine Go version from go.mod
18+
run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV
19+
20+
- uses: actions/setup-go@v4
21+
with:
22+
go-version: ${{ env.GO_VERSION }}
23+
24+
- uses: actions/cache@v3
25+
with:
26+
path: ~/go/pkg/mod
27+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
28+
restore-keys: |
29+
${{ runner.os }}-go-
30+
31+
- name: Run tests
32+
run: make test

0 commit comments

Comments
 (0)