From 5423f3673e014bd245b2eed3490f06d1b7d95e59 Mon Sep 17 00:00:00 2001
From: vincentsarago
Date: Thu, 20 Aug 2020 22:53:42 -0400
Subject: [PATCH 01/14] add multiple ci
---
MANIFEST.in | 7 +-
python_seed/scripts/cli.py | 14 +++-
.../template/{ => ci}/.circleci/config.yml | 0
.../template/ci/.github/workflows/ci.yml | 81 +++++++++++++++++++
.../{ => module}/.pre-commit-config.yaml | 0
python_seed/template/{ => module}/README.md | 0
.../template/{ => module}/pyseed/__init__.py | 0
.../template/{ => module}/pyseed/app.py | 0
.../{ => module}/pyseed/scripts/__init__.py | 0
.../{ => module}/pyseed/scripts/cli.py | 0
.../{ => module}/requirements-dev.txt | 0
.../template/{ => module}/requirements.txt | 0
python_seed/template/{ => module}/setup.py | 0
.../template/{ => module}/tests/__init__.py | 0
.../{ => module}/tests/test_function.py | 0
.../template/{ => module}/tests/test_mod.py | 0
python_seed/template/{ => module}/tox.ini | 4 +-
17 files changed, 99 insertions(+), 7 deletions(-)
rename python_seed/template/{ => ci}/.circleci/config.yml (100%)
create mode 100644 python_seed/template/ci/.github/workflows/ci.yml
rename python_seed/template/{ => module}/.pre-commit-config.yaml (100%)
rename python_seed/template/{ => module}/README.md (100%)
rename python_seed/template/{ => module}/pyseed/__init__.py (100%)
rename python_seed/template/{ => module}/pyseed/app.py (100%)
rename python_seed/template/{ => module}/pyseed/scripts/__init__.py (100%)
rename python_seed/template/{ => module}/pyseed/scripts/cli.py (100%)
rename python_seed/template/{ => module}/requirements-dev.txt (100%)
rename python_seed/template/{ => module}/requirements.txt (100%)
rename python_seed/template/{ => module}/setup.py (100%)
rename python_seed/template/{ => module}/tests/__init__.py (100%)
rename python_seed/template/{ => module}/tests/test_function.py (100%)
rename python_seed/template/{ => module}/tests/test_mod.py (100%)
rename python_seed/template/{ => module}/tox.ini (87%)
diff --git a/MANIFEST.in b/MANIFEST.in
index c7aa7370..3f4e5306 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,3 +1,4 @@
-include python_seed/template/*
-include python_seed/template/pyseed/*
-include python_seed/template/tests/*
\ No newline at end of file
+include python_seed/template/ci/*
+include python_seed/template/module/pyseed/*
+include python_seed/template/module/tests/*
+include python_seed/template/module/*
\ No newline at end of file
diff --git a/python_seed/scripts/cli.py b/python_seed/scripts/cli.py
index 0e67953e..8eb5cd84 100644
--- a/python_seed/scripts/cli.py
+++ b/python_seed/scripts/cli.py
@@ -4,6 +4,7 @@
import shutil
import click
+import pkg_resources
from .. import version
@@ -17,12 +18,21 @@ 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}")
+
new_dir = name
name = name.replace("-", "_")
for root, _, files in os.walk(new_dir):
diff --git a/python_seed/template/.circleci/config.yml b/python_seed/template/ci/.circleci/config.yml
similarity index 100%
rename from python_seed/template/.circleci/config.yml
rename to python_seed/template/ci/.circleci/config.yml
diff --git a/python_seed/template/ci/.github/workflows/ci.yml b/python_seed/template/ci/.github/workflows/ci.yml
new file mode 100644
index 00000000..04fc3253
--- /dev/null
+++ b/python_seed/template/ci/.github/workflows/ci.yml
@@ -0,0 +1,81 @@
+name: CI
+
+on: [push]
+
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ python: [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
+
+ - name: Run Tox
+ # Run tox using the version of Python in `PATH`
+ 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"
+ env:
+ TOXENV=release
+
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ python -m pip install tox
+
+ - name: Set env
+ # https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
+ run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF#refs/*/}
+
+ - name: Check Version
+ # We Only deploy to PyPi if github tag match the python version
+ run:
+ name: verify git tag vs. version
+ command: |
+ VERSION=$(python setup.py --version)
+ if [ "$VERSION" = "$RELEASE_VERSION" ]; then exit 0; else exit 3; fi
+
+ - run:
+ name: init .pypirc
+ command: |
+ echo -e "[pypi]" >> ~/.pypirc
+ echo -e "username = $PYPI_USER" >> ~/.pypirc
+ echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc
+
+ - run:
+ name: run tox
+ command: ~/.local/bin/tox
\ No newline at end of file
diff --git a/python_seed/template/.pre-commit-config.yaml b/python_seed/template/module/.pre-commit-config.yaml
similarity index 100%
rename from python_seed/template/.pre-commit-config.yaml
rename to python_seed/template/module/.pre-commit-config.yaml
diff --git a/python_seed/template/README.md b/python_seed/template/module/README.md
similarity index 100%
rename from python_seed/template/README.md
rename to python_seed/template/module/README.md
diff --git a/python_seed/template/pyseed/__init__.py b/python_seed/template/module/pyseed/__init__.py
similarity index 100%
rename from python_seed/template/pyseed/__init__.py
rename to python_seed/template/module/pyseed/__init__.py
diff --git a/python_seed/template/pyseed/app.py b/python_seed/template/module/pyseed/app.py
similarity index 100%
rename from python_seed/template/pyseed/app.py
rename to python_seed/template/module/pyseed/app.py
diff --git a/python_seed/template/pyseed/scripts/__init__.py b/python_seed/template/module/pyseed/scripts/__init__.py
similarity index 100%
rename from python_seed/template/pyseed/scripts/__init__.py
rename to python_seed/template/module/pyseed/scripts/__init__.py
diff --git a/python_seed/template/pyseed/scripts/cli.py b/python_seed/template/module/pyseed/scripts/cli.py
similarity index 100%
rename from python_seed/template/pyseed/scripts/cli.py
rename to python_seed/template/module/pyseed/scripts/cli.py
diff --git a/python_seed/template/requirements-dev.txt b/python_seed/template/module/requirements-dev.txt
similarity index 100%
rename from python_seed/template/requirements-dev.txt
rename to python_seed/template/module/requirements-dev.txt
diff --git a/python_seed/template/requirements.txt b/python_seed/template/module/requirements.txt
similarity index 100%
rename from python_seed/template/requirements.txt
rename to python_seed/template/module/requirements.txt
diff --git a/python_seed/template/setup.py b/python_seed/template/module/setup.py
similarity index 100%
rename from python_seed/template/setup.py
rename to python_seed/template/module/setup.py
diff --git a/python_seed/template/tests/__init__.py b/python_seed/template/module/tests/__init__.py
similarity index 100%
rename from python_seed/template/tests/__init__.py
rename to python_seed/template/module/tests/__init__.py
diff --git a/python_seed/template/tests/test_function.py b/python_seed/template/module/tests/test_function.py
similarity index 100%
rename from python_seed/template/tests/test_function.py
rename to python_seed/template/module/tests/test_function.py
diff --git a/python_seed/template/tests/test_mod.py b/python_seed/template/module/tests/test_mod.py
similarity index 100%
rename from python_seed/template/tests/test_mod.py
rename to python_seed/template/module/tests/test_mod.py
diff --git a/python_seed/template/tox.ini b/python_seed/template/module/tox.ini
similarity index 87%
rename from python_seed/template/tox.ini
rename to python_seed/template/module/tox.ini
index 4e04fa48..73d6643c 100644
--- a/python_seed/template/tox.ini
+++ b/python_seed/template/module/tox.ini
@@ -4,7 +4,7 @@ envlist = py36,py37,py38
[testenv]
extras = test
commands=
- python -m pytest --cov python_seed --cov-report term-missing --ignore=venv
+ python -m pytest --cov pyseed --cov-report term-missing --ignore=venv
# Lint
[flake8]
@@ -19,7 +19,7 @@ ignore_missing_imports = True
include_trailing_comma = True
multi_line_output = 3
line_length = 90
-known_first_party = python_seed
+known_first_party = pyseed
default_section = THIRDPARTY
# Autoformatter
From 480635c3eda37894da6de410224d1eec835f73d6 Mon Sep 17 00:00:00 2001
From: vincentsarago
Date: Fri, 21 Aug 2020 09:38:41 -0400
Subject: [PATCH 02/14] switch to github actions
---
.github/workflows/ci.yml | 81 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
create mode 100644 .github/workflows/ci.yml
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 00000000..04fc3253
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,81 @@
+name: CI
+
+on: [push]
+
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ python: [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
+
+ - name: Run Tox
+ # Run tox using the version of Python in `PATH`
+ 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"
+ env:
+ TOXENV=release
+
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ python -m pip install tox
+
+ - name: Set env
+ # https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
+ run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF#refs/*/}
+
+ - name: Check Version
+ # We Only deploy to PyPi if github tag match the python version
+ run:
+ name: verify git tag vs. version
+ command: |
+ VERSION=$(python setup.py --version)
+ if [ "$VERSION" = "$RELEASE_VERSION" ]; then exit 0; else exit 3; fi
+
+ - run:
+ name: init .pypirc
+ command: |
+ echo -e "[pypi]" >> ~/.pypirc
+ echo -e "username = $PYPI_USER" >> ~/.pypirc
+ echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc
+
+ - run:
+ name: run tox
+ command: ~/.local/bin/tox
\ No newline at end of file
From cee035f2f51ddd719d227824ebfd51df456d11a8 Mon Sep 17 00:00:00 2001
From: vincentsarago
Date: Fri, 21 Aug 2020 09:43:41 -0400
Subject: [PATCH 03/14] fix actions
---
.github/workflows/ci.yml | 8 ++++----
python_seed/template/ci/.github/workflows/ci.yml | 5 ++---
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 04fc3253..7000dbe4 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -43,15 +43,15 @@ jobs:
needs: [tests]
runs-on: ubuntu-latest
if: contains(github.ref, 'tags')
+ env:
+ TOXENV: release
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
- python-version: "3.x"
- env:
- TOXENV=release
-
+ python-version: "3.x"
+
- name: Install dependencies
run: |
python -m pip install --upgrade pip
diff --git a/python_seed/template/ci/.github/workflows/ci.yml b/python_seed/template/ci/.github/workflows/ci.yml
index 04fc3253..f133fbba 100644
--- a/python_seed/template/ci/.github/workflows/ci.yml
+++ b/python_seed/template/ci/.github/workflows/ci.yml
@@ -43,15 +43,14 @@ jobs:
needs: [tests]
runs-on: ubuntu-latest
if: contains(github.ref, 'tags')
+ env:
+ TOXENV: release
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.x"
- env:
- TOXENV=release
-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
From a2806c942593a22eacad1abac16df2e2d6679bcf Mon Sep 17 00:00:00 2001
From: vincentsarago
Date: Fri, 21 Aug 2020 09:45:45 -0400
Subject: [PATCH 04/14] fix again
---
.github/workflows/ci.yml | 22 ++++++++-----------
.../template/ci/.github/workflows/ci.yml | 22 ++++++++-----------
2 files changed, 18 insertions(+), 26 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7000dbe4..27b2e3c6 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -61,21 +61,17 @@ jobs:
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF#refs/*/}
- - name: Check Version
+ - name: Check git tag vs. version
# We Only deploy to PyPi if github tag match the python version
- run:
- name: verify git tag vs. version
- command: |
+ run: |
VERSION=$(python setup.py --version)
if [ "$VERSION" = "$RELEASE_VERSION" ]; then exit 0; else exit 3; fi
- - run:
- name: init .pypirc
- command: |
- echo -e "[pypi]" >> ~/.pypirc
- echo -e "username = $PYPI_USER" >> ~/.pypirc
- echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc
+ - name: init .pypirc
+ run: |
+ echo -e "[pypi]" >> ~/.pypirc
+ echo -e "username = $PYPI_USER" >> ~/.pypirc
+ echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc
- - run:
- name: run tox
- command: ~/.local/bin/tox
\ No newline at end of file
+ - name: run tox
+ run: ~/.local/bin/tox
\ No newline at end of file
diff --git a/python_seed/template/ci/.github/workflows/ci.yml b/python_seed/template/ci/.github/workflows/ci.yml
index f133fbba..cea45809 100644
--- a/python_seed/template/ci/.github/workflows/ci.yml
+++ b/python_seed/template/ci/.github/workflows/ci.yml
@@ -60,21 +60,17 @@ jobs:
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF#refs/*/}
- - name: Check Version
+ - name: Check git tag vs. version
# We Only deploy to PyPi if github tag match the python version
- run:
- name: verify git tag vs. version
- command: |
+ run: |
VERSION=$(python setup.py --version)
if [ "$VERSION" = "$RELEASE_VERSION" ]; then exit 0; else exit 3; fi
- - run:
- name: init .pypirc
- command: |
- echo -e "[pypi]" >> ~/.pypirc
- echo -e "username = $PYPI_USER" >> ~/.pypirc
- echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc
+ - name: init .pypirc
+ run: |
+ echo -e "[pypi]" >> ~/.pypirc
+ echo -e "username = $PYPI_USER" >> ~/.pypirc
+ echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc
- - run:
- name: run tox
- command: ~/.local/bin/tox
\ No newline at end of file
+ - name: run tox
+ run: ~/.local/bin/tox
\ No newline at end of file
From c8e27445a062828ea23f28e87eb9b2428ae7d78d Mon Sep 17 00:00:00 2001
From: vincentsarago
Date: Fri, 21 Aug 2020 09:57:20 -0400
Subject: [PATCH 05/14] fix 3
---
.github/workflows/ci.yml | 4 ++--
python_seed/template/ci/.github/workflows/ci.yml | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 27b2e3c6..2e7e0555 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- python: [3.6, 3.7, 3.8]
+ python-version: [3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v2
@@ -74,4 +74,4 @@ jobs:
echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc
- name: run tox
- run: ~/.local/bin/tox
\ No newline at end of file
+ run: tox
\ No newline at end of file
diff --git a/python_seed/template/ci/.github/workflows/ci.yml b/python_seed/template/ci/.github/workflows/ci.yml
index cea45809..481674bf 100644
--- a/python_seed/template/ci/.github/workflows/ci.yml
+++ b/python_seed/template/ci/.github/workflows/ci.yml
@@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- python: [3.6, 3.7, 3.8]
+ python-version: [3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v2
@@ -73,4 +73,4 @@ jobs:
echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc
- name: run tox
- run: ~/.local/bin/tox
\ No newline at end of file
+ run: tox
\ No newline at end of file
From dd6abe3b9620813b21e3e682aa142a22861f9762 Mon Sep 17 00:00:00 2001
From: vincentsarago
Date: Fri, 21 Aug 2020 10:25:19 -0400
Subject: [PATCH 06/14] try 4
---
.github/workflows/ci.yml | 8 ++++----
python_seed/template/ci/.github/workflows/ci.yml | 9 +++++----
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 2e7e0555..e5016127 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -21,15 +21,15 @@ jobs:
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 using the version of Python in `PATH`
run: tox -e py
-
+
# Run pre-commit (only for python-3.7)
- name: run pre-commit
- if: ${{ matrix.python-version }} == 3.7
+ if: matrix.python-version == 3.7
run: pre-commit run --all-files
-
+
- name: Upload Results
if: success()
uses: codecov/codecov-action@v1
diff --git a/python_seed/template/ci/.github/workflows/ci.yml b/python_seed/template/ci/.github/workflows/ci.yml
index 481674bf..800e68a6 100644
--- a/python_seed/template/ci/.github/workflows/ci.yml
+++ b/python_seed/template/ci/.github/workflows/ci.yml
@@ -21,15 +21,15 @@ jobs:
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 using the version of Python in `PATH`
run: tox -e py
-
+
# Run pre-commit (only for python-3.7)
- name: run pre-commit
- if: ${{ matrix.python-version }} == 3.7
+ if: matrix.python-version == 3.7
run: pre-commit run --all-files
-
+
- name: Upload Results
if: success()
uses: codecov/codecov-action@v1
@@ -39,6 +39,7 @@ jobs:
name: ${{ matrix.platform }}-${{ matrix.tox-env }}
fail_ci_if_error: false
+
publish:
needs: [tests]
runs-on: ubuntu-latest
From 22fec00fe37f725764418f71dfe7417434b7918b Mon Sep 17 00:00:00 2001
From: vincentsarago
Date: Fri, 21 Aug 2020 12:04:44 -0400
Subject: [PATCH 07/14] update publish
---
.github/workflows/ci.yml | 31 ++++++++---------
.../template/ci/.github/workflows/ci.yml | 34 +++++++++----------
2 files changed, 30 insertions(+), 35 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e5016127..096b1108 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -43,8 +43,6 @@ jobs:
needs: [tests]
runs-on: ubuntu-latest
if: contains(github.ref, 'tags')
- env:
- TOXENV: release
steps:
- uses: actions/checkout@v2
- name: Set up Python
@@ -57,21 +55,20 @@ jobs:
python -m pip install --upgrade pip
python -m pip install tox
- - name: Set env
+ - name: Set tag version
+ id: tag
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
- run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF#refs/*/}
-
- - name: Check git tag vs. version
- # We Only deploy to PyPi if github tag match the python version
- run: |
- VERSION=$(python setup.py --version)
- if [ "$VERSION" = "$RELEASE_VERSION" ]; then exit 0; else exit 3; fi
-
- - name: init .pypirc
- run: |
- echo -e "[pypi]" >> ~/.pypirc
- echo -e "username = $PYPI_USER" >> ~/.pypirc
- echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc
+ run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- - name: run tox
+ - 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
\ No newline at end of file
diff --git a/python_seed/template/ci/.github/workflows/ci.yml b/python_seed/template/ci/.github/workflows/ci.yml
index 800e68a6..c76e6609 100644
--- a/python_seed/template/ci/.github/workflows/ci.yml
+++ b/python_seed/template/ci/.github/workflows/ci.yml
@@ -44,34 +44,32 @@ jobs:
needs: [tests]
runs-on: ubuntu-latest
if: contains(github.ref, 'tags')
- env:
- TOXENV: release
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
- python-version: "3.x"
+ python-version: "3.x"
+
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
- - name: Set env
+ - name: Set tag version
+ id: tag
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
- run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF#refs/*/}
-
- - name: Check git tag vs. version
- # We Only deploy to PyPi if github tag match the python version
- run: |
- VERSION=$(python setup.py --version)
- if [ "$VERSION" = "$RELEASE_VERSION" ]; then exit 0; else exit 3; fi
-
- - name: init .pypirc
- run: |
- echo -e "[pypi]" >> ~/.pypirc
- echo -e "username = $PYPI_USER" >> ~/.pypirc
- echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc
+ run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- - name: run tox
+ - 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
\ No newline at end of file
From aac7653e7a907727e91f000abbbf043228b1a30a Mon Sep 17 00:00:00 2001
From: vincentsarago
Date: Fri, 21 Aug 2020 12:11:01 -0400
Subject: [PATCH 08/14] fix deploy
---
python_seed/template/ci/.github/workflows/ci.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/python_seed/template/ci/.github/workflows/ci.yml b/python_seed/template/ci/.github/workflows/ci.yml
index c76e6609..edd0b103 100644
--- a/python_seed/template/ci/.github/workflows/ci.yml
+++ b/python_seed/template/ci/.github/workflows/ci.yml
@@ -64,7 +64,7 @@ jobs:
- 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}
+ run: echo ::set-output name=version::$(python setup.py --version)
- name: Build and publish
if: steps.tag.outputs.tag == steps.module.outputs.version
From cfcd81d43eb0dbe46eb247f958d890d3405e42a6 Mon Sep 17 00:00:00 2001
From: vincentsarago
Date: Fri, 21 Aug 2020 12:12:53 -0400
Subject: [PATCH 09/14] fix deploy
---
.github/workflows/ci.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 096b1108..3105c9a3 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -63,7 +63,7 @@ jobs:
- 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}
+ run: echo ::set-output name=version::$(python setup.py --version)
- name: Build and publish
if: steps.tag.outputs.tag == steps.module.outputs.version
From 30bb1599b5ac87ba6593cf163d76064f04362e20 Mon Sep 17 00:00:00 2001
From: vincentsarago
Date: Fri, 21 Aug 2020 12:17:09 -0400
Subject: [PATCH 10/14] remove circleci
---
.circleci/config.yml | 116 -------------------------------------------
1 file changed, 116 deletions(-)
delete mode 100644 .circleci/config.yml
diff --git a/.circleci/config.yml b/.circleci/config.yml
deleted file mode 100644
index 273eef7a..00000000
--- a/.circleci/config.yml
+++ /dev/null
@@ -1,116 +0,0 @@
-# Python CircleCI 2.0 configuration file
-#
-# Check https://circleci.com/docs/2.0/language-python/ for more details
-
-# Environment variables required:
-# - PYPI_USER / PYPI_PASSWORD: for publishing package to PyPi
-
-version: 2
-
-common: &common
- working_directory: ~/python-seed
- steps:
- # Get Code from github
- - checkout
-
- # Install deps
- - run:
- name: install dependencies
- command: pip install tox codecov pre-commit --user
-
- # Run tests using TOX
- - run:
- name: run tox
- command: ~/.local/bin/tox
-
- # Run pre-commit (only for python-3.7)
- - run:
- name: run pre-commit
- command: |
- if [[ "$CIRCLE_JOB" == "python-3.7" ]]; then
- ~/.local/bin/pre-commit run --all-files
- fi
-
- # Upload code coverage (only if env have UPLOAD_COVERAGE=1)
- - run:
- name: upload coverage report
- command: |
- if [[ "$UPLOAD_COVERAGE" == 1 ]]; then
- ~/.local/bin/coverage xml
- ~/.local/bin/codecov
- fi
- when: always
-
-
-jobs:
- "python-3.6":
- <<: *common
- docker:
- - image: circleci/python:3.6.5
- environment:
- - TOXENV=py36
-
- "python-3.7":
- <<: *common
- docker:
- - image: circleci/python:3.7.2
- environment:
- - TOXENV=py37
- - UPLOAD_COVERAGE=1
-
- "python-3.8":
- <<: *common
- docker:
- - image: circleci/python:3.8.4
- environment:
- - TOXENV=py38
-
- deploy:
- docker:
- - image: circleci/python:3.7.2
- environment:
- - TOXENV=release
- working_directory: ~/python-seed
- steps:
- - checkout
-
- # We Only deploy to PyPi if github tag match the python version
- - run:
- name: verify git tag vs. version
- command: |
- VERSION=$(python setup.py --version)
- if [ "$VERSION" = "$CIRCLE_TAG" ]; then exit 0; else exit 3; fi
-
- - run:
- name: init .pypirc
- command: |
- echo -e "[pypi]" >> ~/.pypirc
- echo -e "username = $PYPI_USER" >> ~/.pypirc
- echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc
-
- - run:
- name: install dependencies
- command: pip install tox --user
-
- - run:
- name: run tox
- command: ~/.local/bin/tox
-
-workflows:
- version: 2
- build_and_deploy:
- jobs:
- - "python-3.6"
- - "python-3.7":
- filters: # required since `deploy` has tag filters AND requires `build`
- tags:
- only: /.*/
- - "python-3.8"
- - deploy:
- requires:
- - "python-3.7"
- filters:
- tags:
- only: /^[0-9]+.*/
- branches:
- ignore: /.*/
From 875d2f9f391757ea03dcd2c3fc48c5d831d10319 Mon Sep 17 00:00:00 2001
From: vincentsarago
Date: Fri, 21 Aug 2020 12:32:24 -0400
Subject: [PATCH 11/14] fix new line and add codecov config for ci
---
.github/workflows/ci.yml | 2 +-
README.md | 4 ++--
codecov.yml | 8 ++++++++
python_seed/scripts/cli.py | 5 +++++
python_seed/template/ci/.github/workflows/ci.yml | 2 +-
python_seed/template/cov/codecov.yml | 8 ++++++++
python_seed/template/module/requirements-dev.txt | 2 +-
python_seed/template/module/requirements.txt | 2 +-
requirements.txt | 2 +-
9 files changed, 28 insertions(+), 7 deletions(-)
create mode 100644 codecov.yml
create mode 100644 python_seed/template/cov/codecov.yml
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 3105c9a3..6e9aae1c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -71,4 +71,4 @@ jobs:
TOXENV: release
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
- run: tox
\ No newline at end of file
+ run: tox
diff --git a/README.md b/README.md
index 8a655d37..49e9c1c7 100644
--- a/README.md
+++ b/README.md
@@ -7,8 +7,8 @@
Starter kit for creating a new python package.
-
-
+
+
diff --git a/codecov.yml b/codecov.yml
new file mode 100644
index 00000000..c61977e2
--- /dev/null
+++ b/codecov.yml
@@ -0,0 +1,8 @@
+comment: off
+
+coverage:
+ status:
+ project:
+ default:
+ target: auto
+ threshold: 5
diff --git a/python_seed/scripts/cli.py b/python_seed/scripts/cli.py
index 8eb5cd84..8869dc26 100644
--- a/python_seed/scripts/cli.py
+++ b/python_seed/scripts/cli.py
@@ -33,6 +33,11 @@ def create(name, 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):
diff --git a/python_seed/template/ci/.github/workflows/ci.yml b/python_seed/template/ci/.github/workflows/ci.yml
index edd0b103..dabc8dff 100644
--- a/python_seed/template/ci/.github/workflows/ci.yml
+++ b/python_seed/template/ci/.github/workflows/ci.yml
@@ -72,4 +72,4 @@ jobs:
TOXENV: release
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
- run: tox
\ No newline at end of file
+ run: tox
diff --git a/python_seed/template/cov/codecov.yml b/python_seed/template/cov/codecov.yml
new file mode 100644
index 00000000..c61977e2
--- /dev/null
+++ b/python_seed/template/cov/codecov.yml
@@ -0,0 +1,8 @@
+comment: off
+
+coverage:
+ status:
+ project:
+ default:
+ target: auto
+ threshold: 5
diff --git a/python_seed/template/module/requirements-dev.txt b/python_seed/template/module/requirements-dev.txt
index 84bb552b..1f960b0b 100644
--- a/python_seed/template/module/requirements-dev.txt
+++ b/python_seed/template/module/requirements-dev.txt
@@ -1,3 +1,3 @@
pytest
pytest-cov
-pre-commit
\ No newline at end of file
+pre-commit
diff --git a/python_seed/template/module/requirements.txt b/python_seed/template/module/requirements.txt
index b98f6609..dca9a909 100644
--- a/python_seed/template/module/requirements.txt
+++ b/python_seed/template/module/requirements.txt
@@ -1 +1 @@
-click
\ No newline at end of file
+click
diff --git a/requirements.txt b/requirements.txt
index b98f6609..dca9a909 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1 +1 @@
-click
\ No newline at end of file
+click
From 9fafaf959ce15ecfd39c5470132410afb07ab59d Mon Sep 17 00:00:00 2001
From: vincentsarago
Date: Fri, 21 Aug 2020 12:38:59 -0400
Subject: [PATCH 12/14] update readme
---
README.md | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index 49e9c1c7..bfb644a7 100644
--- a/README.md
+++ b/README.md
@@ -58,24 +58,24 @@ Commands:
```
```
-$ pyseed create --help
+pyseed create --help
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/
@@ -90,14 +90,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.
```
From 314519f943372fa10779d27a6951358be939d26a Mon Sep 17 00:00:00 2001
From: vincentsarago
Date: Fri, 21 Aug 2020 12:40:01 -0400
Subject: [PATCH 13/14] add cov in manifest
---
MANIFEST.in | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/MANIFEST.in b/MANIFEST.in
index 3f4e5306..e28fe9f9 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,4 +1,5 @@
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/*
\ No newline at end of file
+include python_seed/template/module/*
From 558ef4854df510449aec113bb85fd4eb1fdcdf19 Mon Sep 17 00:00:00 2001
From: vincentsarago
Date: Fri, 21 Aug 2020 12:44:13 -0400
Subject: [PATCH 14/14] update readme
---
README.md | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index bfb644a7..2e0fca24 100644
--- a/README.md
+++ b/README.md
@@ -58,7 +58,7 @@ Commands:
```
```
-pyseed create --help
+$ pyseed create --help
Usage: pyseed create [OPTIONS] NAME
Create new python seed skeleton.
@@ -86,6 +86,26 @@ 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/
+requirements-dev.txt
+requirements.txt
+setup.py
+tests/
+tox.ini
+```
+
# Project structure
```