Skip to content

Commit

Permalink
CI: Factor out installing from PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
dopplershift committed Nov 5, 2021
1 parent 77ae2da commit b1b1d41
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 138 deletions.
64 changes: 64 additions & 0 deletions .github/actions/install-pypi/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: 'Install Using PyPI'
description: 'Setup environment and install using the PyPI-based toolchain'
inputs:
need-cartopy:
description: 'Whether Cartopy is needed'
required: true
default: 'true'
type:
description: 'Whether test or doc build'
required: true
version-file:
description: 'Name of the version file to use for installation'
required: true
default: 'requirements.txt'
python-version:
description: 'What version of Python to use'
required: true

runs:
using: composite
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

# Use pip to find the right cache dir and then sets up caching for it
- name: Get pip cache dir
shell: bash
id: pip-cache
run: echo "::set-output name=dir::$(pip cache dir)"

- name: Setup pip caching
uses: actions/[email protected]
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip-${{ inputs.type }}-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('ci/*') }}
restore-keys: |
pip-${{ inputs.type }}-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('ci/*') }}
pip-${{ inputs.type }}-${{ runner.os }}-${{ inputs.python-version }}-
pip-${{ inputs.type }}-${{ runner.os }}-
pip-${{ inputs.type }}-
# This installs the stuff needed to build and install Shapely and CartoPy from source.
- name: Install CartoPy build dependencies
if: ${{ inputs.need-cartopy == 'true' }}
shell: bash
run: |
sudo apt-get install libgeos-dev
python -m pip install --upgrade pip setuptools
python -m pip install --no-binary :all: shapely
- name: Install dependencies
shell: bash
run: python -m pip install -r ci/${{ inputs.type }}_requirements.txt -c ci/${{ inputs.version-file }}

- name: Download Cartopy Maps
if: ${{ inputs.need-cartopy == 'true' }}
shell: bash
run: ci/download_cartopy_maps.py

- name: Install
shell: bash
run: python -m pip install -c ci/${{ inputs.version-file }} .
41 changes: 8 additions & 33 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,43 +47,18 @@ jobs:
- name: Get tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

# This uses pip to find the right cache dir and then sets up caching for it
- name: Get pip cache dir
id: pip-cache
run: echo "::set-output name=dir::$(pip cache dir)"

- name: Setup pip cache
uses: actions/[email protected]
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip-docs-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('ci/*') }}
restore-keys: |
pip-docs-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('ci/*') }}
pip-docs-${{ runner.os }}-${{ matrix.python-version }}-
pip-docs-${{ runner.os }}-
pip-docs-
- name: Add extras to requirements
run: cat ci/extra_requirements.txt >> ci/doc_requirements.txt

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

# This installs the stuff needed to build and install Shapely and CartoPy from source.
- name: Install dependencies (PyPI)
run: |
sudo apt-get install libgeos-dev
python -m pip install --upgrade pip setuptools
python -m pip install --no-binary :all: shapely
python -m pip install -r ci/doc_requirements.txt -r ci/extra_requirements.txt -c ci/${{ matrix.dep-versions }}
- name: Download Cartopy Maps
run: ci/download_cartopy_maps.py

- name: Install self
run: python -m pip install -c ci/${{ matrix.dep-versions }} .
- name: Install using PyPI
uses: ./.github/actions/install-pypi
with:
need-cartopy: true
type: 'doc'
python-version: ${{ matrix.dep-versions }}

- name: Build docs
run: |
Expand Down
82 changes: 14 additions & 68 deletions .github/workflows/nightly-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,6 @@ jobs:
- name: Get tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

# This uses pip to find the right cache dir and then sets up caching for it
- name: Get pip cache dir
id: pip-cache
run: echo "::set-output name=dir::$(pip cache dir)"

- name: Setup caching
uses: actions/[email protected]
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip-tests-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('ci/*') }}
restore-keys: |
pip-tests-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('ci/*') }}
pip-tests-${{ runner.os }}-${{ matrix.python-version }}-
pip-tests-${{ runner.os }}-
pip-tests-
- name: Assemble test requirements
run: |
cat ci/extra_requirements.txt >> ci/test_requirements.txt
Expand All @@ -58,19 +37,13 @@ jobs:
- name: Setup PROJ
uses: ./.github/actions/setup-proj

