Skip to content

Commit 97a1a40

Browse files
authored
Merge branch 'master' into action-execution-kvp-rbac
2 parents 0a776c4 + 6aa6198 commit 97a1a40

File tree

4 files changed

+89
-9
lines changed

4 files changed

+89
-9
lines changed

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
./scripts/github/install-apt-packages-use-cache.sh
5858
5959
- name: Initialize Pants and its GHA caches
60-
uses: pantsbuild/actions/init-pants@c0ce05ee4ba288bb2a729a2b77294e9cb6ab66f7
60+
uses: pantsbuild/actions/init-pants@e63d2d0e3c339bdffbe5e51e7c39550e3bc527bb
6161
# This action adds an env var to make pants use both pants.ci.toml & pants.toml.
6262
# This action also creates 3 GHA caches (1 is optional).
6363
# - `pants-setup` has the bootsrapped pants install

.github/workflows/pants.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
submodules: 'true'
3131

3232
- name: Initialize Pants and its GHA caches
33-
uses: pantsbuild/actions/init-pants@c0ce05ee4ba288bb2a729a2b77294e9cb6ab66f7
33+
uses: pantsbuild/actions/init-pants@e63d2d0e3c339bdffbe5e51e7c39550e3bc527bb
3434
# This action adds an env var to make pants use both pants.ci.toml & pants.toml.
3535
# This action also creates 3 GHA caches (1 is optional).
3636
# - `pants-setup` has the bootsrapped pants install

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Added
5757

5858
* Begin introducing `pants <https://www.pantsbuild.org/docs>`_ to improve DX (Developer Experience)
5959
working on StackStorm, improve our security posture, and improve CI reliability thanks in part
60-
to pants' use of PEX lockfiles. This is not a user-facing addition. #5713 #5724 #5726 #5725 #5732 #5733 #5737 #5738 #5758 #5751 #5774 #5776 #5777
60+
to pants' use of PEX lockfiles. This is not a user-facing addition. #5713 #5724 #5726 #5725 #5732 #5733 #5737 #5738 #5758 #5751 #5774 #5776 #5777 #5782
6161
Contributed by @cognifloyd
6262

6363
Changed

pants

Lines changed: 86 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

1313
set -eou pipefail
1414

15+
# an arbitrary number: bump when there's a change that someone might want to query for
16+
# (e.g. checking $(PANTS_BOOTSTRAP_TOOLS=1 ./pants version) >= ...)
17+
SCRIPT_VERSION=1
18+
1519
# Source any custom bootstrap settings for Pants from PANTS_BOOTSTRAP if it exists.
1620
: ${PANTS_BOOTSTRAP:=".pants.bootstrap"}
1721
if [[ -f "${PANTS_BOOTSTRAP}" ]]; then
@@ -40,9 +44,9 @@ fi
4044

4145
PANTS_BOOTSTRAP="${PANTS_SETUP_CACHE}/bootstrap-$(uname -s)-$(uname -m)"
4246

43-
_PEX_VERSION=2.1.62
47+
_PEX_VERSION=2.1.103
4448
_PEX_URL="https://github.com/pantsbuild/pex/releases/download/v${_PEX_VERSION}/pex"
45-
_PEX_EXPECTED_SHA256="56668b1ca147bd63141e586ffee97c7cc51ce8e6eac6c9b7a4bf1215b94396e5"
49+
_PEX_EXPECTED_SHA256="4d45336511484100ae4e2bab24542a8b86b12c8cb89230463593c60d08c4b8d3"
4650

