Skip to content

Commit

Permalink
Merge pull request #1 from jakirkham/create_pkg
Browse files Browse the repository at this point in the history
Autogenerate package with cookiecutter
  • Loading branch information
jakirkham committed Aug 3, 2018
2 parents 6a66f6e + 0fb29fc commit 5ae6691
Show file tree
Hide file tree
Showing 57 changed files with 4,470 additions and 10 deletions.
45 changes: 45 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
platform:
- x64

branches:
only:
- master

environment:
matrix:
- PYVER: 36
- PYVER: 35
- PYVER: 27

install:
# If there is a newer build queued for the same PR, cancel this one.
- cmd: >
.gen_ci_support\\ff_ci_pr_build.py -v
--ci "appveyor"
"%APPVEYOR_ACCOUNT_NAME%/%APPVEYOR_PROJECT_SLUG%"
"%APPVEYOR_BUILD_NUMBER%"
"%APPVEYOR_PULL_REQUEST_NUMBER%"
# Install Miniconda.
- cmd: call .appveyor_support\\install_miniconda.bat

# Create the test environment.
- cmd: set "CONDA_ENV_TYPE=tst_py%PYVER%"
- cmd: call .appveyor_support\\create_env.bat

# Install the package and dependencies.
- cmd: pip install -e .

# Skip .NET project specific build phase.
build: off

# Run tests and measure test coverage.
test_script:
- cmd: coverage erase
- cmd: coverage run --source . setup.py test
- cmd: coverage report -m

on_success:
- cmd: set "CONDA_ENV_TYPE=dpl"
- cmd: .appveyor_support\\create_env.bat
- cmd: coveralls
31 changes: 31 additions & 0 deletions .appveyor_support/create_env.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
:: Show each command and output
@echo on

:: Check CONDA_ENV_TYPE was set.
if "$%CONDA_ENV_TYPE%" == "" (
echo "Set $CONDA_ENV_TYPE externally."
exit 1
)

:: Activate conda.
call "%MINICONDA_DIR%\Scripts\activate.bat"
if errorlevel 1 exit 1

:: Create a temporary directory for the environment.
python -c "import tempfile; print(tempfile.mkdtemp())" > tmp_dir.txt
if errorlevel 1 exit 1
set /p CONDA_ENV_PREFIX=<tmp_dir.txt
if errorlevel 1 exit 1
del tmp_dir.txt
if errorlevel 1 exit 1
set "CONDA_ENV_PATH=%CONDA_ENV_PREFIX%\%CONDA_ENV_TYPE%"
set "SCRIPT_DIR=%~dp0"
set "CONDA_ENV_SPEC=%SCRIPT_DIR%\environments\%CONDA_ENV_TYPE%.yml"

:: Fill the temporary directory.
call "%MINICONDA_DIR%\Scripts\activate.bat"
if errorlevel 1 exit 1
conda.exe env create -p "%CONDA_ENV_PATH%" -f "%CONDA_ENV_SPEC%"
if errorlevel 1 exit 1
call "%MINICONDA_DIR%\Scripts\activate.bat" "%CONDA_ENV_PATH%"
if errorlevel 1 exit 1
11 changes: 11 additions & 0 deletions .appveyor_support/environments/dpl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: pysharedmem_env

channels:
- conda-forge

dependencies:
- python==3.6
- pip==18.0
- wheel==0.31.1
- coverage==4.5.1
- coveralls==1.3.0
9 changes: 9 additions & 0 deletions .appveyor_support/environments/tst_py27.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: pysharedmem_env

channels:
- conda-forge

dependencies:
- pip==18.0
- wheel==0.31.1
- coverage==4.5.1
9 changes: 9 additions & 0 deletions .appveyor_support/environments/tst_py35.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: pysharedmem_env

channels:
- conda-forge

dependencies:
- pip==18.0
- wheel==0.31.1
- coverage==4.5.1
9 changes: 9 additions & 0 deletions .appveyor_support/environments/tst_py36.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: pysharedmem_env

channels:
- conda-forge

dependencies:
- pip==18.0
- wheel==0.31.1
- coverage==4.5.1
49 changes: 49 additions & 0 deletions .appveyor_support/install_miniconda.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
:: Configure batch
@echo on

:: Miniconda Config:
set "MINICONDA_VERSION=4.5.4"
set "MINICONDA_MD5=1c73051ccd997770288275ee6474b423"
set "MINICONDA_INSTALLER=%USERPROFILE%\miniconda.exe"
set "MINICONDA_DIR=%USERPROFILE%\miniconda"
set "MINICONDA_URL=https://repo.continuum.io/miniconda/Miniconda3-%MINICONDA_VERSION%-Windows-x86_64.exe"

