Skip to content

Commit 43a092a

Browse files
committed
CI: make common parts reusable
1 parent ff1d3e9 commit 43a092a

2 files changed

Lines changed: 69 additions & 70 deletions

File tree

.github/actions/setup/action.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: "setup poetry and python"
2+
description: "Setup python, poetry, and development environment"
3+
inputs:
4+
type:
5+
description: "Type of the venv to create"
6+
required: true
7+
python-version:
8+
description: "Python version to use"
9+
required: true
10+
poetry-version:
11+
description: "Poetry version to use"
12+
required: true
13+
14+
# outputs:
15+
# random-number:
16+
# description: "Random number"
17+
# value: ${{ steps.random-number-generator.outputs.random-number }}
18+
runs:
19+
using: "composite"
20+
steps:
21+
- name: Cache venv
22+
id: cache-venv
23+
uses: actions/cache@v3
24+
with:
25+
path: .venv
26+
key: venv-v1-${{ inputs.type }}-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('poetry.lock') }}
27+
28+
- name: Cache pre-commit
29+
id: cache-pre-commit
30+
uses: actions/cache@v3
31+
with:
32+
path: ~/.cache/pre-commit
33+
key: pre-commit-v1-${{ inputs.type }}-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
34+
35+
- name: Cache setup-poetry
36+
id: cache-setup-poetry
37+
uses: actions/cache@v3
38+
with:
39+
path: |
40+
~/.local/share/pypoetry
41+
~/.local/share/virtualenv
42+
~/.local/bin/poetry
43+
key: setup-poetry-v1-${{ runner.os }}-${{ inputs.poetry-version }}
44+
45+
- name: Setup poetry
46+
uses: Gr1N/setup-poetry@v7
47+
id: setup_poetry
48+
if: steps.cache-setup-poetry.outputs.cache-hit != 'true'
49+
with:
50+
poetry-version: ${{ inputs.poetry-version }}
51+
52+
- name: Bootstrap environment
53+
shell: bash
54+
run: |
55+
make dev EXTRAS=${{ inputs.type }}

.github/workflows/ci.yml

Lines changed: 14 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -18,47 +18,13 @@ jobs:
1818
steps:
1919
- name: Checkout
2020
uses: actions/checkout@v3
21-
22-
- name: Set up Python 3.8
23-
uses: actions/setup-python@v4
24-
id: setup_python
25-
with:
26-
python-version: "3.8"
27-
28-
- name: Cache venv
29-
id: cache-venv
30-
uses: actions/cache@v3
31-
with:
32-
path: .venv
33-
key: venv-v1-test-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
34-
35-
- name: Cache pre-commit
36-
id: cache-pre-commit
37-
uses: actions/cache@v3
38-
with:
39-
path: ~/.cache/pre-commit
40-
key: pre-commit-v1-test-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
41-
42-
- name: Cache setup-poetry
43-
id: cache-setup-poetry
44-
uses: actions/cache@v3
45-
with:
46-
path: |
47-
~/.local/share/pypoetry
48-
~/.local/share/virtualenv
49-
~/.local/bin/poetry
50-
key: setup-poetry-v1-${{ runner.os }}-${{ env.POETRY_VERSION }}
51-
52-
- name: Setup poetry
53-
uses: Gr1N/setup-poetry@v7
54-
id: setup_poetry
55-
if: steps.cache-setup-poetry.outputs.cache-hit != 'true'
21+
- name: Setup
22+
uses: ./.github/actions/setup
5623
with:
24+
type: test
25+
python-version: "3.10"
5726
poetry-version: ${{ env.POETRY_VERSION }}
5827

59-
- name: Bootstrap environment
60-
run: |
61-
make dev EXTRAS=test
6228

6329
- name: Style
6430
run: |
@@ -76,28 +42,16 @@ jobs:
7642
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11-dev"]
7743

7844
steps:
45+
7946
- name: Checkout
8047
uses: actions/checkout@v3
8148

82-
- name: Set up Python ${{ matrix.python-version }}
83-
uses: actions/setup-python@v4
84-
id: setup_python
49+
- name: Setup
50+
uses: ./.github/actions/setup
8551
with:
52+
type: test
8653
python-version: ${{ matrix.python-version }}
87-
88-
- name: Cache venv
89-
id: cache-venv
90-
uses: actions/cache@v3
91-
with:
92-
path: .venv
93-
key: venv-v1-test-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
94-
95-
- name: Setup poetry
96-
uses: Gr1N/setup-poetry@v7
97-
98-
- name: Bootstrap test environment
99-
run: |
100-
make dev EXTRAS=test
54+
poetry-version: ${{ env.POETRY_VERSION }}
10155

10256
- name: Test
10357
run: |
@@ -113,23 +67,13 @@ jobs:
11367
- name: Checkout
11468
uses: actions/checkout@v3
11569

116-
- name: Set up Python
117-
uses: actions/setup-python@v4
118-
id: setup_python
70+
- name: Setup
71+
uses: ./.github/actions/setup
11972
with:
120-
python-version: "3.10"
121-
122-
- name: Cache venv
123-
id: cache-venv
124-
uses: actions/cache@v3
125-
with:
126-
path: .venv
127-
key: venv-v1-doc-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
73+
type: doc
74+
python-version: ${{ matrix.python-version }}
75+
poetry-version: ${{ env.POETRY_VERSION }}
12876

129-
- uses: Gr1N/setup-poetry@v7
130-
- name: Bootstrap test environment
131-
run: |
132-
make dev EXTRAS=doc
13377
- name: Test
13478
run: |
13579
make doc

0 commit comments

Comments
 (0)