Skip to content
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
121 changes: 121 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Reference:
# - https://cirrus-ci.org/guide/writing-tasks/
# - https://cirrus-ci.org/guide/linux/
# - https://hub.docker.com/_/gcc/
# - https://hub.docker.com/_/python/

#
# Global defaults.
#
container:
image: python:3.8

env:
# Maximum cache period (in weeks) before forcing a new cache upload.
CACHE_PERIOD: "2"
# Increment the build number to force new mambaforge cache upload.
MAMBA_CACHE_BUILD: "0"
# Increment the build number to force new stratify cache upload.
STRATIFY_CACHE_BUILD: "0"
# Base environment conda packages to be installed.
MAMBA_CACHE_PACKAGES: "pip conda-lock"
# Enable Cython code coverage.
CYTHON_COVERAGE: "1"

#
# Testing (Linux)
#
linux_task:
auto_cancellation: true
matrix:
env:
PY_VER: "3.8"
env:
PY_VER: "3.9"
COVERAGE: "1"
name: "Linux: py${PY_VER}"
container:
image: gcc:latest
env:
PATH: ${HOME}/mambaforge/bin:${PATH}
mamba_cache:
folder: ${HOME}/mambaforge
fingerprint_script:
- wget --quiet https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh -O mambaforge.sh
- echo "${CIRRUS_OS} $(sha256sum mambaforge.sh)"
- echo "${MAMBA_CACHE_PACKAGES}"
- echo "$(date +%Y).$(expr $(date +%U) / ${CACHE_PERIOD}):${MAMBA_CACHE_BUILD}"
populate_script:
- bash mambaforge.sh -b -p ${HOME}/mambaforge
- conda config --set always_yes yes --set changeps1 no
- conda config --set show_channel_urls True
- conda config --add channels conda-forge
- conda install --quiet --name base ${MAMBA_CACHE_PACKAGES}
check_script:
- conda info --all
- conda list --name base
stratify_cache:
folder: ${HOME}/mambaforge/envs/py${PY_VER}
fingerprint_script:
- echo "${CIRRUS_OS} py${PY_VER} tests"
- echo "$(date +%Y).$(expr $(date +%U) / ${CACHE_PERIOD}):${STRATIFY_CACHE_BUILD}"
- cat ${CIRRUS_WORKING_DIR}/requirements/py$(echo ${PY_VER} | tr -d ".").yml
populate_script:
- conda-lock --mamba --platform linux-64 --file ${CIRRUS_WORKING_DIR}/requirements/py$(echo ${PY_VER} | tr -d ".").yml
- mamba create --name py${PY_VER} --quiet --file conda-linux-64.lock
- cp conda-linux-64.lock ${HOME}/mambaforge/envs/py${PY_VER}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, so you're caching the lock info in the CI 👍

test_script:
- cat ${HOME}/mambaforge/envs/py${PY_VER}/conda-linux-64.lock >&2
- source ${HOME}/mambaforge/etc/profile.d/conda.sh >/dev/null 2>&1
- conda activate py${PY_VER} >/dev/null 2>&1
- python setup.py build_ext --inplace
- pip install --no-deps --editable .
- if [ -n "${COVERAGE}" ]; then pytest --cov-report=xml --cov; else pytest; fi
- if [ -n "${COVERAGE}" ]; then codecov; fi

#
# Testing (macOS)
#
osx_task:
auto_cancellation: true
matrix:
env:
PY_VER: "3.8"
name: "OSX: py${PY_VER}"
osx_instance:
image: catalina-xcode
env:
PATH: ${HOME}/mambaforge/bin:${PATH}
mamba_cache:
folder: ${HOME}/mambaforge
fingerprint_script:
- wget --quiet https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-MacOSX-x86_64.sh -O mambaforge.sh
- echo "${CIRRUS_OS} $(shasum -a 256 mambaforge.sh)"
- echo "${MAMBA_CACHE_PACKAGES}"
- echo "$(date +%Y).$(expr $(date +%U) / ${CACHE_PERIOD}):${MAMBA_CACHE_BUILD}"
populate_script:
- bash mambaforge.sh -b -p ${HOME}/mambaforge
- conda config --set always_yes yes --set changeps1 no
- conda config --set show_channel_urls True
- conda config --add channels conda-forge
- conda install --quiet --name base ${MAMBA_CACHE_PACKAGES}
check_script:
- conda info --all
- conda list --name base
stratify_cache:
folder: ${HOME}/mambaforge/envs/py${PY_VER}
fingerprint_script:
- echo "${CIRRUS_OS} py${PY_VER} tests"
- echo "$(date +%Y).$(expr $(date +%U) / ${CACHE_PERIOD}):${STRATIFY_CACHE_BUILD}"
- cat ${CIRRUS_WORKING_DIR}/requirements/py$(echo ${PY_VER} | tr -d ".").yml
populate_script:
- conda-lock --mamba --platform osx-64 --file ${CIRRUS_WORKING_DIR}/requirements/py$(echo ${PY_VER} | tr -d ".").yml
- mamba create --yes --name py${PY_VER} --quiet --file conda-osx-64.lock
- cp conda-osx-64.lock ${HOME}/mambaforge/envs/py${PY_VER}
test_script:
- cat ${HOME}/mambaforge/envs/py${PY_VER}/conda-osx-64.lock >&2
- source ${HOME}/mambaforge/etc/profile.d/conda.sh >/dev/null 2>&1
- conda activate py${PY_VER} >/dev/null 2>&1
- python setup.py build_ext --inplace
- pip install --no-deps --editable .
- pytest
18 changes: 0 additions & 18 deletions .coveragerc

