Skip to content

Commit

Permalink
Merge pull request #44 from MC-kit/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
dvp2015 authored Sep 12, 2022
2 parents 8aa06ff + 0562bf6 commit b3c8f96
Show file tree
Hide file tree
Showing 91 changed files with 3,423 additions and 1,275 deletions.
56 changes: 56 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[flake8]
# select=ANN,B,B9,BLK,C,D,DAR,E,F,TC,I,S,W
select=ANN,B,B9,BLK,C,D,DAR,E,F,TC,S,W
max-complexity=10
max-line-length=88
ignore=
# ANN001 Missing type annotation for function argument
ANN001
# ANN101 Missing type annotation for self in method
ANN101
# ANN102 Missing type annotation for cls in classmethod
ANN102
#ANN204 Missing return type annotation for special method
ANN204
# C812 Missing trailing comma: black compatibility
C812
# D105 Missing docstring in magic method (__hash__, __eq__)
D105
# Missing docstring in __init__
D107
# E203: Whitespace before ‘:'
E203
# E501: Line too long
E501
# W503: Line break before binary operator: for compatibility with black settings
W503
# import is controlled by isort
I100
I201
I202
exclude=
.git
__pycache__
docs/source/conf.py
adhoc
wrk
build
dist
tools/install-poetry.py
*.pyc
*.egg-info
.cache
.eggs
per-file-ignores =
noxfile.py:ANN,DAR101
tools/clear-prev-dist-info.py:S404,S603,S607
src/tests/*:S101,ANN,DAR100,D100,D103,DAR101,DAR103
src/xpypact/Inventory.py:F811
src/xpypact/data_arrays.py:ANN401
src/xpypact/utils/resource.py:ANN202
ignore-decorators=click,pytest
docstring-convention = google
rst-roles = class,const,func,meth,mod,ref
rst-directives = deprecated

# vim: set ts=4 sw=0 tw=79 ss=0 ft=ini et ai :
4 changes: 4 additions & 0 deletions .github/constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pip==22.2.2
nox==2022.8.7
poetry==1.2.0
virtualenv==20.16.4
36 changes: 29 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
version: 2

updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: monthly
time: "11:00"
open-pull-requests-limit: 10
target-branch: devel

- package-ecosystem: pip
directory: "/"
schedule:
interval: monthly
day: monday
time: "11:00"
open-pull-requests-limit: 10
target-branch: devel

- package-ecosystem: "github-actions"
# Workflow files stored in the default location of `.github/workflows`
directory: "/"
schedule:
interval: monthly
day: tuesday
time: "11:00"
open-pull-requests-limit: 10
target-branch: devel

- package-ecosystem: "gitsubmodule"
directory: "/"
schedule:
interval: monthly
day: wednesday
time: "11:00"
open-pull-requests-limit: 10
target-branch: devel
30 changes: 30 additions & 0 deletions .github/workflows/clean-workflow-logs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Clean Workflow Logs

on:
workflow_dispatch:
inputs:
# days_old:
# description: "The amount of days old to delete"
# default: "7"
# required: false
dry:
description: "Dry run"
default: "false"
required: false
jobs:
clean-logs:
runs-on: ubuntu-latest
steps:
# - uses: igorjs/gh-actions-clean-workflow@v1
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# owner: ${{ github.repository_owner }}
# repo: ${{ github.event.repository.name }}
# days_old: ${{ github.event.inputs.days_old }}
- name: Clean workflow runs
uses: dmvict/[email protected]
with:
token: ${{ secrets.MCKIT_GITHUB_TOKEN }}
save_period: 30
save_min_runs_number: 10
dry: ${{ github.event.inputs.dry }}
143 changes: 143 additions & 0 deletions .github/workflows/combine-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: 'Combine PRs'

#
# Source:
# https://dev.to/denvercoder1/keeping-your-dependencies-updated-automatically-with-dependabot-299g
# https://github.com/hrvey/combine-prs-workflow/blob/master/combine-prs.yml
#

# Controls when the action will run - in this case triggered manually
on:
workflow_dispatch:
inputs:
branchPrefix:
description: 'Branch prefix to find combinable PRs based on'
required: true
default: 'dependabot'
mustBeGreen:
description: 'Only combine PRs that are green (status is success)'
required: true
type: boolean
default: true
combineBranchName:
description: 'Name of the branch to combine PRs into'
required: true
default: 'combine-prs-branch'
ignoreLabel:
description: 'Exclude PRs with this label'
required: true
default: 'nocombine'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "combine-prs"
combine-prs:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/github-script@v6
id: create-combined-pr
name: Create Combined PR
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const pulls = await github.paginate('GET /repos/:owner/:repo/pulls', {
owner: context.repo.owner,
repo: context.repo.repo
});
let branchesAndPRStrings = [];
let baseBranch = null;
let baseBranchSHA = null;
for (const pull of pulls) {
const branch = pull['head']['ref'];
console.log('Pull for branch: ' + branch);
if (branch.startsWith('${{ github.event.inputs.branchPrefix }}')) {
console.log('Branch matched prefix: ' + branch);
let statusOK = true;
if(${{ github.event.inputs.mustBeGreen }}) {
console.log('Checking green status: ' + branch);
const statusResponse = await github.rest.repos.getCombinedStatusForRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: branch
});
const state = statusResponse['data']['state'];
console.log('Validating status: ' + state);
if(state != 'success') {
console.log('Discarding ' + branch + ' with status ' + state);
statusOK = false;
}
}
console.log('Checking labels: ' + branch);
const labels = pull['labels'];
for(const label of labels) {
const labelName = label['name'];
console.log('Checking label: ' + labelName);
if(labelName == '${{ github.event.inputs.ignoreLabel }}') {
console.log('Discarding ' + branch + ' with label ' + labelName);
statusOK = false;
}
}
if (statusOK) {
console.log('Adding branch to array: ' + branch);
const prString = '#' + pull['number'] + ' ' + pull['title'];
branchesAndPRStrings.push({ branch, prString });
baseBranch = pull['base']['ref'];
baseBranchSHA = pull['base']['sha'];
}
} else {
console.log('Branch did not match prefix: ' + branch);
}
}
if (branchesAndPRStrings.length == 0) {
core.setFailed('No PRs/branches matched criteria');
return;
}
try {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/heads/' + '${{ github.event.inputs.combineBranchName }}',
sha: baseBranchSHA
});
} catch (error) {
console.log(error);
core.setFailed('Failed to create combined branch - maybe a branch by that name already exists?');
return;
}
let combinedPRs = [];
let mergeFailedPRs = [];
for(const { branch, prString } of branchesAndPRStrings) {
try {
await github.rest.repos.merge({
owner: context.repo.owner,
repo: context.repo.repo,
base: '${{ github.event.inputs.combineBranchName }}',
head: branch,
});
console.log('Merged branch ' + branch);
combinedPRs.push(prString);
} catch (error) {
console.log('Failed to merge branch ' + branch);
mergeFailedPRs.push(prString);
}
}
console.log('Creating combined PR');
const combinedPRsString = combinedPRs.join('\n');
let body = '✅ This PR was created by the Combine PRs action by combining the following PRs:\n' + combinedPRsString;
if(mergeFailedPRs.length > 0) {
const mergeFailedPRsString = mergeFailedPRs.join('\n');
body += '\n\n⚠️ The following PRs were left out due to merge conflicts:\n' + mergeFailedPRsString
}
await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Combined PR',
head: '${{ github.event.inputs.combineBranchName }}',
base: baseBranch,
body: body
});
5 changes: 0 additions & 5 deletions .github/workflows/constraints.txt

This file was deleted.

22 changes: 18 additions & 4 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
name: Labeler
name: Create Repository Labels

on:
push:
branches:
- main
- master
- devel
paths:
- .github/labels.yaml
- .github/workflows/repo-labels.yaml
pull_request:
branches:
- trunk
paths:
- .github/labels.yaml
- .github/workflows/labeler.yml
schedule:
- cron: "0 0 * * TUE"

jobs:
labeler:
labels:
name: Sycnchronize repository labels
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/[email protected]

- name: Run Labeler
uses: crazy-max/ghaction-github-labeler@v3.1.1
- name: Sync GitHub Issue Labels
uses: crazy-max/ghaction-github-labeler@v4
with:
github-token: ${{ secrets.MCKIT_GITHUB_TOKEN }}
skip-delete: true
dry-run: ${{ github.ref != 'refs/heads/master' }}
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ jobs:
draft_release:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5.6.1
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.MCKIT_GITHUB_TOKEN }}
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v2.4.0
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Set up Python
uses: actions/setup-python@v2.2.2
uses: actions/setup-python@v4.2.0
with:
python-version: "3.10"

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip install --constraint=.github/constraints.txt pip
pip --version
- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
pip install --constraint=.github/constraints.txt poetry
poetry --version
- name: Check if there is a parent commit
Expand Down Expand Up @@ -56,14 +56,14 @@ jobs:
- name: Publish package on PyPI
if: steps.check-version.outputs.tag
uses: pypa/gh-action-pypi-publish@v1.4.2
uses: pypa/gh-action-pypi-publish@v1.5.1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

- name: Publish package on TestPyPI
if: "! steps.check-version.outputs.tag"
uses: pypa/gh-action-pypi-publish@v1.4.2
uses: pypa/gh-action-pypi-publish@v1.5.1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: Mark stale issues and pull requests

on:
schedule:
- cron: "30 1 * * *"
- cron: "0 10 1 * *"

jobs:
stale:

runs-on: ubuntu-latest

steps:
- uses: actions/stale@v3
- uses: actions/stale@v5
with:
repo-token: ${{ secrets.MCKIT_GITHUB_TOKEN }}
stale-issue-message: 'Stale issue message'
Expand Down
Loading

0 comments on commit b3c8f96

Please sign in to comment.