diff --git a/.github/actions/python-environment/action.yml b/.github/actions/python-environment/action.yml index a2d43dc38..b292fa4fe 100644 --- a/.github/actions/python-environment/action.yml +++ b/.github/actions/python-environment/action.yml @@ -11,7 +11,7 @@ inputs: poetry-version: description: 'Poetry version to use' required: true - default: "2.1.2" + default: "2.1.4" working-directory: description: 'Working directory to use' @@ -32,29 +32,61 @@ runs: using: "composite" steps: - - name: Set up pipx if not present + + - name: Set up Python (${{ inputs.python-version}}) + uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.python-version }} + + - name: Ensure wget + shell: bash + run: sudo apt update && sudo apt install -y wget + + - name: Set up Poetry (${{ inputs.poetry-version }}) shell: bash run: | - sudo apt update && sudo apt install -y pipx - python3 -m pipx ensurepath + wget --tries=10 --waitretry 10 --retry-connrefused --https-only -O - https://install.python-poetry.org | POETRY_VERSION="${{ inputs.poetry-version }}" "$PYTHON_BINARY" - echo "$HOME/.local/bin" >> $GITHUB_PATH + env: + PYTHON_BINARY: "python${{ inputs.python-version }}" - - name: Set up Poetry (${{ inputs.poetry-version }}) + - name: Setup cache variables + id: setup-cache-variables shell: bash - run: pipx install poetry==${{ inputs.poetry-version }} + run: | + echo "ImageOS=$ImageOS" + echo "ImageVersion=$ImageVersion" + POETRY_ENV_PATH=$(poetry config virtualenvs.path) + POETRY_SHA=$(sha256sum poetry.lock | awk '{print $1}') #Remove trailing filename + echo "POETRY_ENV_PATH=$POETRY_ENV_PATH" >> $GITHUB_OUTPUT + echo "IMAGE_OS=$ImageOS" >> $GITHUB_OUTPUT + echo "IMAGE_VERSION=$ImageVersion" >> $GITHUB_OUTPUT + echo "POETRY_SHA=$POETRY_SHA" >> $GITHUB_OUTPUT + - - name: Set up Python (${{ inputs.python-version}}) - uses: actions/setup-python@v5 + - name: Cache Poetry environment + if: inputs.use-cache == 'true' + id: cache-poetry-env + uses: actions/cache@v4 with: - python-version: ${{ inputs.python-version }} - cache: ${{ inputs.use-cache == 'true' && 'poetry' || '' }} + path: ${{ steps.setup-cache-variables.outputs.POETRY_ENV_PATH }} + key: poetry-env-${{ steps.setup-cache-variables.outputs.POETRY_SHA }}-${{ steps.setup-cache-variables.outputs.IMAGE_OS }}-${{ steps.setup-cache-variables.outputs.IMAGE_VERSION }}-${{ runner.arch }}-${{ inputs.poetry-version }}-${{ inputs.python-version }}-${{ inputs.extras }} - name: Poetry install with extras + if: inputs.use-cache != 'true' || steps.cache-poetry-env.outputs.cache-hit != 'true' working-directory: ${{ inputs.working-directory }} shell: bash run: | + EXTRAS=$(echo "${{ inputs.extras }}" | tr -d ' ') if [[ -n "$EXTRAS" ]]; then poetry install --extras "$EXTRAS" else poetry install fi + + - name: Validate Poetry environment + working-directory: ${{ inputs.working-directory }} + shell: bash + run: | + poetry run python --version + poetry run python --version | grep "${{ inputs.python-version }}" diff --git a/.github/workflows/slow-checks.yml b/.github/workflows/slow-checks.yml index 9932b1b04..13f2210a2 100644 --- a/.github/workflows/slow-checks.yml +++ b/.github/workflows/slow-checks.yml @@ -59,7 +59,12 @@ jobs: - int-linux-x64-4core-gpu-t4-ubuntu24.04-1 - int-linux-x64-4core-ubuntu24.04-1 - int-linux-x64-2core-ubuntu24.04-1 - name: Install Pipx on ${{ matrix.runner }} + python-version: + - "3.10" + - "3.11" + - "3.12" + - "3.13" + name: Install Pipx on ${{ matrix.runner }} with Python "${{ matrix.python-version }}" runs-on: labels: ${{ matrix.runner }} @@ -67,8 +72,17 @@ jobs: - name: SCM Checkout uses: actions/checkout@v4 - - name: Setup Python & Poetry Environment + - name: Set up Python & Poetry Environment uses: ./.github/actions/python-environment + with: + python-version: "${{ matrix.python-version }}" - name: Poetry version run: poetry --version + + - name: Validate Python version + run: | + poetry run which python + poetry run python --version + poetry env list + poetry run python --version | grep "${{ matrix.python-version }}" \ No newline at end of file diff --git a/doc/changes/changes_1.7.3.md b/doc/changes/changes_1.7.3.md index ffa4527d7..f3146cd03 100644 --- a/doc/changes/changes_1.7.3.md +++ b/doc/changes/changes_1.7.3.md @@ -2,3 +2,8 @@ ## Bugfixes * #523: Fixed `pipx` installation for older versions of `pip` + +## Refactorings + +* #525: Added tests for installing `pipx` on different GitHub runners + diff --git a/doc/changes/unreleased.md b/doc/changes/unreleased.md index c35ec589c..23386ba84 100644 --- a/doc/changes/unreleased.md +++ b/doc/changes/unreleased.md @@ -1,5 +1,5 @@ # Unreleased -## Refactorings +## Bugfixes -* #525: Added tests for installing `pipx` on different GitHub runners +* #527: Use correct Python version in actions/python-environment