Skip to content

Commit 420a3c3

Browse files
authored
Merge pull request #77 from UoMResearchIT/fast-reuse
Possible faster action by smarter cache management
2 parents cf25231 + a8cf1a0 commit 420a3c3

File tree

1 file changed

+44
-12
lines changed

1 file changed

+44
-12
lines changed

reuse/action.yml

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,51 @@ runs:
3333
repository: UoMResearchIT/reuse-tool
3434
ref: ${{ inputs.branch }}
3535

36-
- name: Setup Environment
37-
uses: getsentry/action-setup-venv@v2.2.0
36+
- name: Setup Python
37+
uses: actions/setup-python@v5.0.0
38+
id: setup-python
3839
with:
39-
python-version: 3.12
40-
cache-dependency-path: |
41-
reuse-tool
42-
venv-dir: reuse-tool-venv
43-
install-cmd: |
44-
pip install poetry~=1.3.0
45-
cd reuse-tool
46-
poetry install --no-interaction --only main
47-
poetry build --no-interaction
48-
pip install dist/*.whl
40+
python-version: "3.12"
41+
42+
- run: echo '::remove-matcher owner=python::'
43+
shell: bash
44+
45+
- name: Restore Cache
46+
uses: actions/cache/restore@v4.2.0
47+
id: cache-venv
48+
with:
49+
path: reuse-tool-venv
50+
key: setup-venv-${{ runner.os }}-py-${{ steps.setup-python.outputs.python-version }}-${{ steps.setup-python.outputs.python-path }}-reuse-${{ inputs.branch }}-${{ hashFiles('reuse-tool/pyproject.toml', 'reuse-tool/src/**/*.py') }}
51+
52+
- name: Create reuse-tool Environment
53+
run: python -m venv reuse-tool-venv
54+
if: steps.cache-venv.outputs.cache-hit != 'true'
55+
shell: bash
56+
57+
- name: Enable reuse-tool Environment
58+
run: |
59+
SCRIPT_DIR="${{ runner.os == 'Windows' && 'Scripts' || 'bin' }}"
60+
source reuse-tool-venv/${SCRIPT_DIR}/activate
61+
echo "VIRTUAL_ENV=${VIRTUAL_ENV}" >> $GITHUB_ENV
62+
echo "${VIRTUAL_ENV}/${SCRIPT_DIR}" >> $GITHUB_PATH
63+
shell: bash
64+
65+
- name: Setup reuse-tool Environment
66+
run: |
67+
pip install poetry~=1.3.0
68+
cd reuse-tool
69+
poetry install --no-interaction --only main
70+
poetry build --no-interaction
71+
pip install dist/*.whl
72+
if: steps.cache-venv.outputs.cache-hit != 'true'
73+
shell: bash
74+
75+
- name: Save Cache
76+
uses: actions/cache/save@v4.2.0
77+
with:
78+
path: reuse-tool-venv
79+
key: ${{ steps.cache-venv.outputs.cache-primary-key }}
80+
if: steps.cache-venv.outputs.cache-hit != 'true'
4981

5082
- name: Run reuse
5183
shell: bash

0 commit comments

Comments
 (0)