Skip to content
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 }}
69 changes: 15 additions & 54 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
runs-on: ${{ matrix.os }}-latest
defaults:
run:
shell: bash
- {os: macos, python: 3.12}
- {os: windows, python: 3.12}
runs-on: ${{ matrix.os }}-${{ matrix.python == 3.7 && '22.04' || 'latest' }}
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 @@ -74,13 +36,12 @@ jobs:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
finish:
if: github.event_name != 'pull_request' || !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)
name: Coverage
continue-on-error: ${{ github.event_name != 'push' }}
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,20 +51,20 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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'
- id: dist
uses: casperdcl/deploy-pypi@v2
with:
build: true
password: ${{ secrets.PYPI_TOKEN }}
gpg_key: ${{ secrets.GPG_KEY }}
upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
Expand Down
9 changes: 5 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,7 +35,7 @@ repos:
additional_dependencies:
- pytest-timeout
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
rev: 7.1.2
hooks:
- id: flake8
args: [-j8]
Expand All @@ -45,14 +45,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.43.0
hooks:
- id: yapf
args: [-i, --exclude=argopt/_docopt.py]
additional_dependencies: [toml]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 6.0.1
hooks:
- id: isort
2 changes: 1 addition & 1 deletion LICENCE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
* files: *
MPLv2.0 2015-2023 (c) Casper da Costa-Luis
MPLv2.0 2015-2025 (c) Casper da Costa-Luis
[casperdcl](https://github.com/casperdcl).


Expand Down
39 changes: 19 additions & 20 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 All @@ -8,7 +8,7 @@
all
flake8
test
testnose
pytest
testsetup
testcoverage
testtimer
Expand All @@ -17,15 +17,16 @@
prebuildclean
clean
toxclean
installdev
install_build
install_dev
install
build
buildupload
pypi
none

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

alltests:
@+make testcoverage
Expand All @@ -37,24 +38,23 @@ all:
@+make build

flake8:
@+flake8 -j 8 --count --statistics --exit-zero .
@+pre-commit run -a flake8

test:
tox --skip-missing-interpreters -p all

testnose:
nosetests -d -v tests/
pytest:
pytest

testsetup:
python setup.py check --metadata --restructuredtext --strict
python setup.py make none
@make help

testcoverage:
@make coverclean
nosetests --with-coverage --cover-package=argopt --cover-erase --cover-min-percentage=80 -d -v tests/
pytest --cov=argopt --cov-report=xml --cov-report=term --cov-fail-under=80

testtimer:
nosetests --with-timer -d -v tests/
pytest

distclean:
@+make coverclean
Expand All @@ -79,22 +79,21 @@ clean:
toxclean:
@+python -c "import shutil; shutil.rmtree('.tox', True)"


installdev:
python setup.py develop --uninstall
python setup.py develop

install:
python setup.py install
python -m pip install .
install_dev:
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
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -260,5 +260,5 @@ We are grateful for all |GitHub-Contributions|.
:target: https://www.openhub.net/p/arg-opt?ref=Thin+badge
.. |LICENCE| image:: https://img.shields.io/pypi/l/argopt.svg?color=purple&logo=SPDX
:target: https://raw.githubusercontent.com/casperdcl/argopt/master/LICENCE
.. |README-Hits| image:: https://caspersci.uk.to/cgi-bin/hits.cgi?q=argopt&style=social&r=https://github.com/casperdcl/argopt
:target: https://caspersci.uk.to/cgi-bin/hits.cgi?q=argopt&a=plot&r=https://github.com/casperdcl/argopt&style=social
.. |README-Hits| image:: https://cgi.cdcl.ml/hits?q=argopt&style=social&r=https://github.com/casperdcl/argopt
:target: https://cgi.cdcl.ml/hits?q=argopt&a=plot&r=https://github.com/casperdcl/argopt&style=social
2 changes: 0 additions & 2 deletions argopt/_argopt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function

import logging
import re
from argparse import ArgumentParser, RawDescriptionHelpFormatter
Expand Down
Loading