Skip to content

Commit

Permalink
Switch to Cirrus CI
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianWilhelm committed Oct 20, 2019
1 parent 2dd5604 commit 10cdae7
Show file tree
Hide file tree
Showing 8 changed files with 201 additions and 106 deletions.
174 changes: 174 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
---
# Default values to be merged into tasks:
auto_cancellation: false
env:
PATH: ${HOME}/.local/bin:${PATH}
# ^ add user paths
COVERALLS_REPO_TOKEN: vEF8gOZhUEEO0hO8lI2kYDYEo65hadwuT
PIP_CACHE: ${HOME}/.cache/pip
LC_ALL: C.UTF-8
LANG: C.UTF-8

# use custom cloning since otherwise git tags are missing
clone_script: &clone_script |
if [ -z "$CIRRUS_PR" ]; then
git clone --recursive --branch=$CIRRUS_BRANCH https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR
git reset --hard $CIRRUS_CHANGE_IN_REPO
else
git clone --recursive https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR
git fetch origin pull/$CIRRUS_PR/head:pull/$CIRRUS_PR
git reset --hard $CIRRUS_CHANGE_IN_REPO
fi


# This template is used in all tasks
regular_task_template: &REGULAR_TASK_TEMPLATE
tox_install_script:
# Tox is a bit exigent about the name of the python executable,
# (for example, tox requires a `python3.7` to be available)
# and the shape of the directory python is installed to.
# Because of that, some errors might appear in some kinds of installation
# (e.g. OSX with homebrew).
# Luckily, pipx install tox inside its own unique virtualenv, which
# resembles a very standard installation directory.
# So here we install tox using pipx to avoid such problems
- python -m pip install --upgrade pip
- python -m pip install --user pipx
- pipx install tox
prepare_script: &prepare_script
- git config --global user.email "you@example.com"
- git config --global user.name "Your Name"
- git config --system core.longpaths true # Fix for windows git checkout problems
- rm -rf .coverage junit-*.xml
# ^ avoid information carried from one run to the other
test_script:
- tox -e all -- --color yes


# Task definitions:
linux_mac_task:
# use custom cloning since otherwise git tags are missing
clone_script: *clone_script
matrix:
- name: test (Linux - 3.5)
container: {image: "python:3.5-buster"}
pip_cache: &pip-cache
folder: $PIP_CACHE
install_script: &debian-install
- apt-get install -y git
- name: test (Linux - 3.6)
container: {image: "python:3.6-buster"}
pip_cache: *pip-cache
install_script: *debian-install
- name: test (Linux - 3.7)
container: {image: "python:3.7-buster"}
pip_cache: *pip-cache
install_script: *debian-install
- name: test (Linux - Anaconda)
container: {image: "continuumio/anaconda3:2019.03"}
pip_cache: *pip-cache
install_script: *debian-install
- name: test (OS X)
osx_instance: {image: "mojave-xcode-10.2"}
env:
PYTHON_VERSION: 3.7
# ^ it is important to update this env vars when the default version
# of python in homebrew changes
PATH: "${HOME}/.local/bin:${HOME}/Library/Python/${PYTHON_VERSION}/bin:/usr/local/opt/python/libexec/bin:${PATH}"
# ^ add user and homebrew paths
PIP_CACHE: "${HOME}/Library/Caches/pip"
brew_cache:
folder: "$HOME/Library/Caches/Homebrew"
pip_cache: *pip-cache
install_script:
- brew install python gnu-tar
- brew cleanup
<< : *REGULAR_TASK_TEMPLATE


windows_task:
name: test (Windows)
clone_script:
CMD.exe /C ECHO ON &
IF NOT DEFINED CIRRUS_PR (
git clone --recursive --branch=%CIRRUS_BRANCH% https://x-access-token:%CIRRUS_REPO_CLONE_TOKEN%@github.com/%CIRRUS_REPO_FULL_NAME%.git %CIRRUS_WORKING_DIR% &
git reset --hard %CIRRUS_CHANGE_IN_REPO%
) ELSE (
git clone --recursive https://x-access-token:%CIRRUS_REPO_CLONE_TOKEN%@github.com/%CIRRUS_REPO_FULL_NAME%.git %CIRRUS_WORKING_DIR% &
git fetch origin pull/%CIRRUS_PR%/head:pull/%CIRRUS_PR% &
git reset --hard %CIRRUS_CHANGE_IN_REPO%
)
windows_container:
image: "cirrusci/windowsservercore:cmake"
# ^ this image have MSYS2 pre-installed, which means we can use some
# of the GNU tools (like the `rm` command)
os_version: 2019
env:
# Single quotes are used bellow to escape Windows backslash and %
# (YAML restrictions).
PYTHON_HOME: 'C:\Python37'
PYTHON_APPDATA: '%APPDATA%\Python\Python37'
# ^ it is important to update these 2 env vars when the default version
# of python in chocolatey changes
MSYS_HOME: 'C:\tools\msys64'
HOME: '%USERPROFILE%'
USERNAME: 'ContainerAdministrator'
# ^ Ensure USERNAME is set in Windows, so the getpass module doesn't
# raise exceptions
ToolsDir: 'C:\tools'
PATH: '%HOME%\.local\bin\;%PYTHON_APPDATA%\Scripts\;%PYTHON_HOME%\;%PYTHON_HOME%\Scripts\;%MSYS_HOME%\bin\;%MSYS_HOME%\usr\bin\;%MSYS_HOME%\usr\local\bin\;%PATH%'
# ^ add user, chocolatey and msys paths
CHOCOLATEY_CACHE: '%LocalAppData%\chocolatey\Cache'
PIP_CACHE: '%LocalAppData%\pip\Cache'
PIP_TRUSTED_HOST: 'pypi.org pypi.python.org files.pythonhosted.org'
PIP_CONFIG_FILE: '%AppData%\pip\pip.ini'
COVERAGE: 'NO'
chocolatey_cache:
folder: '%CHOCOLATEY_CACHE%'
pip_cache:
folder: '%PIP_CACHE%'
install_script:
# Activate long file paths to avoid some errors
- REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem /v LongPathsEnabled /t REG_DWORD /d 1 /f
# Set Windows encoding to UTF-8
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Command Processor" /v Autorun /t REG_SZ /d "@chcp 65001>nul" /f
- choco config set cacheLocation %CHOCOLATEY_CACHE%
- choco install --no-progress -y python --version 3.7
- python -m pip install -U --user pip setuptools certifi
- python -m pip install -U --user tox pytest-cov pytest-xdist pytest-virtualenv pytest-shutil pytest-fixture-config cookiecutter django
- python -m pip list
prepare_script: *prepare_script
windows_clean_script:
# use parentheses to suppress errors
- ps: (rm junit-*.xml)
- ps: (rm -Recurse -Force .tox)
test_script:
- ps: python -m tox -e all -- --color yes