This file was deleted.

28 changes: 28 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[flake8]

# References:
# https://flake8.readthedocs.io/en/latest/user/configuration.html
# https://flake8.readthedocs.io/en/latest/user/error-codes.html
# https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes

select = C,D,E,F,W,B,B950
ignore =
# E203: whitespace before ':'
E203,
# E226: missing whitespace around arithmetic operator
E226,
# E231: missing whitespace after ',', ';', or ':'
E231,
# E402: module level imports on one line
E402,
# E501: line too long
E501,
# E731: do not assign a lambda expression, use a def
E731,
# W503: line break before binary operator
W503,
# W504: line break after binary operator
W504
exclude =
.eggs
build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
_version.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this file and why explicitly ignored?

Copy link
Member Author

@bjlittle bjlittle May 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used by scm and you do not place it under source code control.

It's like a scratch file that scm uses, as per your configuration, to dump its versioning metadata, see pyproject.toml:line+14.

This is then parsed by stratify.init:line+2

*.so
__pycache__
*.egg-info
Expand Down
39 changes: 39 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.0.1'
hooks:
# Prevent giant files from being committed.
- id: check-added-large-files
# Check whether files parse as valid Python.
- id: check-ast
# Check for file name conflicts on case-insensitive filesytems.
- id: check-case-conflict
# Check for files that contain merge conflict strings.
- id: check-merge-conflict
# Check for debugger imports and py37+ `breakpoint()` calls in Python source.
- id: debug-statements
# Don't commit to master branch.
- id: no-commit-to-branch
- repo: https://github.com/psf/black
rev: '21.5b0'
hooks:
- id: black
# Force black to run on whole repo, using settings from pyproject.toml
pass_filenames: false
args: [--config=./pyproject.toml, .]
- repo: https://gitlab.com/pycqa/flake8
rev: '3.9.2'
hooks:
# Run flake8.
- id: flake8
args: [--config=./.flake8]
- repo: https://github.com/pycqa/isort
rev: 5.8.0
hooks:
- id: isort
name: isort (python)
- id: isort
name: isort (cython)
types: [cython]
5 changes: 0 additions & 5 deletions .stickler.yml

This file was deleted.

53 changes: 0 additions & 53 deletions .travis.yml

This file was deleted.

37 changes: 35 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
[build-system]
# Defined by PEP 518
requires = ["setuptools>=40.8.0", "wheel", "numpy", "Cython"]
requires = [
"setuptools>=42",
"wheel",
"numpy",
"Cython",
"setuptools_scm[toml]>=6.0"
]
# Defined by PEP 517
build-backend = "setuptools.build_meta:__legacy__"
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "stratify/_version.py"
Copy link
Member Author

@bjlittle bjlittle May 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tell scm where to dump its metadata - this nominated file must not be kept under source code control


[tool.black]
target-version = ['py38']
line-length = 88
include = '\.pyi?$'
exclude = '''
(
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
)
'''

[tool.isort]
profile = "black"
3 changes: 0 additions & 3 deletions requirements-dev.txt

This file was deleted.

3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

24 changes: 24 additions & 0 deletions requirements/py38.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: stratify-dev

channels:
- conda-forge

dependencies:
- python=3.8

# Setup dependencies.
- setuptools
- setuptools-scm

# Core dependencies.
- numpy
- cython

# Test dependencies.
- black=21.5b0
- codecov
- flake8=3.9.2
- isort=5.8.0
- pre-commit
- pytest
- pytest-cov
24 changes: 24 additions & 0 deletions requirements/py39.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: stratify-dev

channels:
- conda-forge

dependencies:
- python=3.9

# Setup dependencies.
- setuptools
- setuptools-scm

# Core dependencies.
- numpy
- cython

# Test dependencies.
- black=21.5b0
- codecov
- flake8=3.8.2
- isort=5.8.0
- pre-commit
- pytest
- pytest-cov
1 change: 1 addition & 0 deletions requirements/stratify.yml
Loading