-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
86 lines (77 loc) · 2.6 KB
/
action.yaml
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
75
76
77
78
79
80
81
82
83
84
85
86
name: 'Setup python with poetry environment'
description: 'Set up an Actions job for Python and Poetry'
inputs:
python_version:
description: 'The Python version to install. Defaults to the version stated in the pyproject.toml file.'
required: false
default: ''
project_root:
description: 'The location of the python project root. Defaults to the root of the project'
required: false
default: '.'
install_cdk:
description: 'Install the AWS CDK. Defaults to false'
required: false
default: ''
cache_venv:
description: 'Cache the .venv directory for use with later workflow runs. Defaults to true'
required: false
default: 'true'
codeartifact_login:
description: 'Log in to CodeArtifact. Defaults to false'
required: false
default: ''
codeartifact_source:
description: 'CodeArtifact source. Defaults to code-artifact'
required: false
default: 'code-artifact'
runs:
using: 'composite'
steps:
- name: Setup Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python_version }}
python-version-file: ${{ inputs.project_root }}/pyproject.toml
- name: Install Poetry
id: setup-poetry
uses: snok/[email protected]
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
virtualenvs-path: ${{ inputs.project_root }}/.venv
- name: CodeArtifact login
id: codeartifact_login
if: ${{ inputs.codeartifact_login }}
shell: bash
run: |
cd ${{ inputs.project_root }}
poetry self add poetry-codeartifact-login
poetry aws-login ${{ inputs.codeartifact_source }}
- name: Setup Node
id: setup-node
if: ${{ inputs.install_cdk }}
uses: actions/setup-node@v4
- name: Install CDK
id: install_cdk
if: ${{ inputs.install_cdk }}
shell: bash
run: npm install -g aws-cdk
- name: Load cached venv
id: cached-venv
if: ${{ inputs.cache_venv }}
uses: runs-on/cache@v4
with:
path: ${{ inputs.project_root }}/.venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-venv.outputs.cache-hit != 'true'
shell: bash
working-directory: ${{ inputs.project_root }}
run: poetry install --no-interaction --verbose --no-ansi
- name: Show installed depencies
shell: bash
working-directory: ${{ inputs.project_root }}
run: poetry show --tree --no-ansi