:: Install Miniconda.
powershell -Command "(New-Object Net.WebClient).DownloadFile('%MINICONDA_URL%', '%MINICONDA_INSTALLER%')"
if errorlevel 1 exit 1
( certutil -hashfile "%MINICONDA_INSTALLER%" md5 | findstr /v ":" ) > "%MINICONDA_INSTALLER%.md5"
if errorlevel 1 exit 1
type "%MINICONDA_INSTALLER%.md5"
if errorlevel 1 exit 1
set /p MINICONDA_MD5_FOUND=<%MINICONDA_INSTALLER%.md5
if errorlevel 1 exit 1
set "MINICONDA_MD5_FOUND=%MINICONDA_MD5_FOUND: =%"
if errorlevel 1 exit 1
echo "%MINICONDA_MD5_FOUND%" | findstr /c:"%MINICONDA_MD5%"
if errorlevel 1 exit 1
start /wait "" %MINICONDA_INSTALLER% /InstallationType=JustMe ^
/AddToPath=0 ^
/RegisterPython=0 ^
/S ^
/D=%MINICONDA_DIR%
if errorlevel 1 exit 1
del "%MINICONDA_INSTALLER%"
if errorlevel 1 exit 1
del "%MINICONDA_INSTALLER%.md5"
if errorlevel 1 exit 1

:: Activate conda.
call "%MINICONDA_DIR%\Scripts\activate.bat"
if errorlevel 1 exit 1

:: Configure conda.
conda.exe config --set show_channel_urls true
if errorlevel 1 exit 1
conda.exe config --set auto_update_conda false
if errorlevel 1 exit 1
conda.exe config --set add_pip_as_python_dependency true
if errorlevel 1 exit 1

:: Patch VS 2008 for 64-bit support.
conda.exe install --quiet --yes "conda-forge::vs2008_express_vc_python_patch"
call setup_x64
27 changes: 27 additions & 0 deletions .circleci/checkout_merge_commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash


# Update PR refs for testing.
if [[ -n "${CIRCLE_PR_NUMBER}" ]]
then
FETCH_REFS="${FETCH_REFS} +refs/pull/${CIRCLE_PR_NUMBER}/head:pr/${CIRCLE_PR_NUMBER}/head"
FETCH_REFS="${FETCH_REFS} +refs/pull/${CIRCLE_PR_NUMBER}/merge:pr/${CIRCLE_PR_NUMBER}/merge"
fi

# Retrieve the refs.
if [[ -n "${CIRCLE_PR_NUMBER}" ]]
then
git fetch -u origin ${FETCH_REFS}
fi

# Checkout the PR merge ref.
if [[ -n "${CIRCLE_PR_NUMBER}" ]]
then
git checkout -qf "pr/${CIRCLE_PR_NUMBER}/merge"
fi

# Check for merge conflicts.
if [[ -n "${CIRCLE_PR_NUMBER}" ]]
then
git branch --merged | grep "pr/${CIRCLE_PR_NUMBER}/head" > /dev/null
fi
141 changes: 131 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,143 @@
version: 2

