Pass along the relenv version that should be used.

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2023-06-13 15:27:59 +01:00 committed by Pedro Algarvio
parent efd6fdd24d
commit 2a65c3e025
16 changed files with 170 additions and 37 deletions

View file

@ -8,6 +8,10 @@ on:
type: string
required: true
description: The Salt version to set prior to building packages.
relenv-version:
type: string
required: true
description: The relenv version to set prior to building packages.
jobs:
build:
@ -80,7 +84,7 @@ jobs:
- name: Build Deb
working-directory: pkgs/checkout/
run: |
tools pkg build deb ${{
tools pkg build deb --relenv-version=${{ inputs.relenv-version }} ${{
matrix.source == 'onedir' &&
format('--onedir=salt-{0}-onedir-linux-{1}.tar.xz', inputs.salt-version, matrix.arch)
||

View file

@ -8,6 +8,10 @@ on:
type: string
required: true
description: The Salt version to set prior to building packages.
relenv-version:
type: string
required: true
description: The relenv version to set prior to building packages.
sign-packages:
type: boolean
default: false
@ -104,7 +108,7 @@ jobs:
APPLE_ACCT: "${{ secrets.MAC_SIGN_APPLE_ACCT }}"
APP_SPEC_PWD: "${{ secrets.MAC_SIGN_APP_SPEC_PWD }}"
run: |
tools pkg build macos ${{
tools pkg build macos --relenv-version=${{ inputs.relenv-version }} ${{
matrix.source == 'onedir' &&
format(
'--onedir salt-{0}-onedir-darwin-{1}.tar.xz --salt-version {0} {2}',

View file

@ -8,6 +8,10 @@ on:
type: string
required: true
description: The Salt version to set prior to building packages.
relenv-version:
type: string
required: true
description: The relenv version to set prior to building packages.
env:
COLUMNS: 190
@ -68,7 +72,7 @@ jobs:
- name: Build RPM
run: |
tools pkg build rpm ${{
tools pkg build rpm --relenv-version=${{ inputs.relenv-version }} ${{
matrix.source == 'onedir' &&
format('--onedir=salt-{0}-onedir-linux-{1}.tar.xz', inputs.salt-version, matrix.arch)
||

View file

@ -8,6 +8,10 @@ on:
type: string
required: true
description: The Salt version to set prior to building packages
relenv-version:
type: string
required: true
description: The relenv version to set prior to building packages.
sign-packages:
type: boolean
default: false
@ -99,7 +103,7 @@ jobs:
- name: Build Windows Packages
run: |
tools pkg build windows ${{
tools pkg build windows --relenv-version=${{ inputs.relenv-version }} ${{
matrix.source == 'onedir' &&
format(
'--onedir salt-{0}-onedir-windows-{1}.zip --salt-version {0} --arch {1} {2}',

View file

@ -501,6 +501,7 @@ jobs:
uses: ./.github/workflows/build-rpm-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
relenv-version: "0.12.3"
build-deb-pkgs:
name: Build DEB Packages
@ -511,6 +512,7 @@ jobs:
uses: ./.github/workflows/build-deb-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
relenv-version: "0.12.3"
build-windows-pkgs:
name: Build Windows Packages
@ -521,6 +523,7 @@ jobs:
uses: ./.github/workflows/build-windows-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
relenv-version: "0.12.3"
build-macos-pkgs:
name: Build macOS Packages
@ -531,6 +534,7 @@ jobs:
uses: ./.github/workflows/build-macos-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
relenv-version: "0.12.3"
amazonlinux-2-pkg-tests:
name: Amazon Linux 2 Package Tests

View file

@ -554,6 +554,7 @@ jobs:
uses: ./.github/workflows/build-rpm-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
relenv-version: "0.12.3"
build-deb-pkgs:
name: Build DEB Packages
@ -564,6 +565,7 @@ jobs:
uses: ./.github/workflows/build-deb-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
relenv-version: "0.12.3"
build-windows-pkgs:
name: Build Windows Packages
@ -574,6 +576,7 @@ jobs:
uses: ./.github/workflows/build-windows-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
relenv-version: "0.12.3"
environment: nightly
sign-packages: false
secrets: inherit
@ -587,6 +590,7 @@ jobs:
uses: ./.github/workflows/build-macos-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
relenv-version: "0.12.3"
environment: nightly
sign-packages: true
secrets: inherit

View file

@ -544,6 +544,7 @@ jobs:
uses: ./.github/workflows/build-rpm-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
relenv-version: "0.12.3"
build-deb-pkgs:
name: Build DEB Packages
@ -554,6 +555,7 @@ jobs:
uses: ./.github/workflows/build-deb-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
relenv-version: "0.12.3"
build-windows-pkgs:
name: Build Windows Packages
@ -564,6 +566,7 @@ jobs:
uses: ./.github/workflows/build-windows-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
relenv-version: "0.12.3"
build-macos-pkgs:
name: Build macOS Packages
@ -574,6 +577,7 @@ jobs:
uses: ./.github/workflows/build-macos-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
relenv-version: "0.12.3"
amazonlinux-2-pkg-tests:
name: Amazon Linux 2 Package Tests

View file

@ -544,6 +544,7 @@ jobs:
uses: ./.github/workflows/build-rpm-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
relenv-version: "0.12.3"
build-deb-pkgs:
name: Build DEB Packages
@ -554,6 +555,7 @@ jobs:
uses: ./.github/workflows/build-deb-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
relenv-version: "0.12.3"
build-windows-pkgs:
name: Build Windows Packages
@ -564,6 +566,7 @@ jobs:
uses: ./.github/workflows/build-windows-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
relenv-version: "0.12.3"
environment: staging
sign-packages: ${{ inputs.sign-windows-packages }}
secrets: inherit
@ -577,6 +580,7 @@ jobs:
uses: ./.github/workflows/build-macos-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
relenv-version: "0.12.3"
environment: staging
sign-packages: true
secrets: inherit

View file

@ -16,6 +16,7 @@
uses: ./.github/workflows/build-<{ pkg_type }>-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
relenv-version: "<{ relenv_version }>"
<%- if pkg_type in ("macos", "windows") and gh_environment %>
environment: <{ gh_environment }>
<%- if pkg_type == "macos" %>

View file

@ -88,6 +88,7 @@ repos:
- pyyaml==6.0
- jinja2==3.1.2
- packaging==23.0
- virustotal3==1.0.8
- repo: https://github.com/saltstack/pip-tools-compile-impersonate
rev: "4.8"

View file

@ -18,6 +18,7 @@ override_dh_auto_build:
mkdir -p build/onedir
python3 -m venv --clear --copies build/onedir/venv
build/onedir/venv/bin/python3 -m pip install relenv==$${SALT_RELENV_VERSION}
export FETCH_RELENV_VERSION=$${SALT_RELENV_VERSION}
export PY=$$(build/onedir/venv/bin/python3 -c 'import sys; sys.stdout.write("{}.{}".format(*sys.version_info)); sys.stdout.flush()') \
&& build/onedir/venv/bin/python3 -m pip install -r requirements/static/ci/py$${PY}/tools.txt
build/onedir/venv/bin/relenv fetch

View file

@ -46,6 +46,7 @@ _usage() {
echo " -h, --help this message"
echo " -b, --build build python instead of fetching"
echo " -v, --version version of python to install, must be available with relenv"
echo " -r, --relenv-version version of python to install, must be available with relenv"
echo ""
echo " To build python 3.10.11:"
echo " example: $0 --version 3.10.11"
@ -85,7 +86,12 @@ while true; do
;;
-v | --version )
shift
PY_VERSION="$*"
PY_VERSION="$1"
shift
;;
-r | --relenv-version )
shift
RELENV_VERSION="$1"
shift
;;
-b | --build )
@ -99,8 +105,9 @@ while true; do
exit 1
;;
* )
PY_VERSION="$*"
shift
echo "Invalid Arguments: $*"
_usage
exit 1
;;
esac
done
@ -183,8 +190,13 @@ fi
# Installing Relenv
#-------------------------------------------------------------------------------
_msg "Installing relenv"
pip install relenv >/dev/null 2>&1
if [ -n "$(pip show relenv)" ]; then
if [ -n "${RELENV_VERSION}" ]; then
pip install relenv==${RELENV_VERSION} >/dev/null 2>&1
export RELENV_FETCH_VERSION=${RELENV_VERSION}
else
pip install relenv >/dev/null 2>&1
fi
if [ -n "$(relenv --version)" ]; then
_success
else
_failure

View file

@ -137,6 +137,7 @@ cd $RPM_BUILD_DIR
%if "%{getenv:SALT_ONEDIR_ARCHIVE}" == ""
python3 -m venv --clear --copies build/venv
build/venv/bin/python3 -m pip install relenv==${SALT_RELENV_VERSION}
export FETCH_RELENV_VERSION=${SALT_RELENV_VERSION}
export PY=$(build/venv/bin/python3 -c 'import sys; sys.stdout.write("{}.{}".format(*sys.version_info)); sys.stdout.flush()')
build/venv/bin/python3 -m pip install -r %{_salt_src}/requirements/static/ci/py${PY}/tools.txt
build/venv/bin/relenv fetch

View file

@ -39,17 +39,16 @@ param(
[Parameter(Mandatory=$false)]
[ValidatePattern("^\d{1,2}.\d{1,2}.\d{1,2}$")]
[ValidateSet(
"3.11.2",
"3.11.3",
"3.10.11"
)]
[Alias("p")]
# The version of Python to be built. Pythonnet only supports up to Python
# 3.8 for now. Pycurl stopped building wheel files after 7.43.0.5 which
# supported up to 3.8. So we're pinned to the latest version of Python 3.8.
# We may have to drop support for pycurl.
# Default is: 3.8.16
[String] $PythonVersion = "3.10.11",
[Parameter(Mandatory=$false)]
[Alias("r")]
[String] $RelenvVersion = "0.12.3",
[Parameter(Mandatory=$false)]
[Alias("b")]
# Build python from source instead of fetching a tarball
@ -111,6 +110,7 @@ Write-Host $("#" * 80)
Write-Host "Build Salt Installer Packages" -ForegroundColor Cyan
Write-Host "- Salt Version: $Version"
Write-Host "- Python Version: $PythonVersion"
Write-Host "- Relenv Version: $RelenvVersion"
Write-Host "- Architecture: $Architecture"
Write-Host $("v" * 80)
@ -165,6 +165,7 @@ if ( ! $SkipInstall ) {
$KeywordArguments = @{
Version = $PythonVersion
Architecture = $Architecture
RelenvVersion = $RelenvVersion
}
if ( $Build ) {
$KeywordArguments["Build"] = $false

View file

@ -18,17 +18,16 @@ param(
[Parameter(Mandatory=$false)]
[ValidatePattern("^\d{1,2}.\d{1,2}.\d{1,2}$")]
[ValidateSet(
"3.11.2",
"3.11.3",
"3.10.11"
)]
[Alias("v")]
# The version of Python to be built. Pythonnet only supports up to Python
# 3.8 for now. Pycurl stopped building wheel files after 7.43.0.5 which
# supported up to 3.8. So we're pinned to the latest version of Python 3.8.
# We may have to drop support for pycurl or build it ourselves.
# Default is: 3.8.16
[String] $Version = "3.10.11",
[Parameter(Mandatory=$false)]
[Alias("r")]
[String] $RelenvVersion = "0.12.3",
[Parameter(Mandatory=$false)]
[ValidateSet("x64", "x86", "amd64")]
[Alias("a")]
@ -85,6 +84,7 @@ if ( $Build ) {
}
Write-Host "$SCRIPT_MSG" -ForegroundColor Cyan
Write-Host "- Python Version: $Version"
Write-Host "- Relenv Version: $RelenvVersion"
Write-Host "- Architecture: $Architecture"
Write-Host "- Build: $Build"
Write-Host $("-" * 80)
@ -227,7 +227,7 @@ if ( $env:VIRTUAL_ENV ) {
# Installing Relenv
#-------------------------------------------------------------------------------
Write-Host "Installing Relenv: " -NoNewLine
pip install relenv --disable-pip-version-check | Out-Null
pip install relenv==$RelenvVersion --disable-pip-version-check | Out-Null
$output = pip list --disable-pip-version-check
if ("relenv" -in $output.split()) {
Write-Result "Success" -ForegroundColor Green
@ -235,6 +235,7 @@ if ("relenv" -in $output.split()) {
Write-Result "Failed" -ForegroundColor Red
exit 1
}
$env:RELENV_FETCH_VERSION=$RelenvVersion
#-------------------------------------------------------------------------------
# Building Python with Relenv

View file

@ -77,11 +77,18 @@ def debian(
ctx.exit(1)
ctx.info("Building the package from the source files")
shared_constants = _get_shared_constants()
if not python_version:
python_version = shared_constants["python_version_linux"]
if not relenv_version:
relenv_version = shared_constants["relenv_version"]
if TYPE_CHECKING:
assert python_version
assert relenv_version
new_env = {
"SALT_RELENV_VERSION": relenv_version or shared_constants["relenv_version"],
"SALT_PYTHON_VERSION": python_version
or shared_constants["python_version_linux"],
"SALT_RELENV_VERSION": relenv_version,
"SALT_PYTHON_VERSION": python_version,
"SALT_PACKAGE_ARCH": str(arch),
"RELENV_FETCH_VERSION": relenv_version,
}
for key, value in new_env.items():
os.environ[key] = value
@ -137,11 +144,18 @@ def rpm(
ctx.exit(1)
ctx.info(f"Building the package from the source files")
shared_constants = _get_shared_constants()
if not python_version:
python_version = shared_constants["python_version_linux"]
if not relenv_version:
relenv_version = shared_constants["relenv_version"]
if TYPE_CHECKING:
assert python_version
assert relenv_version
new_env = {
"SALT_RELENV_VERSION": relenv_version or shared_constants["relenv_version"],
"SALT_PYTHON_VERSION": python_version
or shared_constants["python_version_linux"],
"SALT_RELENV_VERSION": relenv_version,
"SALT_PYTHON_VERSION": python_version,
"SALT_PACKAGE_ARCH": str(arch),
"RELENV_FETCH_VERSION": relenv_version,
}
for key, value in new_env.items():
os.environ[key] = value
@ -168,10 +182,21 @@ def rpm(
"sign": {
"help": "Sign and notorize built package",
},
"relenv_version": {
"help": "The version of relenv to use",
},
"python_version": {
"help": "The version of python to build with using relenv",
},
},
)
def macos(
ctx: Context, onedir: str = None, salt_version: str = None, sign: bool = False
ctx: Context,
onedir: str = None,
salt_version: str = None,
sign: bool = False,
relenv_version: str = None,
python_version: str = None,
):
"""
Build the macOS package.
@ -198,10 +223,23 @@ def macos(
if not onedir:
# Prep the salt onedir if not building from an existing one
shared_constants = _get_shared_constants()
py_ver = shared_constants["python_version_macos"]
if not python_version:
python_version = shared_constants["python_version_linux"]
if not relenv_version:
relenv_version = shared_constants["relenv_version"]
if TYPE_CHECKING:
assert python_version
assert relenv_version
os.environ["RELENV_FETCH_VERSION"] = relenv_version
with ctx.chdir(checkout / "pkg" / "macos"):
ctx.info("Fetching relenv python")
ctx.run("./build_python.sh", "--version", py_ver)
ctx.run(
"./build_python.sh",
"--version",
python_version,
"--relenv-version",
relenv_version,
)
ctx.info("Installing salt into the relenv python")
ctx.run("./install_salt.sh")
@ -249,6 +287,12 @@ def macos(
"sign": {
"help": "Sign and notarize built package",
},
"relenv_version": {
"help": "The version of relenv to use",
},
"python_version": {
"help": "The version of python to build with using relenv",
},
},
)
def windows(
@ -257,6 +301,8 @@ def windows(
salt_version: str = None,
arch: str = None,
sign: bool = False,
relenv_version: str = None,
python_version: str = None,
):
"""
Build the Windows package.
@ -265,6 +311,16 @@ def windows(
assert salt_version is not None
assert arch is not None
shared_constants = _get_shared_constants()
if not python_version:
python_version = shared_constants["python_version_linux"]
if not relenv_version:
relenv_version = shared_constants["relenv_version"]
if TYPE_CHECKING:
assert python_version
assert relenv_version
os.environ["RELENV_FETCH_VERSION"] = relenv_version
build_cmd = [
"powershell.exe",
"&",
@ -273,6 +329,10 @@ def windows(
arch,
"-Version",
salt_version,
"-PythonVersion",
python_version,
"-RelenvVersion",
relenv_version,
"-CICD",
]
@ -380,6 +440,9 @@ def windows(
"help": "The version of python to create an environment for using relenv",
"required": True,
},
"relenv_version": {
"help": "The version of relenv to use",
},
"package_name": {
"help": "The name of the relenv environment to be created",
"required": True,
@ -394,6 +457,7 @@ def onedir_dependencies(
ctx: Context,
arch: str = None,
python_version: str = None,
relenv_version: str = None,
package_name: str = None,
platform: str = None,
):
@ -408,6 +472,16 @@ def onedir_dependencies(
assert package_name is not None
assert platform is not None
shared_constants = _get_shared_constants()
if not python_version:
python_version = shared_constants[f"python_version_{platform}"]
if not relenv_version:
relenv_version = shared_constants["relenv_version"]
if TYPE_CHECKING:
assert python_version
assert relenv_version
os.environ["RELENV_FETCH_VERSION"] = relenv_version
# We import relenv here because it is not a hard requirement for the rest of the tools commands
try:
import relenv.create
@ -430,12 +504,11 @@ def onedir_dependencies(
ctx.error(f"Failed to get the relenv version: {ret}")
ctx.exit(1)
target_relenv_version = _get_shared_constants()["relenv_version"]
env_relenv_version = ret.stdout.strip().decode()
if env_relenv_version != target_relenv_version:
if env_relenv_version != relenv_version:
ctx.error(
f"The onedir installed relenv version({env_relenv_version}) is not "
f"the relenv version which should be used({target_relenv_version})."
f"the relenv version which should be used({relenv_version})."
)
ctx.exit(1)
@ -526,6 +599,9 @@ def onedir_dependencies(
"help": "The name of the relenv environment to install salt into",
"required": True,
},
"relenv_version": {
"help": "The version of relenv to use",
},
},
)
def salt_onedir(
@ -533,6 +609,7 @@ def salt_onedir(
salt_name: str,
platform: str = None,
package_name: str = None,
relenv_version: str = None,
):
"""
Install salt into a relenv onedir environment.
@ -541,6 +618,13 @@ def salt_onedir(
assert platform is not None
assert package_name is not None
shared_constants = _get_shared_constants()
if not relenv_version:
relenv_version = shared_constants["relenv_version"]
if TYPE_CHECKING:
assert relenv_version
os.environ["RELENV_FETCH_VERSION"] = relenv_version
salt_archive = pathlib.Path(salt_name).resolve()
onedir_env = pathlib.Path(package_name).resolve()
_check_pkg_build_files_exist(ctx, onedir_env=onedir_env, salt_archive=salt_archive)
@ -558,12 +642,11 @@ def salt_onedir(
ctx.error(f"Failed to get the relenv version: {ret}")
ctx.exit(1)
target_relenv_version = _get_shared_constants()["relenv_version"]
env_relenv_version = ret.stdout.strip().decode()
if env_relenv_version != target_relenv_version:
if env_relenv_version != relenv_version:
ctx.error(
f"The onedir installed relenv version({env_relenv_version}) is not "
f"the relenv version which should be used({target_relenv_version})."
f"the relenv version which should be used({relenv_version})."
)
ctx.exit(1)