mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add a Github Action to get the python version from a binary
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
parent
863368b5ba
commit
7a8254114a
9 changed files with 76 additions and 50 deletions
27
.github/actions/build-onedir-deps/action.yml
vendored
27
.github/actions/build-onedir-deps/action.yml
vendored
|
@ -50,37 +50,28 @@ runs:
|
|||
python3 -c "import os; os.makedirs('artifacts', exist_ok=True)"
|
||||
python3 -m relenv create --arch=${{ inputs.arch }} --python=${{ inputs.python-version }} artifacts/${{ inputs.package-name }}
|
||||
|
||||
- name: Get Onedir Python Version
|
||||
shell: bash
|
||||
- name: Get Ondir Python Version
|
||||
id: get-python-version
|
||||
if: steps.onedir-pkg-cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
if [ "${{ inputs.platform }}" != "windows" ]; then
|
||||
PY_VERSION=$(artifacts/${{ inputs.package-name }}/bin/python3 -c "import sys; sys.stdout.write('{}.{}'.format(*sys.version_info))")
|
||||
else
|
||||
PY_VERSION=$(artifacts/${{ inputs.package-name }}/Scripts/python -c "import sys; sys.stdout.write('{}.{}'.format(*sys.version_info))")
|
||||
fi
|
||||
echo "PY_VERSION=$PY_VERSION" >> "$GITHUB_ENV"
|
||||
uses: ./.github/actions/get-python-version
|
||||
with:
|
||||
python-binary: artifacts/${{ inputs.package-name }}/${{ inputs.platform == 'windows' && 'Scripts/python' || 'bin/python3' }}
|
||||
|
||||
- name: Upgrade Setuptools & Pip
|
||||
shell: bash
|
||||
if: steps.onedir-pkg-cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
if [ "${{ inputs.platform }}" != "windows" ]; then
|
||||
artifacts/${{ inputs.package-name }}/bin/python3 -m pip install -U "pip>=22.3.1,<23.0"
|
||||
artifacts/${{ inputs.package-name }}/bin/python3 -m pip install -U "setuptools>=65.6.3,<66"
|
||||
else
|
||||
artifacts/${{ inputs.package-name }}/Scripts/python -m pip install -U "pip>=22.3.1,<23.0"
|
||||
artifacts/${{ inputs.package-name }}/Scripts/python -m pip install -U "setuptools>=65.6.3,<66"
|
||||
fi
|
||||
${{ steps.get-python-version.outputs.binary }} -m pip install -U "pip>=22.3.1,<23.0"
|
||||
${{ steps.get-python-version.outputs.binary }} -m pip install -U "setuptools>=65.6.3,<66"
|
||||
|
||||
- name: Install Salt Onedir Package Dependencies
|
||||
shell: bash
|
||||
if: steps.onedir-pkg-cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
if [ "${{ inputs.platform }}" != "windows" ]; then
|
||||
artifacts/${{ inputs.package-name }}/bin/python3 -m pip install -r requirements/static/pkg/py${PY_VERSION}/${{ inputs.platform }}.txt --no-binary=':all:'
|
||||
${{ steps.get-python-version.outputs.binary }} -m pip install -r requirements/static/pkg/py${{ steps.get-python-version.outputs.version }}/${{ inputs.platform }}.txt --no-binary=':all:'
|
||||
else
|
||||
artifacts/${{ inputs.package-name }}/Scripts/python -m pip install -r requirements/static/pkg/py${PY_VERSION}/${{ inputs.platform }}.txt
|
||||
${{ steps.get-python-version.outputs.binary }} -m pip install -r requirements/static/pkg/py${{ steps.get-python-version.outputs.version }}/${{ inputs.platform }}.txt
|
||||
fi
|
||||
|
||||
- name: Cleanup Salt Onedir Directory
|
||||
|
|
19
.github/actions/cached-virtualenv/action.yml
vendored
19
.github/actions/cached-virtualenv/action.yml
vendored
|
@ -31,31 +31,30 @@ runs:
|
|||
steps:
|
||||
|
||||
- name: Get Python Version
|
||||
shell: bash
|
||||
id: get-python-version
|
||||
run: |
|
||||
PY_VERSION=$(python3 -c "import sys; sys.stdout.write('{}.{}'.format(*sys.version_info))")
|
||||
echo "python-version=$PY_VERSION" >> "${GITHUB_OUTPUT}"
|
||||
uses: ./.github/actions/get-python-version
|
||||
with:
|
||||
python-binary: python3
|
||||
|
||||
- name: Setup Cache Key
|
||||
shell: bash
|
||||
id: setup-cache-key
|
||||
run: |
|
||||
echo "cache-key=${{ inputs.cache-seed }}|${{ runner.os }}|${{ runner.arch }}|cached-venv|${{ steps.get-python-version.outputs.python-version }}|${{ inputs.name }}" >> "${GITHUB_OUTPUT}"
|
||||
echo "cache-key=${{ inputs.cache-seed }}|${{ runner.os }}|${{ runner.arch }}|cached-venv|${{ steps.get-python-version.outputs.version }}|${{ inputs.name }}" >> "${GITHUB_OUTPUT}"
|
||||
|
||||
- name: Cache VirtualEnv
|
||||
id: cache-virtualenv
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
key: ${{ steps.setup-cache-key.outputs.cache-key }}
|
||||
path: ${{ github.workspace }}/.venvs/py${{ steps.get-python-version.outputs.python-version }}/${{ inputs.name }}
|
||||
path: ${{ github.workspace }}/.venvs/py${{ steps.get-python-version.outputs.version }}/${{ inputs.name }}
|
||||
|
||||
- name: Create Virtualenv
|
||||
shell: bash
|
||||
if: ${{ steps.cache-virtualenv.outputs.cache-hit != 'true' }}
|
||||
run: |
|
||||
mkdir -p ${{ github.workspace }}/.venvs/py${{ steps.get-python-version.outputs.python-version }}
|
||||
python3 -m venv --upgrade ${{ github.workspace }}/.venvs/py${{ steps.get-python-version.outputs.python-version }}/${{ inputs.name }}
|
||||
mkdir -p ${{ github.workspace }}/.venvs/py${{ steps.get-python-version.outputs.version }}
|
||||
python3 -m venv --upgrade ${{ github.workspace }}/.venvs/py${{ steps.get-python-version.outputs.version }}/${{ inputs.name }}
|
||||
|
||||
- name: Define python executable output
|
||||
shell: bash
|
||||
|
@ -63,9 +62,9 @@ runs:
|
|||
run: |
|
||||
shopt -s nocasematch
|
||||
if [[ "${{ runner.os }}" =~ "win" ]]; then
|
||||
BIN_DIR="${{ github.workspace }}/.venvs/py${{ steps.get-python-version.outputs.python-version }}/${{ inputs.name }}/Scripts"
|
||||
BIN_DIR="${{ github.workspace }}/.venvs/py${{ steps.get-python-version.outputs.version }}/${{ inputs.name }}/Scripts"
|
||||
else
|
||||
BIN_DIR="${{ github.workspace }}/.venvs/py${{ steps.get-python-version.outputs.python-version }}/${{ inputs.name }}/bin"
|
||||
BIN_DIR="${{ github.workspace }}/.venvs/py${{ steps.get-python-version.outputs.version }}/${{ inputs.name }}/bin"
|
||||
fi
|
||||
shopt -u nocasematch
|
||||
echo "python-executable=$BIN_DIR/python" >> "${GITHUB_OUTPUT}"
|
||||
|
|
31
.github/actions/get-python-version/action.yml
vendored
Normal file
31
.github/actions/get-python-version/action.yml
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
name: get-python-version
|
||||
description: Setup Relenv
|
||||
inputs:
|
||||
python-binary:
|
||||
required: true
|
||||
type: string
|
||||
description: The python binary to get the version from
|
||||
outputs:
|
||||
binary:
|
||||
value: ${{ steps.get-python-version.outputs.binary }}
|
||||
version:
|
||||
value: ${{ steps.get-python-version.outputs.version }}
|
||||
full-version:
|
||||
value: ${{ steps.get-python-version.outputs.full-version }}
|
||||
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
|
||||
steps:
|
||||
|
||||
- name: Get Python Version
|
||||
id: get-python-version
|
||||
shell: bash
|
||||
run: |
|
||||
echo "binary=${{ inputs.python-binary }}" >> "$GITHUB_OUTPUT"
|
||||
PY_VERSION=$(${{ inputs.python-binary }} -c "import sys; sys.stdout.write('{}.{}'.format(*sys.version_info))")
|
||||
echo "version=$PY_VERSION" >> "$GITHUB_OUTPUT"
|
||||
PY_FULL_VERSION=$(${{ inputs.python-binary }} -c "import sys; sys.stdout.write('{}.{}.{}'.format(*sys.version_info))")
|
||||
echo "full-version=$PY_FULL_VERSION" >> "$GITHUB_OUTPUT"
|
|
@ -13,8 +13,13 @@ runs:
|
|||
|
||||
steps:
|
||||
|
||||
- name: Get Python Version
|
||||
id: get-python-version
|
||||
uses: ./.github/actions/get-python-version
|
||||
with:
|
||||
python-binary: python3
|
||||
|
||||
- name: Install 'python-tools-scripts'
|
||||
shell: bash
|
||||
run: |
|
||||
PY_VERSION=$(python3 -c "import sys; sys.stdout.write('{}.{}'.format(*sys.version_info))")
|
||||
python3 -m pip install -r requirements/static/ci/py${PY_VERSION}/tools.txt
|
||||
python3 -m pip install -r requirements/static/ci/py${{ steps.get-python-version.outputs.version }}/tools.txt
|
||||
|
|
8
.github/workflows/build-docs.yml
vendored
8
.github/workflows/build-docs.yml
vendored
|
@ -54,9 +54,9 @@ jobs:
|
|||
|
||||
- name: Get Python Version
|
||||
id: get-python-version
|
||||
run: |
|
||||
PY_VERSION=$(python3 -c "import sys; sys.stdout.write('{}.{}'.format(*sys.version_info))")
|
||||
echo "python-version=$PY_VERSION" >> "$GITHUB_OUTPUT"
|
||||
uses: ./.github/actions/get-python-version
|
||||
with:
|
||||
python-binary: python3
|
||||
|
||||
- name: Setup Python Tools Scripts
|
||||
uses: ./.github/actions/setup-python-tools-scripts
|
||||
|
@ -66,7 +66,7 @@ jobs:
|
|||
uses: actions/cache@v3
|
||||
with:
|
||||
path: .tools-venvs/
|
||||
key: ${{ inputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.python-version }}|${{ hashFiles('requirements/**/*.txt') }}
|
||||
key: ${{ inputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt') }}
|
||||
|
||||
- name: Prepare Docs Build
|
||||
run: |
|
||||
|
|
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
|
@ -220,16 +220,16 @@ jobs:
|
|||
|
||||
- name: Get Python Version
|
||||
id: get-python-version
|
||||
run: |
|
||||
PY_VERSION=$(python3 -c "import sys; sys.stdout.write('{}.{}'.format(*sys.version_info))")
|
||||
echo "python-version=$PY_VERSION" >> "$GITHUB_OUTPUT"
|
||||
uses: ./.github/actions/get-python-version
|
||||
with:
|
||||
python-binary: python3
|
||||
|
||||
- name: Cache Python Tools Virtualenvs
|
||||
id: tools-venvs-dependencies-cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: .tools-venvs/
|
||||
key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.python-version }}|${{ hashFiles('requirements/**/*.txt') }}
|
||||
key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt') }}
|
||||
|
||||
- name: Setup Python Tools Scripts
|
||||
uses: ./.github/actions/setup-python-tools-scripts
|
||||
|
|
8
.github/workflows/nightly.yml
vendored
8
.github/workflows/nightly.yml
vendored
|
@ -218,16 +218,16 @@ jobs:
|
|||
|
||||
- name: Get Python Version
|
||||
id: get-python-version
|
||||
run: |
|
||||
PY_VERSION=$(python3 -c "import sys; sys.stdout.write('{}.{}'.format(*sys.version_info))")
|
||||
echo "python-version=$PY_VERSION" >> "$GITHUB_OUTPUT"
|
||||
uses: ./.github/actions/get-python-version
|
||||
with:
|
||||
python-binary: python3
|
||||
|
||||
- name: Cache Python Tools Virtualenvs
|
||||
id: tools-venvs-dependencies-cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: .tools-venvs/
|
||||
key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.python-version }}|${{ hashFiles('requirements/**/*.txt') }}
|
||||
key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt') }}
|
||||
|
||||
- name: Setup Python Tools Scripts
|
||||
uses: ./.github/actions/setup-python-tools-scripts
|
||||
|
|
8
.github/workflows/scheduled.yml
vendored
8
.github/workflows/scheduled.yml
vendored
|
@ -218,16 +218,16 @@ jobs:
|
|||
|
||||
- name: Get Python Version
|
||||
id: get-python-version
|
||||
run: |
|
||||
PY_VERSION=$(python3 -c "import sys; sys.stdout.write('{}.{}'.format(*sys.version_info))")
|
||||
echo "python-version=$PY_VERSION" >> "$GITHUB_OUTPUT"
|
||||
uses: ./.github/actions/get-python-version
|
||||
with:
|
||||
python-binary: python3
|
||||
|
||||
- name: Cache Python Tools Virtualenvs
|
||||
id: tools-venvs-dependencies-cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: .tools-venvs/
|
||||
key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.python-version }}|${{ hashFiles('requirements/**/*.txt') }}
|
||||
key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt') }}
|
||||
|
||||
- name: Setup Python Tools Scripts
|
||||
uses: ./.github/actions/setup-python-tools-scripts
|
||||
|
|
8
.github/workflows/templates/ci.yml.jinja
vendored
8
.github/workflows/templates/ci.yml.jinja
vendored
|
@ -58,16 +58,16 @@ on:
|
|||
|
||||
- name: Get Python Version
|
||||
id: get-python-version
|
||||
run: |
|
||||
PY_VERSION=$(python3 -c "import sys; sys.stdout.write('{}.{}'.format(*sys.version_info))")
|
||||
echo "python-version=$PY_VERSION" >> "$GITHUB_OUTPUT"
|
||||
uses: ./.github/actions/get-python-version
|
||||
with:
|
||||
python-binary: python3
|
||||
|
||||
- name: Cache Python Tools Virtualenvs
|
||||
id: tools-venvs-dependencies-cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: .tools-venvs/
|
||||
key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.python-version }}|${{ hashFiles('requirements/**/*.txt') }}
|
||||
key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt') }}
|
||||
|
||||
- name: Setup Python Tools Scripts
|
||||
uses: ./.github/actions/setup-python-tools-scripts
|
||||
|
|
Loading…
Add table
Reference in a new issue