Skip to content

Commit 9acf5bc

Browse files
committed
build: initial commit
1 parent 20bcc21 commit 9acf5bc

32 files changed

+1424
-3
lines changed

.commitlintrc.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const Configuration = {
2+
/*
3+
* Inherit rules from conventional commits.
4+
*/
5+
extends: ["@commitlint/config-conventional"],
6+
7+
/*
8+
* Any rules defined here will override rules from parent.
9+
*/
10+
rules: {
11+
"body-leading-blank": [2, "always"], // warning -> error
12+
"body-max-line-length": [1, "always", 100], // error -> warning
13+
"footer-leading-blank": [2, "always"], // warning -> error
14+
"footer-max-length": [1, "always", 100], // error -> warning
15+
"header-max-length": [1, "always", 100], // error -> warning
16+
},
17+
};
18+
19+
export default Configuration;
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
name: Bug report
3+
description: Create a bug report.
4+
title: "[Bug] "
5+
labels:
6+
- bug
7+
assignees:
8+
- thomasleplus
9+
body:
10+
- type: markdown
11+
attributes:
12+
value: |
13+
Thanks for taking the time to fill out this bug report!
14+
- type: checkboxes
15+
attributes:
16+
label: Is there an existing issue for this?
17+
description: Search to see if an issue already exists for the bug you encountered.
18+
options:
19+
- label: I have searched the existing issues
20+
required: true
21+
- type: textarea
22+
attributes:
23+
label: Current Behavior
24+
description: A concise description of what you're experiencing.
25+
validations:
26+
required: true
27+
- type: textarea
28+
attributes:
29+
label: Expected Behavior
30+
description: A concise description of what you expected to happen.
31+
validations:
32+
required: true
33+
- type: textarea
34+
attributes:
35+
label: version
36+
description: |
37+
Version where you observed this issue
38+
placeholder: |
39+
vX.Y.Z
40+
render: markdown
41+
validations:
42+
required: true
43+
- type: textarea
44+
id: logs
45+
attributes:
46+
label: Relevant log output
47+
description: |
48+
Copy and paste any relevant log output.
49+
This will be automatically formatted into code, so no need for backticks.
50+
Enable debug logging, either on GitHub Actions, or when running locally.
51+
render: shell
52+
validations:
53+
required: true
54+
- type: textarea
55+
attributes:
56+
label: Steps To Reproduce
57+
description: |
58+
Steps to reproduce the issue.
59+
placeholder: |
60+
1. In this environment...
61+
1. With this config...
62+
1. Run '...'
63+
1. See error...
64+
validations:
65+
required: true
66+
- type: textarea
67+
attributes:
68+
label: Anything else?
69+
description: |
70+
Links? References? Anything that will give us more context about the issue you are encountering!
71+
72+
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
73+
validations:
74+
required: false
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: Feature request
3+
description: Suggest a new feature for this project.
4+
title: "[Feature] "
5+
labels:
6+
- enhancement
7+
assignees:
8+
- thomasleplus
9+
body:
10+
- type: markdown
11+
attributes:
12+
value: |
13+
Thanks for taking the time to fill out this feature request!
14+
- type: textarea
15+
attributes:
16+
label: Feature description
17+
description: |
18+
A clear and concise description of what the desired feature is and why it would be useful.
19+
render: markdown
20+
validations:
21+
required: true
22+
- type: textarea
23+
attributes:
24+
label: Anything else?
25+
description: |
26+
If you think that there are some implementation details to be taken into consideration, or anything that is not obvious from the previous description, please specify it here.
27+
28+
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
29+
render: markdown
30+
validations:
31+
required: false
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Question
3+
description: Ask a question.
4+
title: "[Question] "
5+
labels:
6+
- question
7+
assignees:
8+
- thomasleplus
9+
body:
10+
- type: markdown
11+
attributes:
12+
value: |
13+
Thanks for taking the time to fill out this feature request!
14+
- type: textarea
15+
attributes:
16+
label: What is your question?
17+
description: Please include as many details and examples as possible.
18+
render: markdown
19+
validations:
20+
required: true

.github/dependabot.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
version: 2
3+
updates:
4+
- package-ecosystem: "docker"
5+
directory: "/rst"
6+
schedule:
7+
interval: "daily"
8+
commit-message:
9+
prefix: chore(deps)
10+
- package-ecosystem: "github-actions"
11+
directory: "/"
12+
schedule:
13+
interval: "daily"
14+
cooldown:
15+
default-days: 7
16+
commit-message:
17+
prefix: ci(deps)

