Skip to content

Commit

Permalink
Merge pull request #1 from william-cass-wright/first
Browse files Browse the repository at this point in the history
cookiecutter click app
  • Loading branch information
will-wright-eng committed Jun 15, 2022
2 parents f24f1df + 16891dd commit 2070cb9
Show file tree
Hide file tree
Showing 10 changed files with 239 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Test

on:
pull_request:
types: [ labeled ]

permissions:
contents: read

jobs:
label-lint:
if: ${{ github.event.label.name == 'lint' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Python Linter
uses: sunnysid3up/python-linter@master
with:
source: "secrets_mgmt_cli"
mypy-options: "--ignore-missing-imports --show-error-codes"
isort-options: "-w 100"
black-options: "-l 120"
60 changes: 60 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Publish Python Package

on:
release:
types: [created]

permissions:
contents: read

jobs:
publish-test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3
name: Configure pip caching
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip install -e '.[test]'
- name: Run tests
run: |
pytest
deploy:
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.10"
- uses: actions/cache@v3
name: Configure pip caching
with:
path: ~/.cache/pip
key: ${{ runner.os }}-publish-pip-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-publish-pip-
- name: Install dependencies
run: |
pip install setuptools wheel twine build
- name: Publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python -m build
twine upload dist/*
35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test

on:
pull_request:
types: [ labeled ]

permissions:
contents: read

jobs:
label-test:
if: ${{ github.event.label.name == 'test' }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3
name: Configure pip caching
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip install -e '.[test]'
- name: Run tests
run: |
pytest
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
.venv
__pycache__/
*.py[cod]
*$py.class
venv
.eggs
.pytest_cache
*.egg-info
.DS_Store


# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,41 @@
# secrets-mgmt-cli
A simple CLI for managing secrets in AWS Secrets Manager

[![PyPI](https://img.shields.io/pypi/v/secrets-mgmt-cli.svg)](https://pypi.org/project/secrets-mgmt-cli/)
[![Changelog](https://img.shields.io/github/v/release/william-cass-wright/secrets-mgmt-cli?include_prereleases&label=changelog)](https://github.com/william-cass-wright/secrets-mgmt-cli/releases)
[![Tests](https://github.com/william-cass-wright/secrets-mgmt-cli/workflows/Test/badge.svg)](https://github.com/william-cass-wright/secrets-mgmt-cli/actions?query=workflow%3ATest)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/william-cass-wright/secrets-mgmt-cli/blob/master/LICENSE)

A simple CLI for managing secrets in AWS Secrets Manager

## Installation

Install this tool using `pip`:

pip install secrets-mgmt-cli

## Usage

For help, run:

secrets-mgmt-cli --help

You can also use:

python -m secrets_mgmt_cli --help

## Development

To contribute to this tool, first checkout the code. Then create a new virtual environment:

cd secrets-mgmt-cli
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest
Empty file added secrets_mgmt_cli/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions secrets_mgmt_cli/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .cli import cli

if __name__ == "__main__":
cli()
19 changes: 19 additions & 0 deletions secrets_mgmt_cli/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import click


@click.group()
@click.version_option()
def cli():
"A simple CLI for managing secrets in AWS Secrets Manager"


@cli.command(name="command")
@click.argument("example")
@click.option(
"-o",
"--option",
help="An example option",
)
def first_command(example, option):
"Command description goes here"
click.echo("Here is some output")
39 changes: 39 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from setuptools import setup
import os

VERSION = "0.1"


def get_long_description():
with open(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "README.md"),
encoding="utf8",
) as fp:
return fp.read()


setup(
name="secrets-mgmt-cli",
description="A simple CLI for managing secrets in AWS Secrets Manager",
long_description=get_long_description(),
long_description_content_type="text/markdown",
author="Will Wright",
url="https://github.com/william-cass-wright/secrets-mgmt-cli",
project_urls={
"Issues": "https://github.com/william-cass-wright/secrets-mgmt-cli/issues",
"CI": "https://github.com/william-cass-wright/secrets-mgmt-cli/actions",
"Changelog": "https://github.com/william-cass-wright/secrets-mgmt-cli/releases",
},
license="Apache License, Version 2.0",
version=VERSION,
packages=["secrets_mgmt_cli"],
entry_points="""
[console_scripts]
secrets-mgmt-cli=secrets_mgmt_cli.cli:cli
""",
install_requires=["click"],
extras_require={
"test": ["pytest"]
},
python_requires=">=3.7",
)
10 changes: 10 additions & 0 deletions tests/test_secrets_mgmt_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from click.testing import CliRunner
from secrets_mgmt_cli.cli import cli


def test_version():
runner = CliRunner()
with runner.isolated_filesystem():
result = runner.invoke(cli, ["--version"])
assert result.exit_code == 0
assert result.output.startswith("cli, version ")

0 comments on commit 2070cb9

Please sign in to comment.