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

[WIP] Add support for GitHub actions #95

Merged
merged 30 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1b46c55
Add draft implementation for GH actions CI
jaimergp Nov 25, 2019
e25cdaf
Escape GH Actions double curly braces
jaimergp Nov 25, 2019
04e6aeb
... in all occurrences :)
jaimergp Nov 25, 2019
3589152
Remove flake8 linting
jaimergp Nov 27, 2019
2c8bd3e
Drop Python 3.8 for now
jaimergp Nov 27, 2019
dc049dd
Add support for non-conda testing
jaimergp Nov 27, 2019
190021c
Add Windows support via bash shells
jaimergp Nov 27, 2019
0666058
Define and use a unified CONDA_EXE env variable
jaimergp Nov 27, 2019
b5984df
Do not restrict max parallel tasks
jaimergp Nov 27, 2019
1dd4c3a
Rename some GHA steps [skip ci]
jaimergp Nov 27, 2019
9b3219f
Add some debugging statements to GHA CI
jaimergp Dec 1, 2019
b448a16
Rename 'build' job to 'test'
jaimergp Dec 1, 2019
5427c3c
Use codecov GH action
jaimergp Dec 1, 2019
61ff699
Escape GHA braces
jaimergp Dec 1, 2019
9e3205c
`conda` is already in PATH, no need for environment variables.
jaimergp Dec 1, 2019
ea2f3ca
Use PYVER env var for cleaner code
jaimergp Dec 1, 2019
8cfbb24
Force colored output in pytest
jaimergp Dec 1, 2019
e97878a
GHA: Use bash script to initialize conda in the shell
jaimergp Dec 4, 2019
dce9a96
GHA: Run on pull requests too
jaimergp Dec 4, 2019
ac94cce
GHA: Jinja will catch {{ }} in comments too
jaimergp Dec 4, 2019
bd54e79
Put initialize_conda.sh under devtools/github-actions
jaimergp Feb 11, 2020
3c60df1
Add GH Actions badge to README
jaimergp Feb 11, 2020
b2a2bc7
Updates for latest codecov GHA action
jaimergp Mar 9, 2020
1692ca0
Migrate conda support to goanpeca's action
jaimergp May 23, 2020
8a025e4
Change CI provider settings
jaimergp May 23, 2020
8ababd6
Merge remote-tracking branch 'upstream/master' into gh-actions
jaimergp May 23, 2020
68734f7
Fix tests (GH Actions still needed!)
jaimergp May 23, 2020
6b41ad8
Change default options in CI providers
jaimergp May 26, 2020
00f1dcb
Label GH Actions as experimental
jaimergp May 26, 2020
01df365
Add a short paragraph on GHA to the README
jaimergp May 26, 2020
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
34 changes: 17 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,56 +10,56 @@ matrix:
- LICENSE=1
- DEPEND_SOURCE=1
- PYTHON_VER=3.7
- WINDOWS_CI=1
- CI_PROVIDER=2 # Travis+Appveyor
- os: osx
language: generic
env:
- LICENSE=1
- DEPEND_SOURCE=2
- PYTHON_VER=3.7
- WINDOWS_CI=1
- CI_PROVIDER=2
- os: osx
language: generic
env:
- LICENSE=2
- DEPEND_SOURCE=3
- PYTHON_VER=3.7
- WINDOWS_CI=1
- CI_PROVIDER=2
- os: osx
language: generic
env:
- LICENSE=2
- DEPEND_SOURCE=3
- PYTHON_VER=3.7
- WINDOWS_CI=2
- CI_PROVIDER=1 # Travis only
- os: osx
language: generic
env:
- LICENSE=1
- DEPEND_SOURCE=1
- PYTHON_VER=3.6
- WINDOWS_CI=1
- CI_PROVIDER=2
- os: osx
language: generic
env:
- LICENSE=1
- DEPEND_SOURCE=2
- PYTHON_VER=3.6
- WINDOWS_CI=1
- CI_PROVIDER=2
- os: osx
language: generic
env:
- LICENSE=2
- DEPEND_SOURCE=3
- PYTHON_VER=3.6
- WINDOWS_CI=1
- CI_PROVIDER=2
- os: osx
language: generic
env:
- LICENSE=2
- DEPEND_SOURCE=3
- PYTHON_VER=3.6
- WINDOWS_CI=2
- CI_PROVIDER=1

# Pin Xenial for 3.7
- os: linux
Expand All @@ -69,7 +69,7 @@ matrix:
- LICENSE=1
- DEPEND_SOURCE=1
- PYTHON_VER=3.7
- WINDOWS_CI=1
- CI_PROVIDER=2

- os: linux
dist: xenial
Expand All @@ -78,7 +78,7 @@ matrix:
- LICENSE=1
- DEPEND_SOURCE=2
- PYTHON_VER=3.7
- WINDOWS_CI=1
- CI_PROVIDER=2

- os: linux
dist: xenial
Expand All @@ -87,7 +87,7 @@ matrix:
- LICENSE=2
- DEPEND_SOURCE=3
- PYTHON_VER=3.7
- WINDOWS_CI=1
- CI_PROVIDER=2