jobs:
build:
build_py36:
working_directory: ~/test
machine: true
branches:
ignore:
- /.*/
environment:
- PYVER: "36"
steps:
- checkout
- run:
command: exit 0
name: Fast finish outdated PRs and merge PRs
command: |
./.circleci/fast_finish_ci_pr_build.sh
./.circleci/checkout_merge_commit.sh
- run:
name: Install and Configure Miniconda
command: |
source .circleci/install_miniconda.sh
echo "MINICONDA_DIR=${MINICONDA_DIR}" >> "${BASH_ENV}"
- run:
name: Create the test environment
command: |
export CONDA_ENV_TYPE="tst_py${PYVER}"
source .circleci/create_env.sh
echo "CONDA_ENV_PATH=${CONDA_ENV_PATH}" >> "${BASH_ENV}"
- run:
name: Install the package and dependencies
command: |
source "${MINICONDA_DIR}/etc/profile.d/conda.sh"
conda activate "${CONDA_ENV_PATH}"
pip install -e .
- run:
name: Run tests and measure test coverage
command: |
source "${MINICONDA_DIR}/etc/profile.d/conda.sh"
conda activate "${CONDA_ENV_PATH}"
coverage erase
coverage run --source . setup.py test
coverage report -m
- run:
name: Report coverage
command: |
export CONDA_ENV_TYPE="dpl"
source .circleci/create_env.sh
coveralls
build_py35:
working_directory: ~/test
machine: true
environment:
- PYVER: "35"
steps:
- checkout
- run:
name: Fast finish outdated PRs and merge PRs
command: |
./.circleci/fast_finish_ci_pr_build.sh
./.circleci/checkout_merge_commit.sh
- run:
name: Install and Configure Miniconda
command: |
source .circleci/install_miniconda.sh
echo "MINICONDA_DIR=${MINICONDA_DIR}" >> "${BASH_ENV}"
- run:
name: Create the test environment
command: |
export CONDA_ENV_TYPE="tst_py${PYVER}"
source .circleci/create_env.sh
echo "CONDA_ENV_PATH=${CONDA_ENV_PATH}" >> "${BASH_ENV}"
- run:
name: Install the package and dependencies
command: |
source "${MINICONDA_DIR}/etc/profile.d/conda.sh"
conda activate "${CONDA_ENV_PATH}"
pip install -e .
- run:
name: Run tests and measure test coverage
command: |
source "${MINICONDA_DIR}/etc/profile.d/conda.sh"
conda activate "${CONDA_ENV_PATH}"
coverage erase
coverage run --source . setup.py test
coverage report -m
- run:
name: Report coverage
command: |
export CONDA_ENV_TYPE="dpl"
source .circleci/create_env.sh
coveralls
build_py27:
working_directory: ~/test
machine: true
environment:
- PYVER: "27"
steps:
- checkout
- run:
name: Fast finish outdated PRs and merge PRs
command: |
./.circleci/fast_finish_ci_pr_build.sh
./.circleci/checkout_merge_commit.sh
- run:
name: Install and Configure Miniconda
command: |
source .circleci/install_miniconda.sh
echo "MINICONDA_DIR=${MINICONDA_DIR}" >> "${BASH_ENV}"
- run:
name: Create the test environment
command: |
export CONDA_ENV_TYPE="tst_py${PYVER}"
source .circleci/create_env.sh
echo "CONDA_ENV_PATH=${CONDA_ENV_PATH}" >> "${BASH_ENV}"
- run:
name: Install the package and dependencies
command: |
source "${MINICONDA_DIR}/etc/profile.d/conda.sh"
conda activate "${CONDA_ENV_PATH}"
pip install -e .
- run:
name: Run tests and measure test coverage
command: |
source "${MINICONDA_DIR}/etc/profile.d/conda.sh"
conda activate "${CONDA_ENV_PATH}"
coverage erase
coverage run --source . setup.py test
coverage report -m
- run:
name: Report coverage
command: |
export CONDA_ENV_TYPE="dpl"
source .circleci/create_env.sh
coveralls
workflows:
version: 2
build_and_test:
jobs:
- build:
filters:
branches:
ignore:
- /.*/
- build_py36
- build_py35
- build_py27
27 changes: 27 additions & 0 deletions .circleci/create_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash -l

# Some reasonable bash constraints.
set -xeuo pipefail

# Check CONDA_ENV_TYPE was set.
if [ -z "${CONDA_ENV_TYPE}" ]; then
echo "Set $CONDA_ENV_TYPE externally."
exit 1
fi

# Activate conda.
source "${MINICONDA_DIR}/etc/profile.d/conda.sh"
conda activate

# Create a temporary directory for the environment.
export SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CONDA_ENV_PREFIX="$(python -c 'import tempfile; print(tempfile.mkdtemp())')"
export CONDA_ENV_PATH="${CONDA_ENV_PREFIX}/${CONDA_ENV_TYPE}"
export CONDA_ENV_SPEC="${SCRIPT_DIR}/environments/${CONDA_ENV_TYPE}.yml"

# Fill the temporary directory.
conda env create -p "${CONDA_ENV_PATH}" -f "${CONDA_ENV_SPEC}"
conda activate "${CONDA_ENV_PATH}"

# Unset all bash constraints.
set +xeuo pipefail
11 changes: 11 additions & 0 deletions .circleci/environments/dpl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: pysharedmem_env

channels:
- conda-forge

dependencies:
- python==3.6
- pip==18.0
- wheel==0.31.1
- coverage==4.5.1
- coveralls==1.3.0
Loading

0 comments on commit 5ae6691

Please sign in to comment.