-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
74 lines (63 loc) · 2.26 KB
/
Copy pathaction.yml
File metadata and controls
74 lines (63 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Python Environment Setup
description: Installs Python, Poetry, dependencies and pre-commit.
branding:
icon: 'code'
color: 'orange'
inputs:
python-version:
description: "Python version to use"
required: true
use-cache:
description: "Whether to cache the Poetry installation, dependencies and pre-commit"
required: false
default: true
skip-pre-commit:
description: "Whether to skip installing pre-commit"
required: false
default: false
runs:
using: "composite"
steps:
- name: Set up Python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}
- name: Try loading cached Poetry installation
id: cache-poetry
if: ${{ inputs.use-cache == 'true' && runner.os != 'Windows' }}
uses: actions/cache@v3
with:
path: ~/.local
key: poetry-${{ runner.os }}
- name: Install Poetry
id: install-poetry
if: ${{ steps.cache-poetry.outcome == 'skipped' || steps.cache-poetry.outputs.cache-hit != 'true' }}
uses: snok/install-poetry@v1
with:
virtualenvs-in-project: true
- name: Add Poetry to PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH && export PATH="$HOME/.local/bin:$PATH"
shell: bash
- name: Load cached venv
id: cache-deps
if: ${{ inputs.use-cache == 'true' && runner.os != 'Windows' }}
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: ${{ steps.cache-deps.outcome == 'skipped' || steps.cache-deps.outputs.cache-hit != 'true'}}
run: poetry install --no-interaction
shell: bash
- name: Try loading Pre-commit cache
id: cache-pre-commit
if: ${{ inputs.use-cache == 'true' && inputs.skip-pre-commit == 'false' }}
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install pre-commit
if: ${{ inputs.skip-pre-commit == 'false' }}
run: poetry run pre-commit install --install-hooks
shell: bash