- os: linux
dist: xenial
Expand All @@ -96,39 +96,39 @@ matrix:
- LICENSE=2
- DEPEND_SOURCE=3
- PYTHON_VER=3.7
- WINDOWS_CI=2
- CI_PROVIDER=1

- os: linux
python: 3.6
env:
- LICENSE=1
- DEPEND_SOURCE=1
- PYTHON_VER=3.6
- WINDOWS_CI=1
- CI_PROVIDER=2

- os: linux
python: 3.6
env:
- LICENSE=1
- DEPEND_SOURCE=2
- PYTHON_VER=3.6
- WINDOWS_CI=1
- CI_PROVIDER=2

- os: linux
python: 3.6
env:
- LICENSE=2
- DEPEND_SOURCE=3
- PYTHON_VER=3.6
- WINDOWS_CI=1
- CI_PROVIDER=2

- os: linux
python: 3.6
env:
- LICENSE=2
- DEPEND_SOURCE=3
- PYTHON_VER=3.6
- WINDOWS_CI=2
- CI_PROVIDER=1

before_install:
# Make sure pip is around, on OSX Travis we have to do some shenanigans
Expand All @@ -138,7 +138,7 @@ before_install:
- pip install pyyaml cookiecutter

# Build out the cookiecutter from settings
- python tests/setup_cookiecutter.py default_project $LICENSE $DEPEND_SOURCE $WINDOWS_CI
- python tests/setup_cookiecutter.py default_project $LICENSE $DEPEND_SOURCE $CI_PROVIDER

# Change into new project directory
- cd default_project
Expand Down
244 changes: 125 additions & 119 deletions README.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ environment:
DEPEND_SOURCE: 1
PYTHON_VERSION: "3.6"
PYTHON_ARCH: "64"
WINDOWS: 1
CI_PROVIDER: 2 # Travis+Appveyor

- PYTHON: "C:\\Miniconda37-x64"
LICENSE: 2
DEPEND_SOURCE: 2
PYTHON_VERSION: "3.7"
PYTHON_ARCH: "64"
WINDOWS: 1
CI_PROVIDER: 2

- PYTHON: "C:\\Python36-x64"
LICENSE: 1
DEPEND_SOURCE: 3
PYTHON_VERSION: "3.6"
PYTHON_ARCH: "64"
WINDOWS: 1
CI_PROVIDER: 2



Expand All @@ -34,7 +34,7 @@ install:
- git config --global core.autocrlf true

# Build out the cookiecutter from settings
- python tests/setup_cookiecutter.py default_project %LICENSE% %DEPEND_SOURCE% %WINDOWS%
- python tests/setup_cookiecutter.py default_project %LICENSE% %DEPEND_SOURCE% %CI_PROVIDER%

# Change into new project directory
- ps: cd default_project
Expand Down
20 changes: 15 additions & 5 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@
"author_name": "Your name (or your organization/company/team)",
"author_email": "Your email (or your organization/company/team)",
"description": "A short description of the project.",
"open_source_license": ["MIT", "BSD-3-Clause", "LGPLv3", "Not Open Source"],
"open_source_license": [
"MIT",
"BSD-3-Clause",
"LGPLv3",
"Not Open Source"
],
"dependency_source": [
"Prefer conda-forge over the default anaconda channel with pip fallback",
"Prefer default anaconda channel with pip fallback",
"Dependencies from pip only (no conda)"],
"Include_Windows_continuous_integration": ["y","n"],
"_cms_cc_version": 1.2
}
"Dependencies from pip only (no conda)"
],
"continuous_integration_provider": [
"Travis",
"Travis+AppVeyor",
"GitHub Actions (experimental)"
],
"_cms_cc_version": 1.3
}
17 changes: 13 additions & 4 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import os
import subprocess as sp
import shutil


def decode_string(string):
Expand Down Expand Up @@ -58,11 +59,19 @@ def git_init_and_tag():
print("\ngit repository detected. CookieCutter files have been created in {{ cookiecutter.repo_name }} directory.")


def remove_windows_ci():
include_windows = '{{ cookiecutter.Include_Windows_continuous_integration }}'
if include_windows == "n":
def select_continuous_integration_provider():
provider = '{{ cookiecutter.continuous_integration_provider }}'.lower()
if provider == "github actions (experimental)":
# Remove with appveyor to be a safe delete
os.remove("appveyor.yml")
os.remove(".travis.yml")
shutil.rmtree("devtools/travis-ci")
elif provider == "travis":
shutil.rmtree(".github/workflows")
os.remove("appveyor.yml")
elif provider == "travis+appveyor":
shutil.rmtree(".github/workflows")


remove_windows_ci()
select_continuous_integration_provider()
git_init_and_tag()
6 changes: 3 additions & 3 deletions tests/setup_cookiecutter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
project = sys.argv[1]
lic = sys.argv[2]
depend = sys.argv[3]
windows = sys.argv[4]
print("Options: open_source_license=%s, dependency_source=%s, windows_ci=%s" % (lic, depend, windows))
provider = sys.argv[4]
print("Options: open_source_license=%s, dependency_source=%s, ci_provider=%s" % (lic, depend, provider))

