|
| 1 | +# Reference: |
| 2 | +# - https://cirrus-ci.org/guide/writing-tasks/ |
| 3 | +# - https://cirrus-ci.org/guide/linux/ |
| 4 | +# - https://hub.docker.com/_/gcc/ |
| 5 | +# - https://hub.docker.com/_/python/ |
| 6 | + |
| 7 | +# |
| 8 | +# Global defaults. |
| 9 | +# |
| 10 | +container: |
| 11 | + image: python:latest |
| 12 | + cpu: 2 |
| 13 | + memory: 4G |
| 14 | + |
| 15 | + |
| 16 | +env: |
| 17 | + # Maximum cache period (in weeks) before forcing a new cache upload. |
| 18 | + CACHE_PERIOD: "2" |
| 19 | + # Increment the build number to force new mambaforge cache upload. |
| 20 | + MAMBA_CACHE_BUILD: "0" |
| 21 | + # Increment the build number to force new mint cache upload. |
| 22 | + NCTA_CACHE_BUILD: "0" |
| 23 | + # Base environment conda packages to be installed |
| 24 | + MAMBA_CACHE_PACKAGES: "pip conda-lock" |
| 25 | + # Increment the build number to forve new pip cache upload. |
| 26 | + PIP_CACHE_BUILD: "0" |
| 27 | + # Linting packages to be installed. |
| 28 | + PIP_CACHE_PACKAGES: "black flake8 isort" |
| 29 | + |
| 30 | + |
| 31 | +# |
| 32 | +# Linting |
| 33 | +# |
| 34 | +lint_task: |
| 35 | + auto_cancellation: true |
| 36 | + name: "${CIRRUS_OS}: linting" |
| 37 | + pip_cache: |
| 38 | + folder: ~/.cache/pip |
| 39 | + fingerprint_script: |
| 40 | + - echo "${CIRRUS_TASK_NAME} py${PYTHON_VERSION}" |
| 41 | + - echo "$(date +%Y).$(expr $(date +%U) / ${CACHE_PERIOD}):${PIP_CACHE_BUILD} ${PIP_CACHE_PACKAGES}" |
| 42 | + lint_script: |
| 43 | + - pip list |
| 44 | + - python -m pip install --retries 3 --upgrade ${PIP_CACHE_PACKAGES} |
| 45 | + - pip list |
| 46 | + - black --check ${CIRRUS_WORKING_DIR} |
| 47 | + - flake8 ${CIRRUS_WORKING_DIR} |
| 48 | + - isort --check ${CIRRUS_WORKING_DIR} |
| 49 | + |
| 50 | + |
| 51 | +# |
| 52 | +# Testing (Linux) |
| 53 | +# |
| 54 | +linux_task: |
| 55 | + auto_cancellation: true |
| 56 | + matrix: |
| 57 | + env: |
| 58 | + PY_VER: "3.7" |
| 59 | + env: |
| 60 | + PY_VER: "3.8" |
| 61 | + env: |
| 62 | + PY_VER: "3.9" |
| 63 | + COVERAGE: "codecov" |
| 64 | + name: "${CIRRUS_OS}: py${PY_VER}" |
| 65 | + container: |
| 66 | + image: gcc:latest |
| 67 | + env: |
| 68 | + PATH: ${HOME}/mambaforge/bin:${PATH} |
| 69 | + mamba_cache: |
| 70 | + folder: ${HOME}/mambaforge |
| 71 | + fingerprint_script: |
| 72 | + - wget --quiet https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh -O mambaforge.sh |
| 73 | + - echo "${CIRRUS_OS} $(sha256sum mambaforge.sh)" |
| 74 | + - echo "${MAMBA_CACHE_PACKAGES}" |
| 75 | + - echo "$(date +%Y).$(expr $(date +%U) / ${CACHE_PERIOD}):${MAMBA_CACHE_BUILD}" |
| 76 | + populate_script: |
| 77 | + - bash mambaforge.sh -b -p ${HOME}/mambaforge |
| 78 | + - conda config --set always_yes yes --set changeps1 no |
| 79 | + - conda config --set show_channel_urls True |
| 80 | + - conda config --add channels conda-forge |
| 81 | + - conda install --quiet --name base ${MAMBA_CACHE_PACKAGES} |
| 82 | + check_script: |
| 83 | + - conda info --all |
| 84 | + - conda list --name base |
| 85 | + ncta_cache: |
| 86 | + folder: ${HOME}/mambaforge/envs/py${PY_VER} |
| 87 | + fingerprint_script: |
| 88 | + - echo "${CIRRUS_OS} py${PY_VER} tests" |
| 89 | + - echo "$(date +%Y).$(expr $(date +%U) / ${CACHE_PERIOD}):${MINT_CACHE_BUILD}" |
| 90 | + - cat ${CIRRUS_WORKING_DIR}/requirements/py$(echo ${PY_VER} | tr -d ".").yml |
| 91 | + populate_script: |
| 92 | + - conda-lock --mamba --platform linux-64 --file ${CIRRUS_WORKING_DIR}/requirements/py$(echo ${PY_VER} | tr -d ".").yml |
| 93 | + - mamba create --name py${PY_VER} --quiet --file conda-linux-64.lock |
| 94 | + - cp conda-linux-64.lock ${HOME}/mambaforge/envs/py${PY_VER} |
| 95 | + test_script: |
| 96 | + - cat ${HOME}/mambaforge/envs/py${PY_VER}/conda-linux-64.lock >&2 |
| 97 | + - source ${HOME}/mambaforge/etc/profile.d/conda.sh >/dev/null 2>&1 |
| 98 | + - conda activate py${PY_VER} >/dev/null 2>&1 |
| 99 | + - pip install --no-deps --editable . |
| 100 | + - pytest --cov-report=xml --cov |
| 101 | + - ${COVERAGE} |
0 commit comments