Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Github Actions support #44

Merged
merged 7 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 6 additions & 5 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"full_name": "Your Name",
"email": "email@mit.edu",
"github_username": "username",
"github_owner": ["DAI-Lab", "HDI-Project", "D3-AI", "{{ cookiecutter.github_username }}"],
"github_owner": ["DAI-Lab", "HDI-Project", "D3-AI", "data-dev", "sdv-dev", "{{ cookiecutter.github_username }}"],
"project_name": "Python Boilerplate",
"package_name": "{{ cookiecutter.project_name.lower().replace(' ', '-') }}",
"project_slug": "{{ cookiecutter.package_name.replace('-', '_') }}",
Expand All @@ -13,10 +13,11 @@
"pypi_username": "{{ 'mit_dai_lab' if cookiecutter.github_username != cookiecutter.github_owner else cookiecutter.github_username }}",
"version": "0.1.0.dev0",
"support_py2": "n",
"use_pypi_deployment_with_travis": "y",
"use_ghpages_deployment_with_travis": "y",
"use_codecov": "y",
"command_line_interface": ["Click", "No command-line interface"],
"ci_provider": ["Github Actions", "Travis CI", "No continuous integration"],
"use_pypi_with_ci": "n",
"use_ghpages_with_ci": "y",
"use_codecov_with_ci": "y",
"command_line_interface": ["No command-line interface", "Click"],
"create_author_file": "y",
"open_source_license": ["MIT license", "BSD license", "ISC license", "Apache Software License 2.0", "GNU General Public License v3", "Not open source"]
}
2 changes: 1 addition & 1 deletion docs/prompts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Options

The following package configuration options set up different features for your project.

use_pypi_deployment_with_travis
use_pypi_with_ci
Whether to use PyPI deployment with Travis.
k15z marked this conversation as resolved.
Show resolved Hide resolved

command_line_interface
Expand Down
6 changes: 6 additions & 0 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ def main():
cli_file = os.path.join('{{ cookiecutter.project_slug }}', 'cli.py')
remove_file(cli_file)

if '{{ cookiecutter.ci_provider }}' != 'Travis CI':
remove_file('.travis.yml')
elif '{{ cookiecutter.ci_provider }}' != 'Github Actions':
k15z marked this conversation as resolved.
Show resolved Hide resolved
remove_file('.github/workflows/docs.yml')
remove_file('.github/workflows/tests.yml')

if 'Not open source' == '{{ cookiecutter.open_source_license }}':
remove_file('LICENSE')

Expand Down
2 changes: 1 addition & 1 deletion tests/test_bake_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test_bake_with_apostrophe_and_run_tests(cookies):


def test_bake_without_travis_pypi_setup(cookies):
with bake_in_temp_dir(cookies, extra_context={'use_pypi_deployment_with_travis': 'n'}) as result:
with bake_in_temp_dir(cookies, extra_context={'use_pypi_with_ci': 'n'}) as result:
result_travis_config = yaml.load(result.project.join(".travis.yml").open())
assert "deploy" not in result_travis_config
assert "python" == result_travis_config["language"]
Expand Down
28 changes: 28 additions & 0 deletions {{cookiecutter.repository_name}}/.github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Generate Docs

on:
push:
branches: [ master ]

jobs:

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Python
uses: actions/setup-python@v1
with:
python-version: '3.7'

- name: Build
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
make docs
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: {{ '${{secrets.GITHUB_TOKEN}}' }}
publish_dir: docs/_build/html
65 changes: 65 additions & 0 deletions {{cookiecutter.repository_name}}/.github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Run Tests

on: [push]
k15z marked this conversation as resolved.
Show resolved Hide resolved

jobs:
build:
runs-on: {{ '${{ matrix.os }}' }}
strategy:
max-parallel: 4
k15z marked this conversation as resolved.
Show resolved Hide resolved
matrix:
python-version: [3.5, 3.6, 3.7, 3.8]
os: [ubuntu-latest, macos-latest]

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

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

- name: Test with tox
run: tox -e py

k15z marked this conversation as resolved.
Show resolved Hide resolved
{%- if cookiecutter.use_codecov_with_ci == 'y' %}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
{%- endif %}

{%- if cookiecutter.use_pypi_with_ci == 'y' %}
k15z marked this conversation as resolved.
Show resolved Hide resolved
# Automatically deploy releases to PyPI for each tagged commit. This
# uses the API Token feature (https://pypi.org/help/#apitoken). After
# obtaining an API token from PyPI, add it to your github secrets with
# the name `pypi_password`.
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
k15z marked this conversation as resolved.
Show resolved Hide resolved

- name: Build distribution
run: make dist

