From 7d114d6ed82418ea3b9fad2909cd7d40bee79307 Mon Sep 17 00:00:00 2001 From: Arun Babu Neelicattu Date: Sun, 3 Mar 2024 20:00:04 +0100 Subject: [PATCH] ci/gha: simplify poetry setup and caching (cherry picked from commit 2f6a5534794fd6dbf818a3a0f056e3b45886bdb0) --- .github/workflows/docs.yml | 5 +++-- .github/workflows/main.yml | 39 +++++++---------------------------- .github/workflows/release.yml | 15 ++++++-------- 3 files changed, 16 insertions(+), 43 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 4f68e8d9851..bdf659aea3e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -42,7 +42,8 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.12" + cache: poetry - name: Setup Node uses: actions/setup-node@v4 @@ -54,7 +55,7 @@ jobs: - name: Fetch Documentation run: | - python -m pip install poetry + pipx install poetry poetry install --no-root --only main poetry run python bin/website build --local ./poetry diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f3ff4069494..796f9ebdfcc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,26 +43,14 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Bootstrap poetry + run: pipx install poetry + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - - name: Get full Python version - id: full-python-version - run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT - - - name: Bootstrap poetry - run: | - curl -sSL https://install.python-poetry.org | python - -y - - - name: Update PATH - if: ${{ matrix.os != 'Windows' }} - run: echo "$HOME/.local/bin" >> $GITHUB_PATH - - - name: Update Path for Windows - if: ${{ matrix.os == 'Windows' }} - run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH + cache: poetry - name: Enable long paths for git on Windows if: ${{ matrix.os == 'Windows' }} @@ -71,23 +59,10 @@ jobs: run: git config --system core.longpaths true - name: Configure poetry - run: poetry config virtualenvs.in-project true - - - name: Set up cache - uses: actions/cache@v4 - id: cache - with: - path: .venv - key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }} - - - name: Ensure cache is healthy - if: steps.cache.outputs.cache-hit == 'true' run: | - # `timeout` is not available on macOS, so we define a custom function. - [ "$(command -v timeout)" ] || function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; } - - # Using `timeout` is a safeguard against the Poetry command hanging for some reason. - timeout 10s poetry run pip --version || rm -rf .venv + poetry config virtualenvs.in-project true + poetry config virtualenvs.options.no-pip true + poetry config virtualenvs.options.no-setuptools true - name: Check lock file run: poetry check --lock diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 107a3910521..359cfb9f28d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,17 +13,14 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Set up Python 3.10 - uses: actions/setup-python@v5 - with: - python-version: "3.10" - - name: Install Poetry - run: | - curl -sSL https://install.python-poetry.org | python - -y + run: pipx install poetry - - name: Update PATH - run: echo "$HOME/.local/bin" >> $GITHUB_PATH + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: poetry - name: Build project for distribution run: poetry build