4751
VIRTUALENV_VERSION=20.4.7
4852
VIRTUALENV_REQUIREMENTS=$(
@@ -64,6 +68,8 @@ COLOR_GREEN="\x1b[32m"
6468
COLOR_YELLOW="\x1b[33m"
6569
COLOR_RESET="\x1b[0m"
6670

71+
INSTALL_URL="https://www.pantsbuild.org/docs/installation"
72+
6773
function log() {
6874
echo -e "$@" 1>&2
6975
}
@@ -140,7 +146,7 @@ function determine_pants_version {
140146
if [[ -z "${pants_version}" ]]; then
141147
die "Please explicitly specify the \`pants_version\` in your \`pants.toml\` under the \`[GLOBAL]\` scope.
142148
See https://pypi.org/project/pantsbuild.pants/#history for all released versions
143-
and https://www.pantsbuild.org/docs/installation for more instructions."
149+
and ${INSTALL_URL} for more instructions."
144150
fi
145151
pants_major_version="$(echo "${pants_version}" | cut -d '.' -f1)"
146152
pants_minor_version="$(echo "${pants_version}" | cut -d '.' -f2)"
@@ -282,9 +288,13 @@ function bootstrap_pex {
282288
function scrub_env_vars {
283289
# Ensure the virtualenv PEX runs as shrink-wrapped.
284290
# See: https://github.com/pantsbuild/setup/issues/105
285-
if [[ -n "${!PEX_@}" ]]; then
286-
warn "Scrubbing ${!PEX_@}"
287-
unset "${!PEX_@}"
291+
local -r pex_env_vars=(${!PEX_@})
292+
if [[ ! ${#pex_env_vars[@]} -eq 0 ]]; then
293+
local -r pex_env_vars_to_scrub="${pex_env_vars[@]/PEX_ROOT}"
294+
if [[ -n "${pex_env_vars_to_scrub[@]}" ]]; then
295+
warn "Scrubbing ${pex_env_vars_to_scrub[@]}"
296+
unset ${pex_env_vars_to_scrub[@]}
297+
fi
288298
fi
289299
# Also ensure pip doesn't think packages on PYTHONPATH
290300
# are already installed.
@@ -383,6 +393,76 @@ function bootstrap_pants {
383393
echo "${bootstrapped}"
384394
}
385395

396+
function run_bootstrap_tools {
397+
# functionality for introspecting the bootstrapping process, without actually doing it
398+
if [[ "${PANTS_BOOTSTRAP_TOOLS}" -gt "${SCRIPT_VERSION}" ]]; then
399+
die "$0 script (bootstrap version ${SCRIPT_VERSION}) is too old for this invocation (with PANTS_BOOTSTRAP_TOOLS=${PANTS_BOOTSTRAP_TOOLS}).
400+
Please update it by following ${INSTALL_URL}"
401+
fi
402+
403+
case "${1:-}" in
404+
bootstrap-cache-key)
405+
local pants_version=$(determine_pants_version)
406+
local python="$(determine_python_exe "${pants_version}")"
407+
# the python above may be a shim (e.g. pyenv or homebrew), so let's get an estimate of the
408+
# actual path, as will be symlinked in the virtualenv. (NB. virtualenv does more complicated
409+
# things, but we at least emulate the symlink-resolution that it does.)
410+
local python_executable_path="$("${python}" -c 'import os, sys; print(os.path.realpath(sys.executable))')"
411+
412+
local requirements_file="$(mktemp)"
413+
echo "${VIRTUALENV_REQUIREMENTS}" > "${requirements_file}"
414+
local virtualenv_requirements_sha256="$(compute_sha256 "${python}" "${requirements_file}")"
415+
rm "${requirements_file}"
416+
417+
local parts=(
418+
"os_name=$(uname -s)"
419+
"arch=$(uname -m)"
420+
"python_path=${python}"
421+
"python_executable_path=${python_executable_path}"
422+
# the full interpreter information, for maximum compatibility
423+
"python_version=$("$python" --version)"
424+
"pex_version=${_PEX_VERSION}"
425+
"virtualenv_requirements_sha256=${virtualenv_requirements_sha256}"
426+
"pants_version=${pants_version}"
427+
)
428+
echo "${parts[*]}"
429+
;;
430+
bootstrap-version)
431+
echo "${SCRIPT_VERSION}"
432+
;;
433+
help|"")
434+
cat <<EOF
435+
Usage: PANTS_BOOTSTRAP_TOOLS=1 $0 ...
436+
437+
Subcommands:
438+
bootstrap-cache-key
439+
Print an opaque that can be used as a key for accurate and safe caching of
440+
the pants bootstrap directories.
441+
442+
(Added in bootstrap version 1.)
443+
444+
bootstrap-version
445+
Print a version number for the bootstrap script itself.
446+
447+
Distributed scripts (such as reusable CI formulae) that use these bootstrap
448+
tools should set PANTS_BOOTSTRAP_TOOLS to the minimum script version for the
449+
features they require. For example, if 'some-tool' was added in version 123:
450+
451+
PANTS_BOOTSTRAP_TOOLS=123 ./pants some-tool
452+
453+
(Added in bootstrap version 1.)
454+
EOF
455+
;;
456+
*)
457+
die "Unknown subcommand for bootstrap tools: $1. Do you mean to run without PANTS_BOOTSTRAP_TOOLS=1? Or, update this script ($INSTALL_URL)?"
458+
esac
459+
}
460+
461+
if [[ "${PANTS_BOOTSTRAP_TOOLS:-}" -gt 0 ]]; then
462+
run_bootstrap_tools "$@"
463+
exit 0
464+
fi
465+
386466
# Ensure we operate from the context of the ./pants buildroot.
387467
cd "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
388468
pants_version="$(determine_pants_version)"

0 commit comments

Comments
 (0)