Skip to content

Handle relative paths and writing nonexistent directories for CONDA_PROJECT_ENVS_PATH #370

Handle relative paths and writing nonexistent directories for CONDA_PROJECT_ENVS_PATH

Handle relative paths and writing nonexistent directories for CONDA_PROJECT_ENVS_PATH #370

Workflow file for this run

name: Build and test
on:
push:
paths-ignore:
- "README.md"
- "LICENSE"
- "MANIFEST"
- "docs/**"
- ".github/workflows/docs.yml"
branches:
- main
pull_request:
paths-ignore:
- "README.md"
- "LICENSE"
- "MANIFEST"
- "docs/**"
- ".github/workflows/docs.yml"
branches:
- main
jobs:
conda-package:
name: Build Conda package
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Create build environment
run: |
source $CONDA/bin/activate
conda env create -f etc/build-environment.yml
- name: conda Build
run: |
source $CONDA/bin/activate && conda activate build-conda-project
VERSION=`hatch version` conda build -c conda-forge --output-folder conda-build conda.recipe
- name: Upload the build artifact
uses: actions/upload-artifact@v3
with:
name: package-${{ github.sha }}
path: conda-build
build-wheel:
name: Build the wheel
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4
with:
python-version: "3.10"
- name: Install build dependencies
run: pip install build
- name: Build the package
run: python -m build
- name: Upload the build artifact
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
with:
name: wheel-${{ github.sha }}
path: dist/*.whl
if-no-files-found: error
retention-days: 7
test:
name: Test (conda ${{ matrix.conda-version }}, Python ${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: [3.8, 3.9, "3.10"]
conda-version: ["4.11", "4.12", "4.13", "4.14", "22.9", "22.11", "23.1", "23.3", "23.5"]
exclude:
# Python 3.10
- conda-version: "4.11"
python-version: "3.10"
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
- name: Download conda standalone
shell: bash
run: |
if [ $RUNNER_OS == 'Linux' ]; then
curl https://repo.anaconda.com/pkgs/misc/conda-execs/conda-latest-linux-64.exe -o conda.exe
elif [ $RUNNER_OS == 'Windows' ]; then
curl https://repo.anaconda.com/pkgs/misc/conda-execs/conda-4.10.3-win-64.exe -o conda.exe
elif [ $RUNNER_OS == 'macOS' ]; then
curl https://repo.anaconda.com/pkgs/misc/conda-execs/conda-latest-osx-64.exe -o conda.exe
fi
chmod +x conda.exe
./conda.exe config --set auto_update_conda false
./conda.exe clean -ay
./conda.exe info
- name: Setup miniconda
shell: bash
run: |
./conda.exe create -p $HOME/miniconda conda=${{ matrix.conda-version }} python=${{ matrix.python-version }}
- name: Install Libmamba
shell: bash
run: |
if [[ ! "${{ matrix.conda-version }}" =~ ^("4.9"|"4.10"|"4.11")$ ]]; then
if [ $RUNNER_OS == 'Windows' ]; then
source $HOME/miniconda/Scripts/activate root && \
conda install conda-libmamba-solver -p $HOME/miniconda
else
source $HOME/miniconda/bin/activate root && \
conda install conda-libmamba-solver -p $HOME/miniconda
fi
fi
- name: Update with test dependencies
shell: bash
run: |
if [ $RUNNER_OS == 'Windows' ]; then
source $HOME/miniconda/Scripts/activate root && conda env update -f etc/test-environment.yml -p $HOME/miniconda && $HOME/miniconda/Scripts/pip install --no-deps .
else
source $HOME/miniconda/bin/activate root && conda env update -f etc/test-environment.yml -p $HOME/miniconda && $HOME/miniconda/bin/pip install --no-deps .
fi
- name: py.test
shell: bash
env:
CONDA_DEFAULT_CHANNELS: conda-forge
run: |
if [ $RUNNER_OS == 'Windows' ]; then
source $HOME/miniconda/Scripts/activate root && \
conda --version && \
py.test \
-xv \
--cov-report xml:./coverage.xml \
--cov conda_project \
tests
else
source $HOME/miniconda/bin/activate root && \
conda --version && \
py.test \
-xv \
--cov-report xml:./coverage.xml \
--cov conda_project \
tests
fi
- uses: codecov/codecov-action@v2
with:
files: ./coverage.xml
env_vars: OS,PYTHON
upload:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Retrieve the source code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download the build artifacts
uses: actions/download-artifact@v2
with:
name: package-${{ github.sha }}
path: conda-bld
- name: Upload to anaconda.org
env:
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
GITHUB_REF: ${{ github.ref }}
run: |
source $CONDA/bin/activate
conda install -y anaconda-client
[[ "$GITHUB_REF" =~ ^refs/tags/ ]] || export LABEL="--label dev"
anaconda --verbose --token $ANACONDA_TOKEN upload --user defusco $LABEL conda-bld/noarch/conda-project*.tar.bz2 --force
- name: Clean up older artifacts
uses: glassechidna/artifact-cleaner@master
with:
minimumAge: 86400
publish-to-pypi:
name: Build & publish to PyPI
if: github.event_name == 'release' && github.event.action == 'created'
runs-on: ubuntu-latest
needs: [check]
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Setup Python
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4
- name: Download the build artifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3
with:
name: wheel-${{ github.sha }}
path: ~/dist
- name: Install build dependencies
run: pip install twine
- name: Upload to PyPI with twine
run: python -m twine upload ~/dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN}}
# This check job runs to ensure all tests have passed, such that we can use it as a "wildcard" for branch
# protection to ensure all tests pass before a PR can be merged.
check:
if: always()
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Decide whether all required jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}