Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(tests): Use poetry cache action #316

Merged
merged 4 commits into from
Apr 2, 2022
Merged

ci(tests): Use poetry cache action #316

merged 4 commits into from
Apr 2, 2022

Conversation

tony
Copy link
Member

@tony tony commented Apr 2, 2022

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> before poetry 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 poetry
  run: pipx install poetry
- uses: actions/setup-python@v3
  with:
    python-version: '3.9'
    cache: 'poetry'
- run: poetry install
- run: poetry run pytest

See also: python-poetry/poetry#4205

@codecov
Copy link

codecov bot commented Apr 2, 2022

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 tony force-pushed the cache-and-publish branch 2 times, most recently from 3a68636 to 03c77b1 Compare April 2, 2022 10:14
@tony tony merged commit 87163d0 into master Apr 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
Member Author

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: tests

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [ '3.10' ]
    steps:
      - uses: actions/checkout@v3
      - name: Install poetry
        run: |
          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@v3
        with:
          python-version: ${{ matrix.python-version }}
          cache: 'poetry'

      - name: Install dependencies
        run: |
          # 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 flake8
        run: poetry run flake8

      - name: Print python versions
        run: |
          python -V
          poetry run python -V

      - name: Test with pytest
        run: poetry run py.test

@tony tony added this to the v0.12 milestone May 30, 2022
@tony tony 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 free to 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