Skip to content

Commit

Permalink
ci: rework minimum requirements check
Browse files Browse the repository at this point in the history
  • Loading branch information
gadomski committed Apr 7, 2023
1 parent 6ca1f19 commit db55715
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 68 deletions.
6 changes: 1 addition & 5 deletions .github/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ inputs:
python-version:
description: Python version to set up w/ conda
required: True
pip-cache-hash:
description: The hash used for the pip cache
required: False
default: ${{ hashFiles('setup.cfg', 'requirements-dev.txt') }}
runs:
using: composite
steps:
Expand All @@ -21,7 +17,7 @@ runs:
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ inputs.pip-cache-hash }}
key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg', 'requirements-dev.txt') }}
restore-keys: ${{ runner.os }}-pip-
- name: Set up pre-commit cache
uses: actions/cache@v2
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,12 @@ jobs:
- uses: ./.github/setup
with:
python-version: ${{ matrix.python-version }}
pip-cache-hash: ${{ hashFiles('requirements-min.txt', 'requirements-dev.txt') }}
- name: Install minimum requirements
run: pip install -r requirements-min.txt
- name: Install the package
run: pip install .
- name: Install development dependencies
run: pip install -r requirements-dev.txt
- name: Check minimum requirements
run: scripts/check_minimum_requirements
- name: Install the minimum requirements
run: scripts/install-min-requirements
- name: Install the package
run: pip install .
- name: Test
run: scripts/test
pre-release-versions:
Expand Down
13 changes: 0 additions & 13 deletions requirements-min.txt

This file was deleted.

43 changes: 0 additions & 43 deletions scripts/check_minimum_requirements

This file was deleted.

32 changes: 32 additions & 0 deletions scripts/install-min-requirements
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python3

"""Installs the minimum version of all stactools dependencies, with pip.
Assumptions:
- You've installed the development dependencies: `pip install -r requirements-dev.txt
- All of the dependencies in setup.cfg are specified with `>=`
"""

import subprocess
from configparser import ConfigParser
from pathlib import Path

from packaging.requirements import Requirement

root = Path(__file__).parents[1]
setup_cfg = ConfigParser()
setup_cfg.read(root / "setup.cfg")
requirements = []
for install_requires in filter(
bool,
(i.strip() for i in setup_cfg["options"]["install_requires"].splitlines()),
):
requirement = Requirement(install_requires)
assert len(requirement.specifier) == 1
specifier = list(requirement.specifier)[0]
assert specifier.operator == ">="
install_requires = install_requires.replace(">=", "==")
requirements.append(install_requires)

subprocess.run(["pip", "install", *requirements])

0 comments on commit db55715

Please sign in to comment.