1+ on :
2+ push :
3+ branches : [main]
4+ pull_request :
5+
6+ env :
7+ POETRY_VERSION : 1.8.3
8+
9+ jobs :
10+ build :
11+ runs-on : ${{ matrix.os }}
12+ strategy :
13+ fail-fast : false
14+ matrix :
15+ python-version : ["3.10"]
16+ os : [ubuntu-latest, macOS-latest]
17+ env :
18+ POETRY_VIRTUALENVS_IN_PROJECT : true
19+ steps :
20+ - uses : actions/checkout@v3
21+ - uses : actions/setup-python@v4
22+ with :
23+ python-version : ${{ matrix.python-version }}
24+
25+ # Cache the installation of Poetry itself, e.g. the next step. This prevents the workflow
26+ # from installing Poetry every time, which can be slow. Note the use of the Poetry version
27+ # number in the cache key, and the "-0" suffix: this allows you to invalidate the cache
28+ # manually if/when you want to upgrade Poetry, or if something goes wrong.
29+ - name : cache poetry install
30+ uses : actions/cache@v3
31+ with :
32+ path : ~/.local
33+ key : poetry-cache-${{ runner.os }}-${{ matrix.python-version }}-${{ env.POETRY_VERSION }}
34+
35+ # Install Poetry. You could do this manually, or there are several actions that do this.
36+ # `snok/install-poetry` seems to be minimal yet complete, and really just calls out to
37+ # Poetry's default install script, which feels correct. I pin the Poetry version here
38+ # because Poetry does occasionally change APIs between versions and I don't want my
39+ # actions to break if it does.
40+ #
41+ # The key configuration value here is `virtualenvs-in-project: true`: this creates the
42+ # venv as a `.venv` in your testing directory, which allows the next step to easily
43+ # cache it.
44+ - uses : snok/install-poetry@v1
45+ with :
46+ version : 1.8.3
47+ virtualenvs-create : true
48+ virtualenvs-in-project : true
49+
50+ # Cache your dependencies (i.e. all the stuff in your `pyproject.toml`)
51+ - name : cache venv
52+ uses : actions/cache@v3
53+ with :
54+ path : .venv
55+ key : venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
56+ - run : poetry install --no-interaction --no-root
57+ if : steps.cache-deps.outputs.cache-hit != 'true'
58+ - run : poetry install --no-interaction
59+ # - run: poetry run flake8 src/ tests/
60+ - run : poetry run pytest
0 commit comments