.github/pull_request_template.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!-- prettier-ignore-start -->
2+
<!-- markdownlint-disable-next-line MD041 -->
3+
## Readiness checklist
4+
<!-- prettier-ignore-end -->
5+
6+
Please check the boxes below to confirm that you have followed the
7+
required guidelines for contributions:
8+
9+
- [ ] All commits are [signed](https://docs.github.com/en/authentication/managing-commit-signature-verification).
10+
- [ ] The title for this pull request is the same as the first commit's message and it follows the [conventional commits specification](https://www.conventionalcommits.org). See commit history for examples.
11+
- [ ] If this pull request includes code changes, they were all properly tested. Automated tests were also included where possible.
12+
- [ ] If applicable, this pull request includes the relevant documentation for this change.
13+
- [ ] If this pull request is related to an existing issue, you can use the same description below but in any case include a [link to the issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue) like `Fixes #ISSUE_NUMBER.` or `Closes #ISSUE_NUMBER.`.
14+
15+
<!-- prettier-ignore-start -->
16+
<!-- markdownlint-disable-next-line MD041 -->
17+
## Description
18+
<!-- prettier-ignore-end -->

.github/release.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- no-release-notes
5+
categories:
6+
- title: "New Features :sparkles:"
7+
labels:
8+
- feat
9+
- title: "Bug Fixes :bug:"
10+
labels:
11+
- fix
12+
- title: "Dependency Upgrades :package:"
13+
labels:
14+
- dependencies
15+
- title: "Other Changes :broom:"
16+
labels:
17+
- "*"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: APK Check Versions
3+
4+
on:
5+
schedule:
6+
- cron: "0 0 * * 0"
7+
workflow_dispatch:
8+
9+
permissions: {}
10+
11+
jobs:
12+
apk-check-versions:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check the versions
16+
shell: bash
17+
run: |
18+
set -euo pipefail
19+
IFS=$'\n\t'
20+
docker run --pull always -t --user root --entrypoint /bin/sh "leplusorg/${GITHUB_REPOSITORY#*/docker-}:main" -c 'if apk update && apk -u list | tee -a /dev/stderr | grep -q -e .; then exit 1; fi'

.github/workflows/automerge.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
name: "Dependabot auto-merge"
3+
on: pull_request
4+
5+
permissions:
6+
actions: write
7+
contents: write
8+
pull-requests: write
9+
10+
jobs:
11+
automerge:
12+
runs-on: ubuntu-latest
13+
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
14+
steps:
15+
- name: Enable auto-merge for Dependabot PRs
16+
shell: bash
17+
run: |
18+
set -euo pipefail
19+
IFS=$'\n\t'
20+
# Checking the PR title is a poor substitute for the actual PR changes
21+
# but as long as this is used only with dependabot PRs,
22+
# it should be safe to assume that the title is not misleading.
23+
regexp='[Bb]ump .* from [0-9]+\.[0-9]+(\.[0-9]+)?(\.[0-9]+)?(\-[a-z]+)? to [0-9]+\.[0-9]+(\.[0-9]+)?(\.[0-9]+)?(\-[a-z]+)?( in .*)?$'
24+
if ! [[ "${PR_TITLE}" =~ ${regexp} ]] ; then
25+
echo 'Non-semver upgrade, needs manual review.'
26+
elif [ "${BASH_REMATCH[3]}" != "${BASH_REMATCH[6]}" ] ; then
27+
echo 'Version suffixes do not match, needs manual review.'
28+
else
29+
echo 'Automated review approval.'
30+
gh pr review --approve "${PR_URL}"
31+
fi
32+
gh pr merge --auto --squash "${PR_URL}"
33+
env:
34+
PR_TITLE: ${{github.event.pull_request.title}}
35+
PR_URL: ${{github.event.pull_request.html_url}}
36+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/check-pr.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
name: "Check PR"
3+
on: pull_request
4+
5+
permissions:
6+
pull-requests: write
7+
8+
jobs:
9+
check-pr:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check commits
13+
shell: bash
14+
run: |
15+
set -euo pipefail
16+
IFS=$'\n\t'
17+
# Check the commits
18+
commits_json=$(curl -fsSL -H "Authorization: token ${GITHUB_TOKEN}" "${PR_COMMITS_URL}")
19+
echo -n 'Commits: '
20+
echo "${commits_json}" | jq '.'
21+
commit_count="$(echo "${commits_json}" | jq -r 'length')"
22+
# Check first commit message (except for dependabot who is inconsistent)
23+
if [ "${commit_count}" -eq 1 ] && [ "${GITHUB_ACTOR}" != 'dependabot[bot]' ] ; then
24+
commit_title="$(echo "${commits_json}" | jq -r '.[0].commit.message' | head -n 1)"
25+
echo "Commit title: ${commit_title}"
26+
if [[ "${commit_title}" != "${PR_TITLE}" ]] ; then
27+
>&2 echo 'Single commit must have same title as PR.'
28+
exit 1
29+
fi
30+
fi
31+
# Check that all commits are signed
32+
for ((i = 0 ; i < commit_count ; i++ )); do
33+
if [[ "$(echo "${commits_json}" | jq -r ".[${i}].commit.verification.verified")" == 'false' ]] ; then
34+
>&2 echo "Commit $(echo "${commits_json}" | jq -r ".[${i}].sha") must be signed."
35+
exit 1
36+
fi
37+
done
38+
env:
39+
PR_TITLE: ${{github.event.pull_request.title}}
40+
PR_COMMITS_URL: ${{github.event.pull_request.commits_url}}
41+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
42+
- name: Update PR labels
43+
shell: bash
44+
run: |
45+
set -euo pipefail
46+
IFS=$'\n\t'
47+
# Check PR title is a conventional commit message
48+
regexp='^((build|chore|ci|docs|feat|fix|perf|refactor|style|test)(\([a-zA-Z0-9\-]+\))?)!?: .*$'
49+
if ! [[ "${PR_TITLE}" =~ ${regexp} ]] ; then
50+
>&2 echo 'Non conventional PR title.'
51+
exit 1
52+
fi
53+
scoped_type="${BASH_REMATCH[1]}"
54+
type="${BASH_REMATCH[2]}"
55+
add_labels=()
56+
remove_labels=()
57+
# Remove the labels we manage
58+
for label in build chore ci docs feat fix perf refactor test style ; do
59+
if [[ "${label}" == "${type}" ]]; then
60+
echo "Label to add: ${label}"
61+
if [[ "${PR_LABELS}" == *"${label}"* ]] ; then
62+
echo "Label ${label} already present"
63+
else
64+
add_labels+=("${label}")
65+
fi
66+
else
67+
echo "Label to remove: ${label}"
68+
if [[ "${PR_LABELS}" == *"${label}"* ]] ; then
69+
remove_labels+=("${label}")
70+
else
71+
echo "Label ${label} not present"
72+
fi
73+
fi
74+
done
75+
# If scope is dependency-related, add 'dependencies' label
76+
regexp2='^[a-zA-Z0-9]+\([a-zA-Z0-9\-]*deps\)$'
77+
if [[ "${scoped_type}" =~ ${regexp2} ]] ; then
78+
echo "Label to add: dependencies"
79+
if [[ "${PR_LABELS}" == *"dependencies"* ]] ; then
80+
echo "Label dependencies already present"
81+
else
82+
add_labels+=('dependencies')
83+
fi
84+
# otherwise do not remove it since we are not the only ones to manage this label (e.g. dependabot)
85+
fi
86+
# For certain types/scopes, add 'no-release-notes' label
87+
if [[ "${type}" == 'chore' \
88+
|| "${type}" == 'ci' \
89+
|| "${type}" == 'docs' \
90+
|| "${type}" == 'style' \
91+
|| "${type}" == 'test' ]] ; then
92+
echo "Label to add: no-release-notes"
93+
if [[ "${PR_LABELS}" == *"no-release-notes"* ]] ; then
94+
echo "Label no-release-notes already present"
95+
else
96+
add_labels+=('no-release-notes')
97+
fi
98+
else
99+
echo "Label to remove: no-release-notes"
100+
if [[ "${PR_LABELS}" == *"no-release-notes"* ]] ; then
101+
remove_labels+=('no-release-notes')
102+
else
103+
echo "Label no-release-notes not present"
104+
fi
105+
fi
106+
# Update the labels
107+
function join_by { local IFS="$1"; shift; echo "$*"; }
108+
if [ ${#add_labels[@]} -eq 0 ] && [ ${#remove_labels[@]} -eq 0 ]; then
109+
echo 'No label to change'
110+
elif [ ${#add_labels[@]} -eq 0 ]; then
111+
echo "Removing labels: $(join_by , "${remove_labels[@]}")"
112+
gh pr edit "${PR_URL}" --remove-label "$(join_by , "${remove_labels[@]}")"
113+
elif [ ${#remove_labels[@]} -eq 0 ]; then
114+
echo "Adding labels: $(join_by , "${add_labels[@]}")"
115+
gh pr edit "${PR_URL}" --add-label "$(join_by , "${add_labels[@]}")"
116+
else
117+
echo "Adding labels: $(join_by , "${add_labels[@]}")"
118+
echo "Removing labels: $(join_by , "${remove_labels[@]}")"
119+
gh pr edit "${PR_URL}" --add-label "$(join_by , "${add_labels[@]}")" --remove-label "$(join_by , "${remove_labels[@]}")"
120+
fi
121+
env:
122+
PR_TITLE: ${{github.event.pull_request.title}}
123+
PR_LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }}
124+
PR_URL: ${{github.event.pull_request.html_url}}
125+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 commit comments

Comments
 (0)