Skip to content

[MNT] Add dependency caching in CI #382

[MNT] Add dependency caching in CI

[MNT] Add dependency caching in CI #382

Workflow file for this run

name: Test and build mendeleev package
env:
POETRY_VERSION: 1.8.2
on:
push:
branches: [master]
tags: [v*]
pull_request:
branches: [master]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true
- name: Cache dependencies
id: cache-deps
uses: actions/cache@v4
with:
path: ./.venv
key: pydeps-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: poetry install --with vis --no-interaction -v
- name: Lint and format with ruff
uses: pre-commit/[email protected]
- name: Test with pytest
run: |
source $VENV
pytest
deploy:
needs: test
runs-on: ubuntu-latest
name: Build and publish the package to PYPI
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install pypa/build
run: python -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/ .
- name: Publish distribution to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true