Skip to content

Commit

Permalink
add composite action to set up pyenv
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitj committed Sep 25, 2023
1 parent 612510a commit 624c2b7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 48 deletions.
21 changes: 21 additions & 0 deletions .github/actions/pyenv/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Setup python environment
description: Install python environment from cache
inputs:
python-version:
required: true
description: Python version(s) to install
reference:
required: true
description: >
Reference ID to use for defining poetry cache (e.g. PR id or commit SHA)
runs:
using: composite
steps:
# Install & configure poetry
- name: Cache Poetry installation
id: cached-poetry
uses: actions/cache@v3
with:
path: ~/.local
key: ${{ runner.os }}-poetry-${{ inputs.reference }}
60 changes: 12 additions & 48 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,22 @@
name: Lint and test workflow
on:
push:
branches: ['*', '!push-action/*']
branches: ["*", "!push-action/*"]
pull_request:
branches: ['*', '!push-action/*']
branches: ["*", "!push-action/*"]
jobs:
quality:
name: Lint code
if: github.event.pull_request.merged == false
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@master
- name: Setup Python 3.10
uses: actions/setup-python@v4
uses: actions/checkout@v3
- name: Setup Python environment
uses: khanlab/actions/.github/actions/action-setup_task-pyenv@enh/install-project
with:
python-version: '3.10'
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-3.10
restore-keys: ${{ runner.os }}-pip-3.10
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}-3.10
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --with dev
python-version: "3.10"
reference: ${{ github.event.pull_request.id || github.event.after }}
- name: yamlfix
run: poetry run poe yamlfix-check
- name: isort
Expand All @@ -51,33 +33,15 @@ jobs:
needs: [quality]
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10']
python-version: ["3.8", "3.9", "3.10"]
steps:
- name: Clone repo
uses: actions/checkout@master
- name: Select Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/checkout@v3
- name: Setup Python environment
uses: khanlab/actions/.github/actions/action-setup_task-pyenv@enh/install-project
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}
restore-keys: ${{ runner.os }}-pip-${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}-${{ matrix.python-version
}}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
reference: ${{ github.event.pull_request.id || github.event.after }}
run: poetry install --no-interaction --no-root --with dev
- name: Test minimum inputs
run: poetry run poe test_base
Expand Down

0 comments on commit 624c2b7

Please sign in to comment.