From 1d45e182dab4789abc5bcb1e09a1dcc72baf365a Mon Sep 17 00:00:00 2001 From: Lukasz Mentel Date: Sun, 20 Oct 2024 20:56:44 +0200 Subject: [PATCH] [MNT] Add dependency caching (#197) * Add dependency caching * correct env ref * trigger build * poetry run * ad python version to cache key * trigger build * add os to cache key * trigger build --- .github/workflows/main.yml | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 238bed55..4f6b0b6c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,5 +1,8 @@ name: Test and build mendeleev package +env: + POETRY_VERSION: 1.8.2 + on: push: branches: [master] @@ -24,24 +27,35 @@ jobs: 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: 1.8.2 + 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-${{ matrix.os }}-python${{ matrix.python-version }}-${{ 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/action@v3.0.1 + - name: Test with pytest - run: | - source $VENV - pytest + run: poetry run pytest deploy: needs: test