# Setup the options
options = [project, # Repo name
Expand All @@ -20,7 +20,7 @@
"", # Description
lic, # License
depend, # Dependency
windows] # Windows
provider] # ci_provider

# Open a thread
p = Popen(["cookiecutter", "."], stdin=PIPE, stdout=PIPE)
Expand Down
82 changes: 82 additions & 0 deletions {{cookiecutter.repo_name}}/.github/workflows/CI.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: CI

on:
push:
branches:
- "master"
pull_request:
branches:
- "master"
schedule:
# Nightly tests run on master by default:
# Scheduled workflows run on the latest commit on the default or base branch.
# (from https://help.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule)
- cron: "0 0 * * *"

jobs:
test:
name: Test on {{ '${{ matrix.os }}' }}, Python {{ '${{ matrix.python-version }}' }}
runs-on: {{ '${{ matrix.os }}' }}
strategy:
matrix:
os: [macOS-latest, ubuntu-latest, windows-latest]
python-version: [3.6, 3.7]

steps:
- uses: actions/checkout@v1

- name: Additional info about the build
shell: bash
run: |
uname -a
df -h
ulimit -a

{% if cookiecutter.dependency_source == 'Dependencies from pip only (no conda)' %}
- name: Install testing dependencies
shell: bash
run: |
python -m pip install -U pytest pytest-cov codecov
{% else %}
# More info on options: https://github.com/goanpeca/setup-miniconda
- uses: goanpeca/setup-miniconda@v1
with:
python-version: {{ '${{ matrix.python-version }}' }}
environment-file: devtools/conda-envs/test_env.yaml
{% if cookiecutter.dependency_source == 'Prefer conda-forge over the default anaconda channel with pip fallback' %}
channels: conda-forge,defaults
{% endif %}
activate-environment: test
auto-update-conda: true
auto-activate-base: false
show-channel-urls: true
{% endif %}
- name: Install package
{% if cookiecutter.dependency_source == 'Dependencies from pip only (no conda)' %}
shell: bash
run: |
python -m pip install .
{% else %}
# conda setup requires this special shell
shell: bash -l {0}
run: |
python -m pip install . --no-deps
conda list
{% endif %}

- name: Run tests
{% if cookiecutter.dependency_source == 'Dependencies from pip only (no conda)' %}
shell: bash
{% else %}
# conda setup requires this special shell
shell: bash -l {0}
{% endif %}
run: |
pytest -v --cov={{ cookiecutter.repo_name }} --cov-report=xml --color=yes {{ cookiecutter.repo_name }}/tests/

- name: CodeCov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
flags: unittests
name: codecov-{{ '${{ matrix.os }}' }}-py{{ '${{ matrix.python-version }}' }}
7 changes: 6 additions & 1 deletion {{cookiecutter.repo_name}}/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
{{cookiecutter.project_name}}
==============================
[//]: # (Badges)
{% if cookiecutter.continuous_integration_provider == "GitHub Actions (experimental)" -%}
[![GitHub Actions Build Status](https://github.com/REPLACE_WITH_OWNER_ACCOUNT/{{cookiecutter.repo_name}}/workflows/CI/badge.svg)](https://github.com/REPLACE_WITH_OWNER_ACCOUNT/{{cookiecutter.repo_name}}/actions?query=branch%3Amaster+workflow%3ACI)
{% elif cookiecutter.continuous_integration_provider == "Travis" -%}
[![Travis Build Status](https://travis-ci.com/REPLACE_WITH_OWNER_ACCOUNT/{{cookiecutter.project_name}}.svg?branch=master)](https://travis-ci.com/REPLACE_WITH_OWNER_ACCOUNT/{{cookiecutter.project_name}})
{% elif cookiecutter.continuous_integration_provider == "Travis+AppVeyor" -%}
[![Travis Build Status](https://travis-ci.com/REPLACE_WITH_OWNER_ACCOUNT/{{cookiecutter.project_name}}.svg?branch=master)](https://travis-ci.com/REPLACE_WITH_OWNER_ACCOUNT/{{cookiecutter.project_name}})
{% if cookiecutter.Include_Windows_continuous_integration == "y" -%}
[![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/REPLACE_WITH_APPVEYOR_LINK/branch/master?svg=true)](https://ci.appveyor.com/project/REPLACE_WITH_OWNER_ACCOUNT/{{cookiecutter.project_name}}/branch/master)
{% endif -%}
[![codecov](https://codecov.io/gh/REPLACE_WITH_OWNER_ACCOUNT/{{cookiecutter.project_name}}/branch/master/graph/badge.svg)](https://codecov.io/gh/REPLACE_WITH_OWNER_ACCOUNT/{{cookiecutter.project_name}}/branch/master)


{{cookiecutter.description}}

### Copyright
Expand Down