Thanks to visit codestin.com
Credit goes to github.com

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
116 changes: 0 additions & 116 deletions .circleci/config.yml

This file was deleted.

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

on: [push]

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox codecov pre-commit

# Run tox using the version of Python in `PATH`
- name: Run Tox
run: tox -e py

# Run pre-commit (only for python-3.7)
- name: run pre-commit
if: matrix.python-version == 3.7
run: pre-commit run --all-files

- name: Upload Results
if: success()
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
flags: unittests
name: ${{ matrix.platform }}-${{ matrix.tox-env }}
fail_ci_if_error: false

publish:
needs: [tests]
runs-on: ubuntu-latest
if: contains(github.ref, 'tags')
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.x"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox

- name: Set tag version
id: tag
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}

- name: Set module version
id: module
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
run: echo ::set-output name=version::$(python setup.py --version)

- name: Build and publish
if: steps.tag.outputs.tag == steps.module.outputs.version
env:
TOXENV: release
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: tox
8 changes: 5 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include python_seed/template/*
include python_seed/template/pyseed/*
include python_seed/template/tests/*
include python_seed/template/ci/*
include python_seed/template/cov/*
include python_seed/template/module/pyseed/*
include python_seed/template/module/tests/*
include python_seed/template/module/*
35 changes: 28 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<em>Starter kit for creating a new python package.</em>
</p>
<p align="center">
<a href="https://circleci.com/gh/developmentseed/python-seed" target="_blank">
<img src="https://circleci.com/gh/developmentseed/python-seed.svg?style=svg" alt="Test">
<a href="https://github.com/developmentseed/python-seed/actions?query=workflow%3ACI" target="_blank">
<img src="https://github.com/developmentseed/python-seed/workflows/CI/badge.svg" alt="Test">
</a>
<a href="https://codecov.io/gh/developmentseed/python-seed" target="_blank">
<img src="https://codecov.io/gh/developmentseed/python-seed/branch/master/graph/badge.svg" alt="Coverage">
Expand Down Expand Up @@ -64,18 +64,38 @@ Usage: pyseed create [OPTIONS] NAME
Create new python seed skeleton.

Options:
--help Show this message and exit.
--ci [circleci|github] Add CI configuration
--help Show this message and exit.
```

Create a new python project

```bash
# Create a project
# Create a project without CI
$ pyseed create awesomepythonproject

# List files created
$ ls -1 awesomepythonproject
.circleci/
.pre-commit-config.yaml
README.md
awesomepythonproject/
requirements-dev.txt
requirements.txt
setup.py
tests/
tox.ini
```

With CI framework

```bash
# Create a project github actions
$ pyseed create awesomepythonproject --ci github

# List files created
$ ls -1 awesomepythonproject
.github/workflows/ci.yml
codecov.yml
.pre-commit-config.yaml
README.md
awesomepythonproject/
Expand All @@ -90,14 +110,15 @@ tox.ini

```
my-project/
├── .circleci/ - CircleCI configuration.
├── .circleci/ or .github/ - CI configuration.
├── codecov.yml - codecov configuration (only if CI is added).
├── .pre-commit-config.yaml - pre-commit configuration.
├── README.md - project readme.
├── my_project/ - core python module.
├── tests/ - tests suite placeholder for your module.
├── requirements.txt - python requirements (!!! by default requirements are written in setup.py)
├── requirements-dev.txt - python dev requirements (!!! by default requirements are written in setup.py)
──tox.ini - TOX configuration.
──tox.ini - TOX configuration.
```


Expand Down
8 changes: 8 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
comment: off

coverage:
status:
project:
default:
target: auto
threshold: 5
19 changes: 17 additions & 2 deletions python_seed/scripts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil

import click
import pkg_resources

from .. import version

Expand All @@ -17,12 +18,26 @@ def pyseed():

@pyseed.command(short_help="Create new python seed skeleton")
@click.argument("name", type=str, nargs=1)
def create(name):
@click.option(
"--ci", type=click.Choice(["circleci", "github"]), help="Add CI configuration"
)
def create(name, ci):
"""Create new python seed skeleton."""
template_dir = os.path.join(os.path.dirname(__file__), "../template")
template_dir = pkg_resources.resource_filename("python_seed", "template/module")

shutil.copytree(template_dir, name)

if ci:
template_dir = pkg_resources.resource_filename(
"python_seed", f"template/ci/.{ci}"
)
shutil.copytree(template_dir, f"{name}/.{ci}")

covconfig = pkg_resources.resource_filename(
"python_seed", "template/cov/codecov.yml"
)
shutil.copy2(covconfig, f"{name}/codecov.yml")

new_dir = name
name = name.replace("-", "_")
for root, _, files in os.walk(new_dir):
Expand Down
75 changes: 75 additions & 0 deletions python_seed/template/ci/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: CI

on: [push]

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox codecov pre-commit

# Run tox using the version of Python in `PATH`
- name: Run Tox
run: tox -e py

# Run pre-commit (only for python-3.7)
- name: run pre-commit
if: matrix.python-version == 3.7
run: pre-commit run --all-files

- name: Upload Results
if: success()
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
flags: unittests
name: ${{ matrix.platform }}-${{ matrix.tox-env }}
fail_ci_if_error: false


publish:
needs: [tests]
runs-on: ubuntu-latest
if: contains(github.ref, 'tags')
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.x"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox

- name: Set tag version
id: tag
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}

- name: Set module version
id: module
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
run: echo ::set-output name=version::$(python setup.py --version)

- name: Build and publish
if: steps.tag.outputs.tag == steps.module.outputs.version
env:
TOXENV: release
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: tox
Loading