Skip to content

Commit 910fb15

Browse files
authored
Merge pull request #64 from MC-kit/devel
Devel
2 parents 9f13b65 + b3d7dab commit 910fb15

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+456
-133
lines changed

.flake8

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ exclude=
3030
per-file-ignores =
3131
noxfile.py:ANN,DAR101
3232
config.py:ANN001,ANN201
33-
tests/*:S101,ANN,DAR100,D100,D103,DAR101,DAR103
33+
src/tests/*:S101,ANN,DAR100,D100,D103,DAR101,DAR103
3434
ignore-decorators=click,pytest
3535
docstring-convention = google
3636
rst-roles = class,const,func,meth,mod,ref
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Clean Workflow Logs
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
# days_old:
7+
# description: "The amount of days old to delete"
8+
# default: "7"
9+
# required: false
10+
dry:
11+
description: "Dry run"
12+
default: "false"
13+
required: false
14+
jobs:
15+
clean-logs:
16+
runs-on: ubuntu-latest
17+
steps:
18+
# - uses: igorjs/gh-actions-clean-workflow@v1
19+
# with:
20+
# token: ${{ secrets.GITHUB_TOKEN }}
21+
# owner: ${{ github.repository_owner }}
22+
# repo: ${{ github.event.repository.name }}
23+
# days_old: ${{ github.event.inputs.days_old }}
24+
- name: Clean workflow runs
25+
uses: dmvict/[email protected]
26+
with:
27+
token: ${{ secrets.MCKIT_GITHUB_TOKEN }}
28+
save_period: 30
29+
save_min_runs_number: 10
30+
dry: ${{ github.event.inputs.dry }}

.github/workflows/combine-prs.yml

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: 'Combine PRs'
2+
#
3+
# Source:
4+
# https://dev.to/denvercoder1/keeping-your-dependencies-updated-automatically-with-dependabot-299g
5+
# https://github.com/hrvey/combine-prs-workflow/blob/master/combine-prs.yml
6+
#
7+
# Controls when the action will run - in this case triggered manually
8+
on:
9+
workflow_dispatch:
10+
inputs:
11+
branchPrefix:
12+
description: 'Branch prefix to find combinable PRs based on'
13+
required: true
14+
default: 'dependabot'
15+
mustBeGreen:
16+
description: 'Only combine PRs that are green (status is success)'
17+
required: true
18+
default: true
19+
combineBranchName:
20+
description: 'Name of the branch to combine PRs into'
21+
required: true
22+
default: 'combine-prs-branch'
23+
ignoreLabel:
24+
description: 'Exclude PRs with this label'
25+
required: true
26+
default: 'nocombine'
27+
28+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
29+
jobs:
30+
# This workflow contains a single job called "combine-prs"
31+
combine-prs:
32+
# The type of runner that the job will run on
33+
runs-on: ubuntu-latest
34+
35+
# Steps represent a sequence of tasks that will be executed as part of the job
36+
steps:
37+
- uses: actions/github-script@v3
38+
id: fetch-branch-names
39+
name: Fetch branch names
40+
with:
41+
github-token: ${{secrets.GITHUB_TOKEN}}
42+
script: |
43+
const pulls = await github.paginate('GET /repos/:owner/:repo/pulls', {
44+
owner: context.repo.owner,
45+
repo: context.repo.repo
46+
});
47+
branches = [];
48+
prs = [];
49+
base_branch = null;
50+
for (const pull of pulls) {
51+
const branch = pull['head']['ref'];
52+
console.log('Pull for branch: ' + branch);
53+
if (branch.startsWith('${{ github.event.inputs.branchPrefix }}')) {
54+
console.log('Branch matched: ' + branch);
55+
statusOK = true;
56+
if(${{ github.event.inputs.mustBeGreen }}) {
57+
console.log('Checking green status: ' + branch);
58+
const statuses = await github.paginate('GET /repos/{owner}/{repo}/commits/{ref}/status', {
59+
owner: context.repo.owner,
60+
repo: context.repo.repo,
61+
ref: branch
62+
});
63+
if(statuses.length > 0) {
64+
const latest_status = statuses[0]['state'];
65+
console.log('Validating status: ' + latest_status);
66+
if(latest_status != 'success') {
67+
console.log('Discarding ' + branch + ' with status ' + latest_status);
68+
statusOK = false;
69+
}
70+
}
71+
}
72+
console.log('Checking labels: ' + branch);
73+
const labels = pull['labels'];
74+
for(const label of labels) {
75+
const labelName = label['name'];
76+
console.log('Checking label: ' + labelName);
77+
if(labelName == '${{ github.event.inputs.ignoreLabel }}') {
78+
console.log('Discarding ' + branch + ' with label ' + labelName);
79+
statusOK = false;
80+
}
81+
}
82+
if (statusOK) {
83+
console.log('Adding branch to array: ' + branch);
84+
branches.push(branch);
85+
prs.push('#' + pull['number'] + ' ' + pull['title']);
86+
base_branch = pull['base']['ref'];
87+
}
88+
}
89+
}
90+
91+
if (branches.length == 0) {
92+
core.setFailed('No PRs/branches matched criteria');
93+
return;
94+
}
95+
96+
core.setOutput('base-branch', base_branch);
97+
core.setOutput('prs-string', prs.join('\n'));
98+
99+
combined = branches.join(' ')
100+
console.log('Combined: ' + combined);
101+
return combined
102+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
103+
- uses: actions/[email protected]
104+
with:
105+
fetch-depth: 0
106+
# Creates a branch with other PR branches merged together
107+
- name: Created combined branch
108+
env:
109+
BASE_BRANCH: ${{ steps.fetch-branch-names.outputs.base-branch }}
110+
BRANCHES_TO_COMBINE: ${{ steps.fetch-branch-names.outputs.result }}
111+
COMBINE_BRANCH_NAME: ${{ github.event.inputs.combineBranchName }}
112+
run: |
113+
echo "$BRANCHES_TO_COMBINE"
114+
sourcebranches="${BRANCHES_TO_COMBINE%\"}"
115+
sourcebranches="${sourcebranches#\"}"
116+
117+
basebranch="${BASE_BRANCH%\"}"
118+
basebranch="${basebranch#\"}"
119+
120+
git config pull.rebase false
121+
git config user.name github-actions
122+
git config user.email [email protected]
123+
124+
git branch $COMBINE_BRANCH_NAME $basebranch
125+
git checkout $COMBINE_BRANCH_NAME
126+
git pull origin $sourcebranches --no-edit
127+
git push origin $COMBINE_BRANCH_NAME
128+
# Creates a PR with the new combined branch
129+
- uses: actions/github-script@v3
130+
name: Create Combined Pull Request
131+
env:
132+
PRS_STRING: ${{ steps.fetch-branch-names.outputs.prs-string }}
133+
with:
134+
github-token: ${{secrets.GITHUB_TOKEN}}
135+
script: |
136+
const prString = process.env.PRS_STRING;
137+
const body = 'This PR was created by the Combine PRs action by combining the following PRs:\n' + prString;
138+
await github.pulls.create({
139+
owner: context.repo.owner,
140+
repo: context.repo.repo,
141+
title: 'Combined PR',
142+
head: '${{ github.event.inputs.combineBranchName }}',
143+
base: '${{ steps.fetch-branch-names.outputs.base-branch }}',
144+
body: body
145+
});

.github/workflows/constraints.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
pip==22.0.3
1+
pip==22.1.2
22
nox==2022.1.7
3-
nox-poetry==0.9.0
4-
poetry==1.1.11
5-
virtualenv==20.13.1
3+
nox-poetry==1.0.0
4+
poetry==1.1.13
5+
virtualenv==20.14.1

.github/workflows/coverage.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ jobs:
77
!startsWith(github.event.head_commit.message, 'bump:') &&
88
!contains(github.event.head_commit.message, '[skip_ci]')
99
steps:
10-
- uses: actions/checkout@v2
11-
- uses: actions/setup-python@v1
10+
- uses: actions/checkout@v3
11+
- uses: actions/setup-python@v4
1212
with:
1313
python-version: '3.9'
1414
architecture: x64

.github/workflows/labeler.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Check out the repository
15-
uses: actions/checkout@v2.4.0
15+
uses: actions/checkout@v3
1616

1717
- name: Run Labeler
18-
uses: crazy-max/ghaction-github-labeler@v3.1.1
18+
uses: crazy-max/ghaction-github-labeler@v4.0.0
1919
with:
2020
skip-delete: true

.github/workflows/release-drafter.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ jobs:
77
draft_release:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: release-drafter/release-drafter@v5.6.1
10+
- uses: release-drafter/release-drafter@v5.20.0
1111
env:
1212
GITHUB_TOKEN: ${{ secrets.MCKIT_GITHUB_TOKEN }}

.github/workflows/release.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Check out the repository
15-
uses: actions/checkout@v2.4.0
15+
uses: actions/checkout@v3
1616
with:
1717
fetch-depth: 2
1818

1919
- name: Set up Python
20-
uses: actions/setup-python@v2.2.2
20+
uses: actions/setup-python@v4
2121
with:
2222
python-version: "3.10"
2323

@@ -56,21 +56,21 @@ jobs:
5656
5757
- name: Publish package on PyPI
5858
if: steps.check-version.outputs.tag
59-
uses: pypa/gh-action-pypi-publish@v1.4.2
59+
uses: pypa/gh-action-pypi-publish@v1.5.0
6060
with:
6161
user: __token__
6262
password: ${{ secrets.PYPI_TOKEN }}
6363

6464
- name: Publish package on TestPyPI
6565
if: "! steps.check-version.outputs.tag"
66-
uses: pypa/gh-action-pypi-publish@v1.4.2
66+
uses: pypa/gh-action-pypi-publish@v1.5.0
6767
with:
6868
user: __token__
6969
password: ${{ secrets.TEST_PYPI_TOKEN }}
7070
repository_url: https://test.pypi.org/legacy/
7171

7272
- name: Publish the release notes
73-
uses: release-drafter/release-drafter@v5.15.0
73+
uses: release-drafter/release-drafter@v5.20.0
7474
with:
7575
publish: ${{ steps.check-version.outputs.tag != '' }}
7676
tag: ${{ steps.check-version.outputs.tag }}

.github/workflows/stale.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/stale@v3
13+
- uses: actions/stale@v5
1414
with:
1515
repo-token: ${{ secrets.MCKIT_GITHUB_TOKEN }}
1616
stale-issue-message: 'Stale issue message'

.github/workflows/test-pypi.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ jobs:
1717
!contains(github.event.head_commit.message, '[skip_ci]')
1818
steps:
1919
- name: Checkout repository
20-
uses: actions/checkout@v2
21-
- uses: actions/setup-python@v1
20+
uses: actions/checkout@v3
21+
- uses: actions/setup-python@v4
2222
with:
2323
python-version: '3.10'
2424
architecture: x64
@@ -48,8 +48,8 @@ jobs:
4848
os: [ubuntu-latest] # , macos-latest, windows-latest]
4949
python-version: ['3.9']
5050
steps:
51-
- uses: actions/checkout@v2
52-
- uses: actions/setup-python@v1
51+
- uses: actions/checkout@v3
52+
- uses: actions/setup-python@v4
5353
with:
5454
python-version: ${{matrix.python-version}}
5555
architecture: x64

.github/workflows/tests.yml

+18-11
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,29 @@ on:
1919
- "**.py"
2020
- "**.yml"
2121
- "**.toml"
22+
23+
concurrency:
24+
group: ci-tests-${{ github.ref }}-1
25+
cancel-in-progress: true
26+
2227
jobs:
2328
tests:
2429
name: "Python ${{ matrix.python-version }} on ${{ matrix.os }}"
2530
runs-on: ${{ matrix.os }}
2631
if: |
27-
!startsWith(github.event.head_commit.message, 'bump:') &&
2832
!contains(github.event.head_commit.message, '[skip_ci]')
2933
strategy:
3034
fail-fast: false
3135
matrix:
32-
os: [ubuntu-latest, macos-latest, windows-latest]
33-
python-version: ['3.8', '3.9', '3.10']
36+
# TODO dvp: return full testing for relaxed maintenance
37+
# os: [ubuntu-latest, macos-latest, windows-latest]
38+
# python-version: ['3.8', '3.9', '3.10']
39+
os: [ubuntu-latest]
40+
python-version: ['3.10']
3441
steps:
3542
- name: Checkout repository
36-
uses: actions/checkout@v2
37-
- uses: actions/setup-python@v1
43+
uses: actions/checkout@v3
44+
- uses: actions/setup-python@v4
3845
with:
3946
python-version: ${{ matrix.python-version }}
4047
architecture: x64
@@ -48,13 +55,13 @@ jobs:
4855
run: nox --force-color --python ${{ matrix.python-version }}
4956
- name: Upload coverage data
5057
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
51-
uses: "actions/upload-artifact@v2.2.4"
58+
uses: "actions/upload-artifact@v3.1.0"
5259
with:
5360
name: coverage-data
5461
path: ".coverage.*"
5562
- name: Upload documentation
5663
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
57-
uses: actions/upload-artifact@v2.2.4
64+
uses: actions/upload-artifact@v3.1.0
5865
with:
5966
name: docs
6067
path: docs/_build
@@ -64,10 +71,10 @@ jobs:
6471
needs: tests
6572
steps:
6673
- name: Check out the repository
67-
uses: actions/checkout@v2.4.0
74+
uses: actions/checkout@v3
6875

6976
- name: Set up Python 3.10
70-
uses: actions/setup-python@v1
77+
uses: actions/setup-python@v4
7178
with:
7279
python-version: '3.10'
7380

@@ -88,7 +95,7 @@ jobs:
8895
nox --version
8996
9097
- name: Download coverage data
91-
uses: actions/download-artifact@v2.0.10
98+
uses: actions/download-artifact@v3.0.0
9299
with:
93100
name: coverage-data
94101

@@ -101,4 +108,4 @@ jobs:
101108
nox --force-color --session=coverage -- xml
102109
103110
- name: Upload coverage report
104-
uses: codecov/codecov-action@v2.1.0
111+
uses: codecov/codecov-action@v3.1.0

noxfile.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
)
3939

4040
package = "mapstp"
41-
locations = f"src/{package}", "tests", "noxfile.py", "docs/source/conf.py"
41+
locations = f"src/{package}", "src/tests", "noxfile.py", "docs/source/conf.py"
4242

4343
supported_pythons = ["3.8", "3.9", "3.10"]
4444
black_pythons = "3.10"
@@ -222,7 +222,7 @@ def lint(s: Session) -> None:
222222
@session(python=mypy_pythons)
223223
def mypy(s: Session) -> None:
224224
"""Type-check using mypy."""
225-
args = s.posargs or ["src", "tests", "docs/source/conf.py"]
225+
args = s.posargs or ["src", "docs/source/conf.py"]
226226
s.install(".")
227227
s.install("mypy", "pytest", "types-setuptools")
228228
s.run("mypy", *args)

0 commit comments

Comments
 (0)