Skip to content

Commit

Permalink
CI: Factor out Conda-based install
Browse files Browse the repository at this point in the history
  • Loading branch information
dopplershift committed Nov 5, 2021
1 parent b1b1d41 commit 4e5692b
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 71 deletions.
46 changes: 46 additions & 0 deletions .github/actions/install-conda/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: 'Install Using Conda'
description: 'Setup environment and install using a Conda-based toolchain'
inputs:
type:
description: 'Whether test or doc build'
required: true
python-version:
description: 'What version of Python to use'
required: true
runs:
using: composite
steps:
- name: Setup conda caching
uses: actions/[email protected]
with:
path: ~/conda_pkgs_dir
key: conda-${{ inputs.type }}-${{ runner.os }}-${{ inputs.python-version}}-${{ hashFiles('ci/*') }}
restore-keys: |
conda-${{ inputs.type }}-${{ runner.os }}-${{ inputs.python-version}}
conda-${{ inputs.type }}-${{ runner.os }}
conda-${{ inputs.type }}-
- name: Set up Python ${{ matrix.python-version }}
uses: conda-incubator/[email protected]
with:
miniforge-version: latest
miniforge-variant: mambaforge
python-version: ${{ inputs.python-version }}
channel-priority: strict
channels: conda-forge/label/testing,conda-forge
show-channel-urls: true
# Needed for caching
use-only-tar-bz2: true

- name: Install dependencies
shell: bash -l {0}
run: mamba install --quiet --yes --file ci/${{ inputs.type }}_requirements.txt --file ci/extra_requirements.txt --file ci/requirements.txt

- name: Install
shell: bash -l {0}
# For some reason on Windows 3.7 building the wheel fails to properly include our extra
# stuff. Executing the egg_info beforehand for some reason fixes it. No idea why. We're
# deep in territory where googling for answers helps not at all.
run: |
python setup.py egg_info
python -m pip install --no-deps .
4 changes: 4 additions & 0 deletions .github/actions/install-pypi/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ runs:
pip-${{ inputs.type }}-${{ runner.os }}-
pip-${{ inputs.type }}-
- name: Setup PROJ
if: ${{ inputs.need-cartopy == 'true' }}
uses: ./.github/actions/setup-proj

# This installs the stuff needed to build and install Shapely and CartoPy from source.
- name: Install CartoPy build dependencies
if: ${{ inputs.need-cartopy == 'true' }}
Expand Down
32 changes: 3 additions & 29 deletions .github/workflows/docs-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,11 @@ jobs:
- name: Get tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Setup conda caching
uses: actions/[email protected]
- name: Install from Conda
uses: ./.github/actions/install-conda
with:
path: ~/conda_pkgs_dir
key: conda-docs-${{ runner.os }}-${{ matrix.python-version}}-${{ hashFiles('ci/*') }}
restore-keys: |
conda-docs-${{ runner.os }}-${{ matrix.python-version}}
conda-docs-${{ runner.os }}
conda-docs-
- name: Set up Python ${{ matrix.python-version }}
uses: conda-incubator/[email protected]
with:
miniforge-version: latest
miniforge-variant: mambaforge
type: 'doc'
python-version: ${{ matrix.python-version }}
channel-priority: strict
show-channel-urls: true
# Needed for caching
use-only-tar-bz2: true

- name: Install dependencies
run: mamba install --quiet --yes --file ci/doc_requirements.txt --file ci/extra_requirements.txt --file ci/requirements.txt

- name: Install
# For some reason on Windows 3.7 building the wheel fails to properly include our extra
# stuff. Executing the egg_info beforehand for some reason fixes it. No idea why. We're
# deep in territory where googling for answers helps not at all.
run: |
python setup.py egg_info
python -m pip install --no-deps .

- name: Build docs
run: |
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ jobs:
- name: Add extras to requirements
run: cat ci/extra_requirements.txt >> ci/doc_requirements.txt

- name: Setup PROJ
uses: ./.github/actions/setup-proj

- name: Install using PyPI
uses: ./.github/actions/install-pypi
with:
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/nightly-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ jobs:
echo git+git://github.com/hgrecco/pint@master#egg=pint >> ci/test_requirements.txt
echo git+git://github.com/pydata/xarray@main#egg=xarray >> ci/test_requirements.txt
- name: Setup PROJ
uses: ./.github/actions/setup-proj

- name: Install using PyPI
uses: ./.github/actions/install-pypi
with:
Expand Down Expand Up @@ -86,9 +83,6 @@ jobs:
echo git+git://github.com/hgrecco/pint@master#egg=pint >> ci/doc_requirements.txt
echo git+git://github.com/pydata/xarray@main#egg=xarray >> ci/doc_requirements.txt
- name: Setup PROJ
uses: ./.github/actions/setup-proj

- name: Install using PyPI
uses: ./.github/actions/install-pypi
with:
Expand Down
33 changes: 3 additions & 30 deletions .github/workflows/tests-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,38 +33,11 @@ jobs:
- name: Get tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Setup conda caching
uses: actions/[email protected]
- name: Install from Conda
uses: ./.github/actions/install-conda
with:
path: ~/conda_pkgs_dir
key: conda-tests-${{ runner.os }}-${{ matrix.python-version}}-${{ hashFiles('ci/*') }}
restore-keys: |
conda-tests-${{ runner.os }}-${{ matrix.python-version}}
conda-tests-${{ runner.os }}
conda-tests-
- name: Set up Python ${{ matrix.python-version }}
uses: conda-incubator/[email protected]
with:
miniforge-version: latest
miniforge-variant: mambaforge
type: 'test'
python-version: ${{ matrix.python-version }}
channel-priority: strict
channels: conda-forge/label/testing,conda-forge
show-channel-urls: true
# Needed for caching
use-only-tar-bz2: true

- name: Install dependencies
run: mamba install --quiet --yes --file ci/test_requirements.txt --file ci/extra_requirements.txt --file ci/requirements.txt

- name: Install
# For some reason on Windows 3.7 building the wheel fails to properly include our extra
# stuff. Executing the egg_info beforehand for some reason fixes it. No idea why. We're
# deep in territory where googling for answers helps not at all.
run: |
python setup.py egg_info
python -m pip install --no-deps .

- name: Run tests
uses: ./.github/actions/run-tests
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/tests-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ jobs:
out.write(dep.replace('>=', '==') + '\n')
EOF
- name: Setup PROJ
uses: ./.github/actions/setup-proj

- name: Install from PyPI
uses: ./.github/actions/install-pypi
with:
Expand Down

0 comments on commit 4e5692b

Please sign in to comment.