# This installs the stuff needed to build and install Shapely and CartoPy from source.
- name: Install dependencies
run: |
sudo apt-get install libgeos-dev
python -m pip install --upgrade pip setuptools
python -m pip install --no-binary :all: shapely
python -m pip install -r ci/test_requirements.txt -c ci/Prerelease
- name: Download Cartopy Maps
run: ci/download_cartopy_maps.py

- name: Install
run: python -m pip install -c ci/Prerelease .
- name: Install using PyPI
uses: ./.github/actions/install-pypi
with:
need-cartopy: true
type: test
version-file: Prerelease
python-version: ${{ matrix.python-version }}

- name: Run tests
id: tests
Expand Down Expand Up @@ -107,27 +80,6 @@ jobs:
- name: Get tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

# This uses pip to find the right cache dir and then sets up caching for it
- name: Get pip cache dir
id: pip-cache
run: echo "::set-output name=dir::$(pip cache dir)"

- name: Setup pip cache
uses: actions/[email protected]
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip-docs-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('ci/*') }}
restore-keys: |
pip-docs-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('ci/*') }}
pip-docs-${{ runner.os }}-${{ matrix.python-version }}-
pip-docs-${{ runner.os }}-
pip-docs-
- name: Assemble doc requirements
run: |
cat ci/extra_requirements.txt >> ci/doc_requirements.txt
Expand All @@ -137,19 +89,13 @@ jobs:
- name: Setup PROJ
uses: ./.github/actions/setup-proj

# This installs the stuff needed to build and install Shapely and CartoPy from source.
- name: Install dependencies (PyPI)
run: |
sudo apt-get install libgeos-dev
python -m pip install --upgrade pip setuptools
python -m pip install --no-binary :all: shapely
python -m pip install -r ci/doc_requirements.txt -c ci/Prerelease
- name: Download Cartopy Maps
run: ci/download_cartopy_maps.py

- name: Install self
run: python -m pip install -c ci/Prerelease .
- name: Install using PyPI
uses: ./.github/actions/install-pypi
with:
need-cartopy: true
type: doc
version-file: Prerelease
python-version: ${{ matrix.python-version }}

- name: Build docs
id: build
Expand Down
44 changes: 7 additions & 37 deletions .github/workflows/tests-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,6 @@ jobs:
- name: Get tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

# This uses pip to find the right cache dir and then sets up caching for it
- name: Get pip cache dir
id: pip-cache
run: echo "::set-output name=dir::$(pip cache dir)"

- name: Setup caching
uses: actions/[email protected]
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip-tests-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('ci/*') }}
restore-keys: |
pip-tests-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('ci/*') }}
pip-tests-${{ runner.os }}-${{ matrix.python-version }}-
pip-tests-${{ runner.os }}-
pip-tests-
- name: Add extras to requirements
if: ${{ matrix.no-extras != 'No Extras' }}
run: cat ci/extra_requirements.txt >> ci/test_requirements.txt
Expand All @@ -85,22 +64,13 @@ jobs:
- name: Setup PROJ
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: ${{ matrix.no-extras != 'No Extras' }}
run: |
sudo apt-get install libgeos-dev
python -m pip install --no-binary :all: shapely
- name: Install test dependencies
run: python -m pip install -r ci/test_requirements.txt -c ci/${{ matrix.dep-versions }}

- name: Download Cartopy Maps
if: ${{ matrix.no-extras != 'No Extras' }}
run: ci/download_cartopy_maps.py

- name: Install
run: python -m pip install -c ci/${{ matrix.dep-versions }} .
- name: Install from PyPI
uses: ./.github/actions/install-pypi
with:
need-cartopy: ${{ matrix.no-extras != 'No Extras' }}
type: 'test'
version-file: ${{ matrix.dep-versions }}
python-version: ${{ matrix.python-version }}

- name: Run tests
uses: ./.github/actions/run-tests
Expand Down

0 comments on commit b1b1d41

Please sign in to comment.