From 3ed0e7788441019aa77d43fcc505092c7b5f5e27 Mon Sep 17 00:00:00 2001 From: Mathijs de Bruin Date: Wed, 28 Aug 2024 12:16:52 +0100 Subject: [PATCH] Caching of Python deps in CI. Special care taken of https://github.com/python-poetry/poetry/issues/2117 --- .github/workflows/e2e-tests.yaml | 21 +++++++++++++++------ .github/workflows/mypy.yaml | 12 ++++++++---- .github/workflows/pytest.yaml | 10 +++++++--- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/.github/workflows/e2e-tests.yaml b/.github/workflows/e2e-tests.yaml index f6d26de166..e7eb2315dc 100644 --- a/.github/workflows/e2e-tests.yaml +++ b/.github/workflows/e2e-tests.yaml @@ -18,21 +18,30 @@ jobs: with: node-version: '16.15.0' cache: 'pnpm' + - name: cache poetry install + uses: actions/cache@v2 + with: + path: ~/.local + key: poetry-1.8.3-0 + - name: Install Poetry + run: pipx install poetry==1.8.3 - name: Set up Python + id: python uses: actions/setup-python@v4 with: - python-version: '3.9' - cache: 'pip' - - name: Install Poetry - run: pip install poetry + python-version: 3.9 + cache: poetry + cache-dependency-path: backend/poetry.lock + - name: Set Poetry environment + run: poetry -C ./backend env use '${{ steps.python.outputs.python-path }}' + - name: Install Python dependencies + run: poetry -C ./backend install --with tests - name: Install JS dependencies run: pnpm install --no-frozen-lockfile - name: Build UI run: pnpm run buildUi - name: Lint UI run: pnpm run lintUi - - name: Install Python dependencies - run: poetry install -C ./backend --with tests - name: Run tests env: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} diff --git a/.github/workflows/mypy.yaml b/.github/workflows/mypy.yaml index a0cd334b27..5df7dc2566 100644 --- a/.github/workflows/mypy.yaml +++ b/.github/workflows/mypy.yaml @@ -10,13 +10,17 @@ jobs: working-directory: ./backend steps: - uses: actions/checkout@v3 + - name: Install Poetry + run: pipx install poetry - name: Set up Python + id: python uses: actions/setup-python@v4 with: - python-version: '3.9' - cache: 'pip' - - name: Install Poetry - run: pip install poetry + python-version: 3.9 + cache: poetry + cache-dependency-path: backend/poetry.lock + - name: Set Poetry environment + run: poetry env use '${{ steps.python.outputs.python-path }}' - name: Install dependencies run: poetry install --with tests --with mypy --with custom-data - name: Run Mypy diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index d36ac99075..26404e5971 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -13,13 +13,17 @@ jobs: working-directory: ./backend steps: - uses: actions/checkout@v3 + - name: Install Poetry + run: pipx install poetry - name: Set up Python + id: python uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - cache: 'pip' - - name: Install Poetry - run: pip install poetry + cache: poetry + cache-dependency-path: backend/poetry.lock + - name: Set Poetry environment + run: poetry env use '${{ steps.python.outputs.python-path }}' - name: Install dependencies run: poetry install --with tests --with mypy --with custom-data - name: Run Pytest