- name: Publish package
if: startsWith(github.event.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
{%- endif %}
8 changes: 4 additions & 4 deletions {{cookiecutter.repository_name}}/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ matrix:
sudo: required

# Command to install dependencies
{%- if cookiecutter.use_codecov == 'y' %}
{%- if cookiecutter.use_codecov_with_ci == 'y' %}
install: pip install -U tox-travis codecov

after_success: codecov
Expand All @@ -27,10 +27,10 @@ install: pip install -U tox-travis
# Command to run tests
script: tox

{% if cookiecutter.use_pypi_deployment_with_travis == 'y' or cookiecutter.use_ghpages_deployment_with_travis == 'y' -%}
{% if cookiecutter.use_pypi_with_ci == 'y' or cookiecutter.use_ghpages_with_ci == 'y' -%}
deploy:
{%- endif %}
{% if cookiecutter.use_pypi_deployment_with_travis == 'y' %}
{% if cookiecutter.use_pypi_with_ci == 'y' %}
# Automatically deploy releases to PyPI for each tagged commit
# Assuming you have installed the travis-ci CLI tool, after you
# create the Github repo and add it to Travis, run the
Expand All @@ -47,7 +47,7 @@ deploy:
repo: {{ cookiecutter.github_owner }}/{{ cookiecutter.repository_name }}
python: 3.6
{%- endif %}
{% if cookiecutter.use_ghpages_deployment_with_travis == 'y' %}
{% if cookiecutter.use_ghpages_with_ci == 'y' %}
# Automatically build and deploy documentation to GitHub Pages after every
# commit
# Follow the instructions at https://docs.travis-ci.com/user/deployment/pages/
Expand Down
8 changes: 6 additions & 2 deletions {{cookiecutter.repository_name}}/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Before you submit a pull request, check that it meets these guidelines:
4. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the documentation in an appropriate place.
5. The pull request should work for all the supported Python versions. Check the `Travis Build
5. The pull request should work for all the supported Python versions. Check the `Build
Status page`_ and make sure that all the checks pass.

Unit Testing Guidelines
Expand Down Expand Up @@ -233,5 +233,9 @@ or in command line::


.. _GitHub issues page: https://github.com/{{ cookiecutter.github_owner }}/{{ cookiecutter.repository_name }}/issues
.. _Travis Build Status page: https://travis-ci.org/{{ cookiecutter.github_owner }}/{{ cookiecutter.repository_name }}/pull_requests
{%- if cookiecutter.ci_provider == 'Github Actions' %}
.. _Build Status page: https://github.com/{{ cookiecutter.github_owner }}/{{ cookiecutter.repository_name }}/actions
{%- else %}
.. _Build Status page: https://travis-ci.org/{{ cookiecutter.github_owner }}/{{ cookiecutter.repository_name }}/pull_requests
{%- endif %}
.. _Google docstrings style: https://google.github.io/styleguide/pyguide.html?showone=Comments#Comments
2 changes: 1 addition & 1 deletion {{cookiecutter.repository_name}}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ install-develop: clean-build clean-pyc ## install the package in editable mode a

.PHONY: test-all
test-all: ## run tests on every Python version with tox
tox -r
tox -r -p auto
k15z marked this conversation as resolved.
Show resolved Hide resolved

.PHONY: fix-lint
fix-lint: ## fix lint issues using autoflake, autopep8, and isort
Expand Down
10 changes: 9 additions & 1 deletion {{cookiecutter.repository_name}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@
<!-- Uncomment these lines after releasing the package to PyPI for version and downloads badges -->
<!--[![PyPI Shield](https://img.shields.io/pypi/v/{{ cookiecutter.package_name }}.svg)](https://pypi.python.org/pypi/{{ cookiecutter.package_name }})-->
<!--[![Downloads](https://pepy.tech/badge/{{ cookiecutter.package_name }})](https://pepy.tech/project/{{ cookiecutter.package_name }})-->
ci_provider
{%- if cookiecutter.ci_provider == 'Travis CI' %}
[![Travis CI Shield](https://travis-ci.org/{{ cookiecutter.github_owner }}/{{ cookiecutter.repository_name }}.svg?branch=master)](https://travis-ci.org/{{ cookiecutter.github_owner }}/{{ cookiecutter.repository_name }})
{%- if cookiecutter.use_codecov == 'y' %}
{%- endif %}
{%- if cookiecutter.ci_provider == 'Github Actions' %}
[![Github Actions Shield](https://img.shields.io/github/workflow/status/{{ cookiecutter.github_owner }}/{{ cookiecutter.repository_name }}/Run%20Tests)](https://github.com/{{ cookiecutter.github_owner }}/{{ cookiecutter.repository_name }}/actions)
{%- endif %}
{%- if cookiecutter.use_codecov_with_ci == 'y' %}
[![Coverage Status](https://codecov.io/gh/{{ cookiecutter.github_owner }}/{{ cookiecutter.repository_name }}/branch/master/graph/badge.svg)](https://codecov.io/gh/{{ cookiecutter.github_owner }}/{{ cookiecutter.repository_name }})
{%- endif %}



# {{ cookiecutter.project_name }}

{{ cookiecutter.project_short_description }}
Expand Down
10 changes: 5 additions & 5 deletions {{cookiecutter.repository_name}}/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

from setuptools import setup, find_packages

with open('README.md') as readme_file:
with open('README.md', encoding="utf-8") as readme_file:
k15z marked this conversation as resolved.
Show resolved Hide resolved
readme = readme_file.read()

with open('HISTORY.md') as history_file:
with open('HISTORY.md', encoding="utf-8") as history_file:
history = history_file.read()

install_requires = [
Expand All @@ -32,9 +32,9 @@
'watchdog>=0.8.3',

# docs
'm2r>=0.2.0',
'Sphinx>=1.7.1',
'sphinx_rtd_theme>=0.2.4',
'm2r>=0.2.0,<0.3',
k15z marked this conversation as resolved.
Show resolved Hide resolved
'Sphinx>=1.7.1,<3',
'sphinx_rtd_theme>=0.2.4,<0.5',
'autodocsumm>=0.1.10',

# style check
Expand Down