Skip to content

Commit

Permalink
feat: read dependencies from pyproject.toml in CI workflow
Browse files Browse the repository at this point in the history
- Add pytest-cov and make to dev dependencies
- Modify workflow to dynamically read dependencies from pyproject.toml
- Remove hardcoded dependencies from workflow file
  • Loading branch information
michaelaye committed Nov 27, 2024
1 parent 78bf3ca commit c31829c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,22 @@ jobs:
- name: Install dependencies
shell: bash -l {0}
run: |
# Install dependencies from pyproject.toml
mamba install -y -c conda-forge \
tomlkit \
requests \
tqdm \
pandas \
pytest \
make \
pip
# Install tomlkit first to read pyproject.toml
mamba install -y -c conda-forge tomlkit pip make
# Use Python to get dependencies from pyproject.toml
DEPS=$(python -c "
import tomlkit
with open('pyproject.toml', 'r') as f:
pyproject = tomlkit.load(f)
deps = pyproject['project']['dependencies']
dev_deps = pyproject['project']['optional-dependencies']['dev']
all_deps = deps + dev_deps
print(' '.join(all_deps))
")
# Install all dependencies
mamba install -y -c conda-forge $DEPS
- name: Install package
shell: bash -l {0}
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ repository = "https://github.com/planetarypy/planetarypy"
[project.optional-dependencies]
dev = [
"pytest",
"pytest-cov",
"build",
"twine",
"pip-tools"
"pip-tools",
"make"
]

[project.scripts]
Expand Down

0 comments on commit c31829c

Please sign in to comment.