coverage_task:
name: coverage (Linux)
clone_script: *clone_script
container: {image: "python:3.6-buster"}
env:
COVERAGE: yes
depends_on:
- test (Linux - 3.6)
- test (Linux - 3.7)
- test (Linux - Anaconda)
- test (OS X)
- test (Windows)
install_script: *debian-install
pip_install_script:
pip install --user --upgrade
pytest pytest-cov pytest-virtualenv
coverage coveralls
flake8 pre-commit
precommit_script:
- pre-commit install
- pre-commit run --all-files
<< : *REGULAR_TASK_TEMPLATE
coverage_script:
- coverage combine .coverage
- coveralls
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog
=========

Version 0.4.1
=============

- Fix problem with additional new lines in Windows

Version 0.4
===========

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[![Build Status](https://travis-ci.org/pyscaffold/pyscaffoldext-dsproject.svg?branch=master)](https://travis-ci.org/pyscaffold/pyscaffoldext-dsproject)
[![Build Status](https://api.cirrus-ci.com/github/pyscaffold/pyscaffoldext-dsproject.svg?branch=master)](https://cirrus-ci.com/github/pyscaffold/pyscaffoldext-dsproject)
[![Coveralls](https://img.shields.io/coveralls/github/pyscaffold/pyscaffoldext-dsproject/master.svg)](https://coveralls.io/r/pyscaffold/pyscaffoldext-dsproject)
[![PyPI-Server](https://img.shields.io/pypi/v/pyscaffoldext-dsproject.svg)](https://pypi.org/project/pyscaffoldext-dsproject)


# pyscaffoldext-dsproject

[PyScaffold] extension tailored for *Data Science* projects. This extension is inspired by
Expand All @@ -14,7 +15,7 @@

Also consider using [dvc] to version control and share your data within your team.
Read [this blogpost] to learn how to work with JupyterLab notebooks efficiently by using a
data science project structure like this.
data science project structure like this.

The final directory structure looks like:
```
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ packages = find:
include_package_data = True
package_dir =
=src
install_requires = pyscaffold>=3.2a0,<4.0a0;pyscaffoldext-markdown<0.4a0
install_requires = pyscaffold>=3.2a0,<4.0a0;pyscaffoldext-markdown
# DON'T CHANGE THE FOLLOWING LINE! IT WILL BE UPDATED BY PYSCAFFOLD!
setup_requires = pyscaffold>=3.2a0,<3.3a0
setup_requires = pyscaffold>=3.2a0,<4.0a0
# The usage of test_requires is discouraged, see `Dependency Management` docs
# tests_require = pytest; pytest-cov
# Require a specific Python version, e.g. Python 2.7 or >= 3.4
Expand Down
8 changes: 5 additions & 3 deletions src/pyscaffoldext/dsproject/templates/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import os
import string
from pkg_resources import resource_string

Expand All @@ -15,9 +16,10 @@ def get_template(name):
:obj:`string.Template`: template
"""
file_name = "{name}.template".format(name=name)
data = resource_string("pyscaffoldext.dsproject.templates",
file_name)
return string.Template(data.decode("UTF-8"))
data = resource_string(__name__, file_name)
# we assure that line endings are converted to '\n' for all OS
data = data.decode(encoding="utf-8").replace(os.linesep, '\n')
return string.Template(data)


def gitignore_all(opts):
Expand Down
61 changes: 0 additions & 61 deletions tests/travis_install.sh

This file was deleted.

15 changes: 12 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,24 @@
# THIS SCRIPT IS SUPPOSED TO BE AN EXAMPLE. MODIFY IT ACCORDING TO YOUR NEEDS!

[tox]
minversion = 2.4
minversion = 3.8
envlist = default

[testenv]
setenv = TOXINIDIR = {toxinidir}
setenv =
TOXINIDIR = {toxinidir}
passenv =
HOME
USER
USERNAME
COVERAGE
PIP_CACHE
deps =
certifi
pytest
pyscaffold
commands =
py.test {posargs}
all: py.test {posargs}
extras =
all
testing

0 comments on commit 10cdae7

Please sign in to comment.