Skip to content

ci(tests): Use poetry cache action - #316

Merged
tony merged 4 commits into
masterfrom
cache-and-publish
Apr 2, 2022
Merged

ci(tests): Use poetry cache action#316
tony merged 4 commits into
masterfrom
cache-and-publish

Conversation

@tony

@tonytony commented Apr 2, 2022

Copy link
Copy Markdown
Member

Potential bug (as of actions/setup-python v3.1):

Filed a report here: actions/setup-python#374, reproduction: https://github.com/tony/setup-python-poetry-version-example

The workaround for now is to use poetry env use <python-version>beforepoetry install

Original message

As of yesterday, @actions/setup-python@v3 supports this via v3.1.0: Release, Tag, actions/setup-python#281

steps:
- uses: actions/checkout@v3
- name: Install poetryrun: pipx install poetry
- uses: actions/setup-python@v3with:
python-version: '3.9'cache: 'poetry'
- run: poetry install
- run: poetry run pytest

See also: python-poetry/poetry#4205

@tony
tonyforce-pushed the cache-and-publish branch from 9acef0b to 2c045c2CompareApril 2, 2022 10:02
@codecov

codecovBot commented Apr 2, 2022

Copy link
Copy Markdown

Codecov Report

Merging #316 (3a68636) into master (623a393) will not change coverage.
The diff coverage is n/a.

❗ Current head 3a68636 differs from pull request most recent head 601ffef. Consider uploading reports for the commit 601ffef to get more accurate results

@@ Coverage Diff @@## master #316 +/- ##
=======================================
Coverage 86.80% 86.80% =======================================
Files 15 15 Lines 879 879 =======================================
Hits 763 763 Misses 116 116 

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 623a393...601ffef. Read the comment docs.

@tony
tonyforce-pushed the cache-and-publish branch from 8753d81 to 663c19dCompareApril 2, 2022 10:04
@tony
tonyforce-pushed the cache-and-publish branch 2 times, most recently from 3a68636 to 03c77b1CompareApril 2, 2022 10:14
@tony
tony merged commit 87163d0 into masterApr 2, 2022
@tony
tony deleted the cache-and-publish branch April 2, 2022 10:16
@tony
tony restored the cache-and-publish branch April 2, 2022 11:12
@tony
tony deleted the cache-and-publish branch April 2, 2022 11:12
{{ env.poetry_virtualenvs_path }}
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
python-version: ${{ matrix.python-version }}
cache: 'poetry'

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update (as of actions/setup-python):

When I do this, I've found I had to run poetry env ${{ matrix.python-version }} before poetry install or else it'd use the default python version:

name: testson: [push]jobs:
build:
runs-on: ubuntu-lateststrategy:
matrix:
python-version: [ '3.10' ]steps:
- uses: actions/checkout@v3
- name: Install poetryrun: | curl -O -sSL https://install.python-poetry.org/install-poetry.py python install-poetry.py -y --version 1.1.12 echo "PATH=${HOME}/.poetry/bin:${PATH}" >> $GITHUB_ENV rm install-poetry.py - name: Set up Python ${{ matrix.python-version }}uses: actions/setup-python@v3with:
python-version: ${{ matrix.python-version }}cache: 'poetry'
- name: Install dependenciesrun: | # This is required to do as of @actions/checkout@v3 to prevent default action python (3.8) from being used poetry env use ${{ matrix.python-version }} poetry install - name: Lint with flake8run: poetry run flake8
- name: Print python versionsrun: | python -V poetry run python -V - name: Test with pytestrun: poetry run py.test

@tonytony added this to the v0.12 milestone May 30, 2022
@tonytony mentioned this pull request Aug 16, 2022
tony added a commit that referenced this pull request Aug 16, 2022
This was originally added in #316 but retracted due to actions/setup-python#374. In recent versions this python version issue has apparently been fixed.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant

@tony