I have read and tested different things but didn't found a solution. Maybe I have to live with the boilerplate, but I am not yet done trying it.
I have the follow github actions workflow:
---
name: Code Quality Checks
on:
push:
branches: [main, development]
pull_request:
branches: [main, development]
jobs:
test:
runs-on: ubuntu-latest
needs: setup
steps:
- name: get repo
uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install poetry
uses: snok/install-poetry@v1.0.0
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- name: Unit & Coverage test with pytest
run: poetry run pytest
check:
runs-on: ubuntu-latest
needs: setup
steps:
- name: get repo
uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install poetry
uses: snok/install-poetry@v1.0.0
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- name: Check style with flake8
run: poetry run flake8 boxsup_pytorch/ tests/
As you might see there is a lot of boilerplate in both jobs. I tested 'composition' which has issues with the cached variables. I also tinkert around with upload and download artifacts, but since the setup-python action uses python binary outside my cwd I was thinking uploading the complete runner is not a good idea.
Any working solutions for my scenario?
My previous Ideas was mostly based on In a github actions workflow, is there a way to have multiple jobs reuse the same setup?