From 940d49b8300c64a6cd7ddc0ab69081166546a4c6 Mon Sep 17 00:00:00 2001 From: Ian McGinnis <67600557+ian-noaa@users.noreply.github.com> Date: Thu, 13 Oct 2022 19:54:41 -0600 Subject: [PATCH] Change the poetry env within the poetry install step Each step runs in its own process in GitHub Actions so environment changes are not preserved between steps. I may need to add this to the `poetry run ...` commands as well. I hope it's unnecessary. Apparently Poetry has some "well-known" issues with correctly detecting the desired Python version. See: * Poetry issue: https://github.com/python-poetry/poetry/issues/655 * setup-python workaround: https://github.com/actions/setup-python/issues/374#issuecomment-1088938718 --- .github/workflows/api.yaml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/api.yaml b/.github/workflows/api.yaml index 552cc3f8..ccc1d2c2 100644 --- a/.github/workflows/api.yaml +++ b/.github/workflows/api.yaml @@ -32,12 +32,11 @@ jobs: python-version: '3.9' cache: 'poetry' cache-dependency-path: 'services/api/poetry.lock' - - name: Force Poetry to the correct Python version - working-directory: services/api - run: poetry env use 3.9 - name: Install dependencies working-directory: services/api - run: poetry install + run: | + poetry env use 3.9 + poetry install - name: Lint with Black working-directory: services/api run: poetry run black --check . @@ -55,12 +54,11 @@ jobs: python-version: '3.9' cache: 'poetry' cache-dependency-path: 'services/api/poetry.lock' - - name: Force Poetry to the correct Python version - working-directory: services/api - run: poetry env use 3.9 - name: Install dependencies working-directory: services/api - run: poetry install + run: | + poetry env use 3.9 + poetry install - name: Check Types with mypy working-directory: services/api run: poetry run mypy src/ @@ -75,12 +73,11 @@ jobs: python-version: '3.9' cache: 'poetry' cache-dependency-path: 'services/api/poetry.lock' - - name: Force Poetry to the correct Python version - working-directory: services/api - run: poetry env use 3.9 - name: Install dependencies working-directory: services/api - run: poetry install + run: | + poetry env use 3.9 + poetry install - name: Test working-directory: services/api run: poetry run pytest