Skip to content

Commit

Permalink
Pep621 and other CI (#54)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
LecrisUT committed Aug 29, 2023
1 parent 515950e commit 8118a76
Show file tree
Hide file tree
Showing 22 changed files with 895 additions and 663 deletions.
2 changes: 0 additions & 2 deletions .flake8

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

on:
workflow_dispatch:
inputs:
upload-wheel:
type: boolean
required: false
default: false
description: Upload wheel as an artifact
pull_request:
push:
branches: [ master ]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
uses: ./.github/workflows/step_test.yaml

build-wheel:
uses: ./.github/workflows/step_build-wheel.yaml
needs: [ tests ]
with:
upload: ${{ inputs.upload-wheel || false }}
61 changes: 0 additions & 61 deletions .github/workflows/main.yaml

This file was deleted.

52 changes: 52 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Prepare release

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"
workflow_dispatch:
inputs:
ref:
description: Tag to release
required: true
type: string

permissions:
contents: read

jobs:
tests:
uses: ./.github/workflows/step_test.yaml
build-wheel:
needs: [ tests ]
uses: ./.github/workflows/step_build-wheel.yaml
with:
ref: ${{ inputs.ref }}
upload_pypi:
name: Upload to PyPI repository
needs: [ tests, build-wheel ]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/click-option-group/
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
release:
needs: [ upload_pypi ]
name: Create release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: softprops/action-gh-release@v1
with:
name: click-option-group ${{ github.ref_name }}
prerelease: ${{ contains(github.ref, 'rc') }}
generate_release_notes: true
29 changes: 29 additions & 0 deletions .github/workflows/step_build-wheel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
workflow_call:
inputs:
upload:
description: Upload wheel as artifact
required: false
type: boolean
default: true
ref:
description: Tag to release
required: false
type: string

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
- name: Build package
run: pipx run build
- uses: actions/upload-artifact@v3
with:
path: dist/*
if: ${{ inputs.upload }}
52 changes: 52 additions & 0 deletions .github/workflows/step_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
on:
workflow_call:

permissions:
contents: read

jobs:
pre-commit:
name: Run pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: pre-commit/action@v3.0.0

checks:
name: Check with Python ${{ matrix.python-version }} ${{ matrix.experimental && '(Experimental)' }}
needs: [ pre-commit ]
continue-on-error: ${{ matrix.experimental || false }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12" ]
include:
- python-version: "3.12"
experimental: true
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Install package
run: pip install -e .[test-cov]
- name: Test package
run: pytest --cov --cov-report=xml
- name: Upload coverage report
uses: coverallsapp/github-action@v2
with:
parallel: true
flag-name: python-${{ matrix.python-version }}

finish:
needs: [ checks ]
runs-on: ubuntu-latest
steps:
- name: Finish Coveralls
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,6 @@ dmypy.json

# PyCharm
.idea/

### Project specific
src/click_option_group/_version.py
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace

- repo: https://github.com/google/yapf
rev: v0.40.1
hooks:
- id: yapf

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.284
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
4 changes: 0 additions & 4 deletions MANIFEST.in

This file was deleted.

20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)


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

## Aim and Motivation

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

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

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

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

## Quickstart

### Installing
### Installing

Install and update using pip:

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

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

```python
Expand All @@ -54,13 +54,13 @@ import click
from click_option_group import optgroup, RequiredMutuallyExclusiveOptionGroup

@click.command()
@optgroup.group('Server configuration',
@optgroup.group('Server configuration',
help='The configuration of some server connection')
@optgroup.option('-h', '--host', default='localhost', help='Server host name')
@optgroup.option('-p', '--port', type=int, default=8888, help='Server port')
@optgroup.option('-n', '--attempts', type=int, default=3, help='The number of connection attempts')
@optgroup.option('-t', '--timeout', type=int, default=30, help='The server response timeout')
@optgroup.group('Input data sources', cls=RequiredMutuallyExclusiveOptionGroup,
@optgroup.group('Input data sources', cls=RequiredMutuallyExclusiveOptionGroup,
help='The sources of the input data')
@optgroup.option('--tsv-file', type=click.File(), help='CSV/TSV input data file')
@optgroup.option('--json-file', type=click.File(), help='JSON input data file')
Expand Down
3 changes: 0 additions & 3 deletions click_option_group/_version.py

This file was deleted.

Loading

0 comments on commit 8118a76

Please sign in to comment.