mirror of
https://github.com/actions/runner-images.git
synced 2025-12-10 10:58:13 +00:00
Merge pull request #1726 from vsafonkin/v-vlsafo/add-pipx-ubuntu
[ubuntu] Add pipx and install yamllint and aws sam cli through it.
This commit is contained in:
@@ -246,3 +246,7 @@ function Get-AptPackages {
|
||||
$pkgs = ($apt.common_packages + $apt.cmd_packages | Sort-Object) -join ", "
|
||||
return $pkgs
|
||||
}
|
||||
|
||||
function Get-PipxVersion {
|
||||
return "Pipx $(pipx --version 2> $null)"
|
||||
}
|
||||
@@ -54,7 +54,8 @@ $markdown += New-MDList -Style Unordered -Lines @(
|
||||
)
|
||||
|
||||
$markdown += New-MDHeader "Package Management" -Level 3
|
||||
$markdown += New-MDList -Style Unordered -Lines @(
|
||||
|
||||
$packageManagementList = @(
|
||||
(Get-HomebrewVersion),
|
||||
(Get-GemVersion),
|
||||
(Get-MinicondaVersion),
|
||||
@@ -66,6 +67,14 @@ $markdown += New-MDList -Style Unordered -Lines @(
|
||||
(Get-VcpkgVersion)
|
||||
)
|
||||
|
||||
if (-not (Test-IsUbuntu16)) {
|
||||
$packageManagementList += @(
|
||||
(Get-PipxVersion)
|
||||
)
|
||||
}
|
||||
|
||||
$markdown += New-MDList -Style Unordered -Lines ($packageManagementList | Sort-Object)
|
||||
|
||||
$markdown += New-MDHeader "Project Management" -Level 3
|
||||
$markdown += New-MDList -Style Unordered -Lines @(
|
||||
(Get-AntVersion),
|
||||
@@ -115,6 +124,7 @@ $toolsList = @(
|
||||
(Get-TerraformVersion),
|
||||
(Get-UnZipVersion),
|
||||
(Get-WgetVersion),
|
||||
(Get-YamllintVersion),
|
||||
(Get-ZipVersion),
|
||||
(Get-ZstdVersion)
|
||||
)
|
||||
|
||||
@@ -276,3 +276,7 @@ function Get-SphinxVersion {
|
||||
$sphinxVersion = searchd -h | Select-Object -First 1 | Take-OutputPart -Part 1 | Take-OutputPart -Part 0 -Delimiter "-"
|
||||
return "Sphinx Open Source Search Server $sphinxVersion"
|
||||
}
|
||||
|
||||
function Get-YamllintVersion {
|
||||
return "$(yamllint --version)"
|
||||
}
|
||||
30
images/linux/scripts/installers/pipx-packages.sh
Normal file
30
images/linux/scripts/installers/pipx-packages.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
################################################################################
|
||||
## File: pipx-packages.sh
|
||||
## Desc: Install tools via pipx
|
||||
################################################################################
|
||||
|
||||
|
||||
export PATH="$PATH:/opt/pipx_bin"
|
||||
|
||||
toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json"
|
||||
pipx_packages=$(jq -r ".pipx[] .package" $toolset)
|
||||
|
||||
for package in $pipx_packages; do
|
||||
python_version=$(jq -r ".pipx[] | select(.package == \"$package\") .python" $toolset)
|
||||
if [ "$python_version" != "null" ]; then
|
||||
python_path="/opt/hostedtoolcache/Python/$python_version*/x64/bin/python$python_version"
|
||||
echo "Install $package into python $python_path"
|
||||
pipx install $package --python $python_path
|
||||
else
|
||||
echo "Install $package into default python"
|
||||
pipx install $package
|
||||
fi
|
||||
|
||||
# Run tests to determine that the software installed as expected
|
||||
cmd=$(jq -r ".pipx[] | select(.package == \"$package\") .cmd" $toolset)
|
||||
if ! command -v $cmd; then
|
||||
echo "$package was not installed"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
@@ -6,18 +6,40 @@
|
||||
|
||||
set -e
|
||||
# Source the helpers for use with the script
|
||||
source $HELPER_SCRIPTS/etc-environment.sh
|
||||
source $HELPER_SCRIPTS/os.sh
|
||||
|
||||
# Install Python, Python 3, pip, pip3
|
||||
if isUbuntu16 || isUbuntu18; then
|
||||
apt-get install -y --no-install-recommends python python-dev python-pip python3 python3-dev python3-pip
|
||||
apt-get install -y --no-install-recommends python python-dev python-pip python3 python3-dev python3-pip python3-venv
|
||||
fi
|
||||
|
||||
if isUbuntu20; then
|
||||
apt-get install -y --no-install-recommends python3 python3-dev python3-pip
|
||||
apt-get install -y --no-install-recommends python3 python3-dev python3-pip python3-venv
|
||||
ln -s /usr/bin/pip3 /usr/bin/pip
|
||||
fi
|
||||
|
||||
if isUbuntu18 || isUbuntu20 ; then
|
||||
# Install pipx
|
||||
# Set pipx custom directory
|
||||
export PIPX_BIN_DIR=/opt/pipx_bin
|
||||
export PIPX_HOME=/opt/pipx
|
||||
|
||||
python3 -m pip install pipx
|
||||
python3 -m pipx ensurepath
|
||||
|
||||
# Update /etc/environment
|
||||
setEtcEnvironmentVariable "PIPX_BIN_DIR" $PIPX_BIN_DIR
|
||||
setEtcEnvironmentVariable "PIPX_HOME" $PIPX_HOME
|
||||
prependEtcEnvironmentPath $PIPX_BIN_DIR
|
||||
|
||||
# Test pipx
|
||||
if ! command -v pipx; then
|
||||
echo "pipx was not installed or not found on PATH"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run tests to determine that the software installed as expected
|
||||
echo "Testing to make sure that script performed as expected, and basic scenarios work"
|
||||
for cmd in python pip python3 pip3; do
|
||||
|
||||
@@ -164,7 +164,6 @@
|
||||
"time",
|
||||
"unzip",
|
||||
"wget",
|
||||
"yamllint",
|
||||
"zip"
|
||||
]
|
||||
},
|
||||
@@ -186,5 +185,15 @@
|
||||
"node:12-alpine",
|
||||
"ubuntu:14.04"
|
||||
]
|
||||
},
|
||||
"pipx": [
|
||||
{
|
||||
"package": "yamllint",
|
||||
"cmd": "yamllint"
|
||||
},
|
||||
{
|
||||
"package": "aws-sam-cli",
|
||||
"cmd": "sam"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -127,7 +127,6 @@
|
||||
"time",
|
||||
"unzip",
|
||||
"wget",
|
||||
"yamllint",
|
||||
"zip"
|
||||
]
|
||||
},
|
||||
@@ -149,5 +148,15 @@
|
||||
"node:12-alpine",
|
||||
"ubuntu:14.04"
|
||||
]
|
||||
},
|
||||
"pipx": [
|
||||
{
|
||||
"package": "yamllint",
|
||||
"cmd": "yamllint"
|
||||
},
|
||||
{
|
||||
"package": "aws-sam-cli",
|
||||
"cmd": "sam"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -238,10 +238,10 @@
|
||||
{
|
||||
"type": "shell",
|
||||
"scripts": [
|
||||
"{{template_dir}}/scripts/installers/aws-sam-cli.sh"
|
||||
"{{template_dir}}/scripts/installers/pipx-packages.sh"
|
||||
],
|
||||
"environment_vars": [
|
||||
"HELPER_SCRIPTS={{user `helper_script_folder`}}"
|
||||
"INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}"
|
||||
],
|
||||
"execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'"
|
||||
},
|
||||
|
||||
@@ -240,10 +240,10 @@
|
||||
{
|
||||
"type": "shell",
|
||||
"scripts": [
|
||||
"{{template_dir}}/scripts/installers/aws-sam-cli.sh"
|
||||
"{{template_dir}}/scripts/installers/pipx-packages.sh"
|
||||
],
|
||||
"environment_vars": [
|
||||
"HELPER_SCRIPTS={{user `helper_script_folder`}}"
|
||||
"INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}"
|
||||
],
|
||||
"execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user