Skip to content

Commit 8118a76

Browse files
authored
Pep621 and other CI (#54)
* PEP621 Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de> * Add pre-commit Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de> * Rework Github CI Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de> * src-layout Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de> * Change pre-commit tools Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de> * Use recommended settings Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de> * Run pre-commit Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de> --------- Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
1 parent 515950e commit 8118a76

22 files changed

+895
-663
lines changed

.flake8

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/workflows/ci.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
upload-wheel:
7+
type: boolean
8+
required: false
9+
default: false
10+
description: Upload wheel as an artifact
11+
pull_request:
12+
push:
13+
branches: [ master ]
14+
15+
permissions:
16+
contents: read
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
jobs:
23+
tests:
24+
uses: ./.github/workflows/step_test.yaml
25+
26+
build-wheel:
27+
uses: ./.github/workflows/step_build-wheel.yaml
28+
needs: [ tests ]
29+
with:
30+
upload: ${{ inputs.upload-wheel || false }}

.github/workflows/main.yaml

Lines changed: 0 additions & 61 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Prepare release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+"
7+
- "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"
8+
workflow_dispatch:
9+
inputs:
10+
ref:
11+
description: Tag to release
12+
required: true
13+
type: string
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
tests:
20+
uses: ./.github/workflows/step_test.yaml
21+
build-wheel:
22+
needs: [ tests ]
23+
uses: ./.github/workflows/step_build-wheel.yaml
24+
with:
25+
ref: ${{ inputs.ref }}
26+
upload_pypi:
27+
name: Upload to PyPI repository
28+
needs: [ tests, build-wheel ]
29+
runs-on: ubuntu-latest
30+
environment:
31+
name: pypi
32+
url: https://pypi.org/project/click-option-group/
33+
permissions:
34+
id-token: write
35+
steps:
36+
- uses: actions/download-artifact@v3
37+
with:
38+
name: artifact
39+
path: dist
40+
- name: Publish package to PyPI
41+
uses: pypa/gh-action-pypi-publish@release/v1
42+
release:
43+
needs: [ upload_pypi ]
44+
name: Create release
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v3
48+
- uses: softprops/action-gh-release@v1
49+
with:
50+
name: click-option-group ${{ github.ref_name }}
51+
prerelease: ${{ contains(github.ref, 'rc') }}
52+
generate_release_notes: true
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
upload:
5+
description: Upload wheel as artifact
6+
required: false
7+
type: boolean
8+
default: true
9+
ref:
10+
description: Tag to release
11+
required: false
12+
type: string
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
with:
23+
ref: ${{ inputs.ref }}
24+
- name: Build package
25+
run: pipx run build
26+
- uses: actions/upload-artifact@v3
27+
with:
28+
path: dist/*
29+
if: ${{ inputs.upload }}

.github/workflows/step_test.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
on:
2+
workflow_call:
3+
4+
permissions:
5+
contents: read
6+
7+
jobs:
8+
pre-commit:
9+
name: Run pre-commit
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: actions/setup-python@v4
14+
- uses: pre-commit/action@v3.0.0
15+
16+
checks:
17+
name: Check with Python ${{ matrix.python-version }} ${{ matrix.experimental && '(Experimental)' }}
18+
needs: [ pre-commit ]
19+
continue-on-error: ${{ matrix.experimental || false }}
20+
runs-on: ubuntu-latest
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12" ]
25+
include:
26+
- python-version: "3.12"
27+
experimental: true
28+
steps:
29+
- uses: actions/checkout@v3
30+
- uses: actions/setup-python@v4
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
allow-prereleases: true
34+
35+
- name: Install package
36+
run: pip install -e .[test-cov]
37+
- name: Test package
38+
run: pytest --cov --cov-report=xml
39+
- name: Upload coverage report
40+
uses: coverallsapp/github-action@v2
41+
with:
42+
parallel: true
43+
flag-name: python-${{ matrix.python-version }}
44+
45+
finish:
46+
needs: [ checks ]
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Finish Coveralls
50+
uses: coverallsapp/github-action@v2
51+
with:
52+
parallel-finished: true

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,6 @@ dmypy.json
7575

7676
# PyCharm
7777
.idea/
78+
79+
### Project specific
80+
src/click_option_group/_version.py

.pre-commit-config.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: check-added-large-files
6+
- id: check-case-conflict
7+
- id: check-merge-conflict
8+
- id: check-symlinks
9+
- id: check-yaml
10+
- id: debug-statements
11+
- id: end-of-file-fixer
12+
- id: mixed-line-ending
13+
- id: trailing-whitespace
14+
15+
- repo: https://github.com/google/yapf
16+
rev: v0.40.1
17+
hooks:
18+
- id: yapf
19+
20+
- repo: https://github.com/astral-sh/ruff-pre-commit
21+
rev: v0.0.284
22+
hooks:
23+
- id: ruff
24+
args: ["--fix", "--show-fixes"]

MANIFEST.in

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
88

99

10-
**click-option-group** is a Click-extension package that adds option groups
10+
**click-option-group** is a Click-extension package that adds option groups
1111
missing in [Click](https://github.com/pallets/click/).
1212

1313
## Aim and Motivation
1414

15-
Click is a package for creating powerful and beautiful command line interfaces (CLI) in Python,
15+
Click is a package for creating powerful and beautiful command line interfaces (CLI) in Python,
1616
but it has no the functionality for creating option groups.
1717

18-
Option groups are convenient mechanism for logical structuring CLI, also it allows you to set
19-
the specific behavior and set the relationship among grouped options (mutually exclusive options for example).
20-
Moreover, [argparse](https://docs.python.org/3/library/argparse.html) stdlib package contains this
18+
Option groups are convenient mechanism for logical structuring CLI, also it allows you to set
19+
the specific behavior and set the relationship among grouped options (mutually exclusive options for example).
20+
Moreover, [argparse](https://docs.python.org/3/library/argparse.html) stdlib package contains this
2121
functionality out of the box.
2222

2323
At the same time, many Click users need this functionality.
@@ -28,12 +28,12 @@ You can read interesting discussions about it in the following issues:
2828
* [issue 509](https://github.com/pallets/click/issues/509)
2929
* [issue 1137](https://github.com/pallets/click/issues/1137)
3030

31-
The aim of this package is to provide group options with extensible functionality
31+
The aim of this package is to provide group options with extensible functionality
3232
using canonical and clean API (Click-like API as far as possible).
3333

3434
## Quickstart
3535

36-
### Installing
36+
### Installing
3737

3838
Install and update using pip:
3939

@@ -44,7 +44,7 @@ pip install -U click-option-group
4444
### A Simple Example
4545

4646
Here is a simple example how to use option groups in your Click-based CLI.
47-
Just use `optgroup` for declaring option groups by decorating
47+
Just use `optgroup` for declaring option groups by decorating
4848
your command function in Click-like API style.
4949

5050
```python
@@ -54,13 +54,13 @@ import click
5454
from click_option_group import optgroup, RequiredMutuallyExclusiveOptionGroup
5555

5656
@click.command()
57-
@optgroup.group('Server configuration',
57+
@optgroup.group('Server configuration',
5858
help='The configuration of some server connection')
5959
@optgroup.option('-h', '--host', default='localhost', help='Server host name')
6060
@optgroup.option('-p', '--port', type=int, default=8888, help='Server port')
6161
@optgroup.option('-n', '--attempts', type=int, default=3, help='The number of connection attempts')
6262
@optgroup.option('-t', '--timeout', type=int, default=30, help='The server response timeout')
63-
@optgroup.group('Input data sources', cls=RequiredMutuallyExclusiveOptionGroup,
63+
@optgroup.group('Input data sources', cls=RequiredMutuallyExclusiveOptionGroup,
6464
help='The sources of the input data')
6565
@optgroup.option('--tsv-file', type=click.File(), help='CSV/TSV input data file')
6666
@optgroup.option('--json-file', type=click.File(), help='JSON input data file')

0 commit comments

Comments
 (0)