Skip to content

Commit 43900ae

Browse files
[DOP-11710] Automation of work with Github (#26)
* [DOP-11710] Automation of work with Github Co-authored-by: Maxim Martynov <msmarty5@mts.ru>
1 parent 2ea1e31 commit 43900ae

File tree

11 files changed

+263
-8
lines changed

11 files changed

+263
-8
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!-- Thank you for your contribution! -->
2+
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
3+
<!-- See https://github.com/MobileTeleSystems/syncmaster/blob/develop/CONTRIBUTING.rst for help on Contributing -->
4+
<!-- PLEASE DO **NOT** put issue ids in the PR title! Instead, add a descriptive title and put ids in the body -->
5+
6+
## Change Summary
7+
8+
<!-- Please give a short summary of the changes. -->
9+
10+
## Related issue number
11+
12+
<!-- Are there any issues opened that will be resolved by merging this change? -->
13+
<!-- WARNING: please use "fix #123" style references so the issue is closed when this PR is merged. -->
14+
15+
## Checklist
16+
17+
* [ ] Commit message and PR title is comprehensive
18+
* [ ] Keep the change as small as possible
19+
* [ ] Unit and integration tests for the changes exist
20+
* [ ] Tests pass on CI and coverage does not decrease
21+
* [ ] Documentation reflects the changes where applicable
22+
* [ ] `docs/changelog/next_release/<pull request or issue id>.<change type>.rst` file added describing change
23+
(see [CONTRIBUTING.rst](https://github.com/MobileTeleSystems/syncmaster/blob/develop/CONTRIBUTING.rst) for details.)
24+
* [ ] My PR is ready to review.

.github/dependabot.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Set update schedule for GitHub Actions
2+
3+
version: 2
4+
updates:
5+
- package-ecosystem: github-actions
6+
directory: /
7+
schedule:
8+
interval: weekly
9+
labels:
10+
- type:ci
11+
# https://til.simonwillison.net/github/dependabot-python-setup
12+
groups:
13+
github-actions:
14+
patterns:
15+
- '*'
16+
- package-ecosystem: pip
17+
directory: /
18+
schedule:
19+
interval: weekly
20+
labels:
21+
- type:dependency
22+
# https://til.simonwillison.net/github/dependabot-python-setup
23+
groups:
24+
python-packages:
25+
patterns:
26+
- '*'

.github/labels.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# config for https://github.com/marketplace/actions/github-labeler
2+
3+
- name: attention:help wanted
4+
description: Extra attention is needed
5+
color: bfdadc
6+
from_name: help wanted
7+
8+
- name: attention:invalid
9+
description: This doesn't seem right
10+
color: ea2357
11+
from_name: invalid
12+
13+
- name: ci:skip-changelog
14+
description: Add this label to skip changelog file check
15+
color: 04990f
16+
17+
- name: component:backend
18+
description: Backend-related changes
19+
color: '5319e7'
20+
21+
- name: component:worker
22+
description: Worker-related changes
23+
color: 75f526
24+
25+
- name: kind:bug
26+
description: Something isn't working
27+
color: d73a4a
28+
from_name: bug
29+
30+
- name: kind:feature
31+
description: New feature or request
32+
color: 389a3f
33+
34+
- name: kind:improvement
35+
description: Improvement of some existing feature
36+
color: 1a92c2
37+
from_name: enhancement
38+
39+
- name: kind:question
40+
description: Further information is requested
41+
color: 0e857c
42+
from_name: question
43+
44+
- name: resolution:duplicate
45+
description: This issue or pull request already exists
46+
color: cfd3d7
47+
from_name: duplicate
48+
49+
- name: resolution:wontfix
50+
description: This will not be worked on
51+
color: ec103b
52+
from_name: wontfix
53+
54+
- name: type:ci
55+
description: CI-related changes
56+
color: cdb0bd
57+
58+
- name: type:dependency
59+
description: Dependency-related changes
60+
color: 214efe
61+
62+
- name: type:documentation
63+
description: Improvements or additions to documentation
64+
color: 6b9f54
65+
from_name: documentation
66+
67+
- name: type:tests
68+
description: Tests-related changes
69+
color: 5cca5b

.github/workflows/automerge.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Automerge
2+
3+
on:
4+
pull_request_target:
5+
6+
jobs:
7+
automerge:
8+
name: Enable pull request automerge
9+
runs-on: ubuntu-latest
10+
if: github.event.pull_request.user.login == 'pre-commit-ci[bot]' || github.event.pull_request.user.login == 'dependabot[bot]'
11+
12+
steps:
13+
- uses: alexwilson/enable-github-automerge-action@2.0.0
14+
with:
15+
github-token: ${{ secrets.AUTOMERGE_TOKEN }}
16+
merge-method: REBASE
17+
18+
autoapprove:
19+
name: Automatically approve pull request
20+
needs: [automerge]
21+
runs-on: ubuntu-latest
22+
if: github.event.pull_request.user.login == 'pre-commit-ci[bot]' || github.event.pull_request.user.login == 'dependabot[bot]'
23+
24+
steps:
25+
- uses: hmarr/auto-approve-action@v4
26+
with:
27+
github-token: ${{ secrets.AUTOMERGE_TOKEN }}

.github/workflows/changelog.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Changelog
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, labeled, unlabeled, reopened]
6+
branches-ignore:
7+
- master
8+
9+
env:
10+
DEFAULT_PYTHON: '3.12'
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
check-changelog:
17+
name: Changelog Entry Check
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 10
20+
if: "!contains(github.event.pull_request.labels.*.name, 'ci:skip-changelog') && github.event.pull_request.user.login != 'pre-commit-ci[bot]' && github.event.pull_request.user.login != 'dependabot[bot]'"
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
28+
id: python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: ${{ env.DEFAULT_PYTHON }}
32+
33+
- name: Install poetry
34+
uses: snok/install-poetry@v1
35+
36+
- name: Cache poetry
37+
uses: actions/cache@v4
38+
with:
39+
path: ~/.cache/pypoetry
40+
key: ${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-changelog-${{ hashFiles('**/poetry.lock') }}
41+
restore-keys: |
42+
${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-changelog-${{ hashFiles('**/poetry.lock') }}
43+
${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-changelog-
44+
${{ runner.os }}-python
45+
${{ runner.os }}-
46+
47+
- name: Install dependencies
48+
run: |
49+
poetry install --no-root --with docs --without dev,test
50+
51+
- name: Check changelog entry exists
52+
run: |
53+
if [ ! -s docs/changelog/next_release/${{ github.event.pull_request.number }}.*.rst ]; then
54+
echo "Please add corresponding file 'docs/changelog/next_release/<issue number>.<change type>.rst' with changes description"
55+
exit 1
56+
fi
57+
58+
- name: Validate changelog
59+
run: |-
60+
# Fetch the pull request' base branch so towncrier will be able to
61+
# compare the current branch with the base branch.
62+
git fetch --no-tags origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
63+
poetry run towncrier check --compare-with origin/${{ github.base_ref }}
64+
poetry run towncrier --draft
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Repo labels sync
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
paths:
8+
- .github/labels.yml
9+
- .github/workflows/repo-labels-sync.yml
10+
pull_request:
11+
paths:
12+
- .github/labels.yml
13+
- .github/workflows/repo-labels-sync.yml
14+
workflow_dispatch:
15+
16+
jobs:
17+
labeler:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Run Labeler
24+
uses: crazy-max/ghaction-github-labeler@v5
25+
with:
26+
github-token: ${{ secrets.GITHUB_TOKEN }}
27+
yaml-file: .github/labels.yml
28+
dry-run: ${{ github.event_name == 'pull_request' }}

CONTRIBUTING.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,8 @@ Then open Gitlab interface and `create merge request <https://docs.gitlab.com/ee
186186
Please follow guide from MR body template.
187187

188188
After pull request is created, it get a corresponding number, e.g. 123 (``mr_number``).
189+
190+
How to skip change notes check?
191+
-------------------------------
192+
193+
Just add ```ci:skip-changelog``` label to pull request.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Automation of work with Github.

poetry.lock

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ sphinx-argparse = {version = "^0.2.5", python = ">=3.8"}
216216
# sphinx-plantuml = {version = "^1.0.0", python = ">=3.8"}
217217

218218
[tool.towncrier]
219-
name = "Horizon"
220-
package = "horizon"
219+
name = "Syncmaster"
220+
package = "syncmaster"
221221
filename = "docs/changelog/NEXT_RELEASE.rst"
222222
directory = "docs/changelog/next_release/"
223223
title_format = "{version} ({project_date})"
@@ -261,4 +261,12 @@ showcontent = true
261261
[[tool.towncrier.type]]
262262
directory = "misc"
263263
name = "Misc"
264-
showcontent = true
264+
showcontent = true
265+
266+
[tool.poetry_bumpversion.file."syncmaster/__init__.py"]
267+
search = '_raw_version = "{current_version}"'
268+
replace = '_raw_version = "{new_version}"'
269+
270+
[tool.poetry_bumpversion.file."docs/conf.py"]
271+
search = 'ver = Version.parse("{current_version}")'
272+
replace = 'ver = Version.parse("{new_version}")'

0 commit comments

Comments
 (0)