Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

next release v2.0.2 #90

Merged
merged 8 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 8 additions & 39 deletions .github/workflows/comment-bot.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,17 @@
# runs on any comment matching the format `/tag <tagname> <commit>`
name: Comment Bot
on:
issue_comment: {types: [created]}
pull_request_review_comment: {types: [created]}
jobs:
tag: # /tag <tagname> <commit>
if: startsWith(github.event.comment.body, '/tag ')
tag:
runs-on: ubuntu-latest
permissions: {contents: write, pull-requests: write, issues: write}
steps:
- uses: actions/checkout@v3
- name: React Seen
uses: actions/github-script@v6
- uses: actions/checkout@v4
with:
script: |
const perm = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner, repo: context.repo.repo,
username: context.payload.comment.user.login})
post = (context.eventName == "issue_comment"
? github.rest.reactions.createForIssueComment
: github.rest.reactions.createForPullRequestReviewComment)
if (!["admin", "write"].includes(perm.data.permission)){
post({
owner: context.repo.owner, repo: context.repo.repo,
comment_id: context.payload.comment.id, content: "laugh"})
throw "Permission denied for user " + context.payload.comment.user.login
}
post({
owner: context.repo.owner, repo: context.repo.repo,
comment_id: context.payload.comment.id, content: "eyes"})
- name: Tag Commit
run: |
git clone https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} repo
git -C repo tag $(echo "$BODY" | awk '{print $2" "$3}')
git -C repo push --tags
rm -rf repo
env:
BODY: ${{ github.event.comment.body }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: React Success
uses: actions/github-script@v6
fetch-depth: 0
token: ${{ secrets.GH_TOKEN || github.token }}
- uses: casperdcl/comment-bot@v1
with:
script: |
post = (context.eventName == "issue_comment"
? github.rest.reactions.createForIssueComment
: github.rest.reactions.createForPullRequestReviewComment)
post({
owner: context.repo.owner, repo: context.repo.repo,
comment_id: context.payload.comment.id, content: "rocket"})
token: ${{ secrets.GH_TOKEN || github.token }}
66 changes: 14 additions & 52 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,22 @@ on:
pull_request:
schedule: [{cron: '3 2 1 * *'}] # M H d m w (monthly at 2:03)
jobs:
check:
if: github.event_name != 'pull_request' || !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Prepare cache
run: echo "PYSHA=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PYSHA }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Dependencies
run: pip install -U pre-commit
- uses: reviewdog/action-setup@v1
- if: github.event_name == 'push' || github.event_name == 'pull_request'
name: Comment
run: |
if [[ $EVENT == pull_request ]]; then
REPORTER=github-pr-review
else
REPORTER=github-check
fi
pre-commit run -a todo | reviewdog -efm="%f:%l: %m" -name=TODO -tee -reporter=$REPORTER -filter-mode nofilter
pre-commit run -a flake8 | reviewdog -f=pep8 -name=flake8 -tee -reporter=$REPORTER -filter-mode nofilter
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EVENT: ${{ github.event_name }}
- name: Lint
run: pre-commit run -a --show-diff-on-failure
test:
if: github.event_name != 'pull_request' || !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)
name: py${{ matrix.python }}-${{ matrix.os }}
strategy:
matrix:
os: [ubuntu]
python: [3.7, 3.8, 3.9, '3.10', 3.11]
python: [3.7, 3.8, 3.9, '3.10', 3.11, 3.12]
include:
- os: macos
python: 3.11
- os: windows
python: 3.11
- {os: macos, python: 3.12}
- {os: windows, python: 3.12}
runs-on: ${{ matrix.os }}-latest
defaults:
run:
shell: bash
defaults: {run: {shell: bash}}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
with: {fetch-depth: 0}
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install
Expand All @@ -79,7 +41,7 @@ jobs:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Coveralls Finished
Expand All @@ -90,13 +52,14 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy:
name: Deploy
needs: [check, test]
needs: test
runs-on: ubuntu-latest
environment: pypi
permissions: {contents: write, id-token: write, packages: write}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
with: {fetch-depth: 0}
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install
Expand All @@ -107,7 +70,6 @@ jobs:
- id: dist
uses: casperdcl/deploy-pypi@v2
with:
password: ${{ secrets.TWINE_PASSWORD }}
gpg_key: ${{ secrets.GPG_KEY }}
upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
- id: collect_assets
Expand Down
2 changes: 1 addition & 1 deletion .meta/requirements-build.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
py-make>=0.1.0
twine
wheel
build
10 changes: 6 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand Down Expand Up @@ -35,10 +35,11 @@ repos:
additional_dependencies:
- pytest-timeout
- argopt
- pyyaml
- tabulate
- tqdm
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
rev: 7.1.1
hooks:
- id: flake8
args: [-j8]
Expand All @@ -48,14 +49,15 @@ repos:
- flake8-comprehensions
- flake8-debugger
- flake8-isort
- flake8-pyproject
- flake8-string-format
- repo: https://github.com/google/yapf
rev: v0.32.0
rev: v0.40.2
hooks:
- id: yapf
args: [-i]
additional_dependencies: [toml]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11-alpine
FROM python:3.12-alpine
RUN apk update && apk add --no-cache git
COPY dist/*.whl .
RUN pip install -U $(ls *.whl)[full] && rm *.whl
Expand Down
2 changes: 1 addition & 1 deletion LICENCE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
* files: *
MPLv2.0 2016-2023 (c) Casper da Costa-Luis
MPLv2.0 2016-2024 (c) Casper da Costa-Luis
[casperdcl](https://github.com/casperdcl).


Expand Down
22 changes: 9 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# IMPORTANT: for compatibility with `python setup.py make [alias]`, ensure:
# IMPORTANT: for compatibility with `python -m pymake [alias]`, ensure:
# 1. Every alias is preceded by @[+]make (eg: @make alias)
# 2. A maximum of one @make alias or command per line
# see: https://github.com/tqdm/py-make/issues/1
Expand Down Expand Up @@ -29,7 +29,7 @@
run

help:
@python setup.py make -p
@python -m pymake -p

alltests:
@+make testcoverage
Expand All @@ -51,8 +51,7 @@ pytest:

testsetup:
@make gitfame/git-fame.1
python setup.py check --metadata --restructuredtext --strict
python setup.py make none
@make help

testcoverage:
@make coverclean
Expand Down Expand Up @@ -91,29 +90,26 @@ coverclean:
@+python -c "import shutil; shutil.rmtree('gitfame/__pycache__', True)"
clean:
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('*.py[co]')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('gitfame/*.py[co]')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('gitfame/*.c')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('gitfame/*.so')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('tests/*.py[co]')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('gitfame/*.py[co]')]"
toxclean:
@+python -c "import shutil; shutil.rmtree('.tox', True)"

install:
python setup.py install
python -m pip install .
install_dev:
python setup.py develop --uninstall
python setup.py develop
python -m pip install -e .
install_build:
python -m pip install -r .meta/requirements-build.txt

build:
@make prebuildclean
@make testsetup
python setup.py sdist bdist_wheel
# python setup.py bdist_wininst
python -m build
python -m twine check dist/*

pypi:
twine upload dist/*
python -m twine upload dist/*

buildupload:
@make build
Expand Down
14 changes: 8 additions & 6 deletions gitfame/_gitfame.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,13 +480,15 @@ def main(args=None):
log.debug(args)
if args.manpath is not None:
import sys
from os import path
from shutil import copyfile
from pathlib import Path

from pkg_resources import resource_filename
fi = resource_filename(__name__, 'git-fame.1')
fo = path.join(args.manpath, 'git-fame.1')
copyfile(fi, fo)
try: # py<3.9
import importlib_resources as resources
except ImportError:
from importlib import resources
fi = resources.files('gitfame') / 'git-fame.1'
fo = Path(args.manpath) / 'git-fame.1'
fo.write_bytes(fi.read_bytes())
log.info("written:%s", fo)
sys.exit(0)

Expand Down
2 changes: 1 addition & 1 deletion gitfame/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def Max(it, empty_default=0):
try:
return max(it)
except ValueError as e:
if 'empty sequence' in str(e):
if 'empty' in str(e):
return empty_default
raise # pragma: no cover

Expand Down
Loading
Loading