Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump minimum python version to 3.8 and Upgrade pantsbuild to 2.17 #6118

Merged
merged 22 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e54d5f6
update pants to 2.16.0 final
cognifloyd Jan 27, 2024
addeb79
switch from in-repo ./pants script to pants binary
cognifloyd Jan 27, 2024
bcc568d
update to pants 2.17.1
cognifloyd Jan 27, 2024
b7d3e2c
increase min python version to 3.8
cognifloyd Jan 28, 2024
9f29b03
Regenerate lockfiles/st2.lock w/ min python 3.8
cognifloyd Jan 28, 2024
1ed80c7
Regenerate tool lockfiles w/ python 3.8 minimum
cognifloyd Jan 28, 2024
6afb377
regen sample conf
cognifloyd Jan 28, 2024
c32eae1
fix bandit lockfile
cognifloyd Jan 28, 2024
c1ed3ea
adjust pants-plugins interpreter constraints for pants 2.18+
cognifloyd Jan 28, 2024
4a4a16a
update jsonschema to 3.2.0
cognifloyd Jan 28, 2024
4ca0185
add changelog entry
cognifloyd Jan 28, 2024
665c70c
stable sort across python versions
cognifloyd Jan 29, 2024
dcc7640
deal with CI failures due to updated transitive dep
cognifloyd Jan 29, 2024
7600233
Update Makefile hack to be compatible with make 4.3+
cognifloyd Jan 29, 2024
c904f17
Stop testing w/ python3.6 in CI
cognifloyd Jan 29, 2024
bcaf467
do not update to jsonschema 4 yet
cognifloyd Jan 29, 2024
84692c7
correct pants-plugin test to account for new pantsbuild 2.17+
cognifloyd Jan 29, 2024
be09e03
update custom jsonschema validator w/ jsonschema 3 properties
cognifloyd Jan 29, 2024
80c7ee3
test: adjust test after jsonschema update …
cognifloyd Jan 29, 2024
620e90b
drop some pointless if six.PY3 else blocks in tests
cognifloyd Jan 29, 2024
4ed34ce
Improve changelog
cognifloyd Jan 29, 2024
1df2823
correct test that expects a regex
cognifloyd Jan 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
./scripts/github/install-apt-packages-use-cache.sh

- name: Initialize Pants and its GHA caches
uses: pantsbuild/actions/init-pants@v2
uses: pantsbuild/actions/init-pants@v6-scie-pants
# This action adds an env var to make pants use both pants.ci.toml & pants.toml.
# This action also creates 3 GHA caches (1 is optional).
# - `pants-setup` has the bootsrapped pants install
Expand All @@ -75,10 +75,12 @@ jobs:
named-caches-hash: ${{ hashFiles('requirements.txt') }}
# enable the optional lmdb_store cache since we're not using remote caching.
cache-lmdb-store: 'true'
# install whatever version of python we need for our in-repo pants-plugins
setup-python-for-plugins: 'true'

- name: Lint
run: |
./pants lint ::
pants lint ::

- name: Upload pants log
uses: actions/upload-artifact@v2
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/pants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
submodules: 'true'

- name: Initialize Pants and its GHA caches
uses: pantsbuild/actions/init-pants@v2
uses: pantsbuild/actions/init-pants@v6-scie-pants
# This action adds an env var to make pants use both pants.ci.toml & pants.toml.
# This action also creates 3 GHA caches (1 is optional).
# - `pants-setup` has the bootsrapped pants install
Expand All @@ -48,10 +48,12 @@ jobs:
named-caches-hash: ${{ hashFiles('requirements.txt') }}
# enable the optional lmdb_store cache since we're not using remote caching.
cache-lmdb-store: 'true'
# install whatever version of python we need for our in-repo pants-plugins
setup-python-for-plugins: 'true'

- name: Check BUILD files
run: |
./pants tailor --check update-build-files --check ::
pants tailor --check update-build-files --check ::

- name: Upload pants log
uses: actions/upload-artifact@v2
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
./scripts/github/install-apt-packages-use-cache.sh

- name: Initialize Pants and its GHA caches
uses: pantsbuild/actions/init-pants@v2
uses: pantsbuild/actions/init-pants@v6-scie-pants
# This action adds an env var to make pants use both pants.ci.toml & pants.toml.
# This action also creates 3 GHA caches (1 is optional).
# - `pants-setup` has the bootsrapped pants install
Expand All @@ -123,13 +123,15 @@ jobs:
named-caches-hash: ${{ hashFiles('requirements.txt') }}
# enable the optional lmdb_store cache since we're not using remote caching.
cache-lmdb-store: 'true'
# install whatever version of python we need for our in-repo pants-plugins
setup-python-for-plugins: 'true'

- name: Test
# We do not support running pytest everywhere yet. When we do it will be simply:
# ./pants test ::
# pants test ::
# Until then, we need to manually adjust this command line to test what we can.
run: |
./pants test pylint_plugins/:: pants-plugins/::
pants test pylint_plugins/:: pants-plugins/::

- name: Upload pants log
uses: actions/upload-artifact@v2
Expand Down
4 changes: 4 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ file(
name="license",
source="LICENSE",
)

shell_sources(
name="root",
)
23 changes: 12 additions & 11 deletions BUILD.tools
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ python_requirement(
"bandit==1.7.0",
"setuptools",
"GitPython==3.1.18",
# bandit needs stevedore which needs importlib-metadata<5
# see: https://github.com/PyCQA/bandit/pull/952
"importlib-metadata<5;python_version<'3.8'",
],
)

Expand Down Expand Up @@ -40,14 +37,18 @@ python_requirement(
resolve="pytest",
requirements=[
"pytest==7.0.1", # copied from https://www.pantsbuild.org/v2.14/docs/reference-pytest#version
"pytest-benchmark[histogram]==3.4.1",
# "pytest-timer[colorama]",
"pytest-icdiff",
"pygments",
# "pytest-timeout",
# "pytest-mock",
"pytest-cov>=2.12,!=2.12.1,<3.1",
"pytest-xdist>=2.5,<3",
"pytest-benchmark[histogram]==3.4.1", # used for st2common/benchmarks
# "pytest-timer[colorama]", # report test timing (--with-timer ala nose-timer)
"pytest-icdiff", # make diff output easier to read
"pygments", # highlight code in tracebacks
#
# other possible plugins
# "pytest-timeout", # time limit on tests
# "pytest-mock", # more convenient mocking
#
# needed by pants
"pytest-cov>=2.12,!=2.12.1,<3.1", # coverage
"pytest-xdist>=2.5,<3", # parallel test runs (pants uses this if [pytest].xdist_enabled)
],
)

Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ in development
Fixed
~~~~~

Added
~~~~~
* Continue introducing `pants <https://www.pantsbuild.org/docs>`_ to improve DX (Developer Experience)
working on StackStorm, improve our security posture, and improve CI reliability thanks in part
to pants' use of PEX lockfiles. This is not a user-facing addition.
#6118
Contributed by @cognifloyd

3.8.1 - December 13, 2023
-------------------------
Fixed
Expand Down
2 changes: 1 addition & 1 deletion conf/st2.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ token_ttl = 86400
# Standalone mode options - options below only apply when auth service is running in the standalone
# mode.

# Authentication backend to use in a standalone mode. Available backends: ldap, flat_file.
# Authentication backend to use in a standalone mode. Available backends: flat_file, ldap.
backend = flat_file
# JSON serialized arguments which are passed to the authentication backend in a standalone mode.
backend_kwargs = None
Expand Down
2 changes: 1 addition & 1 deletion fixed-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ gitdb==4.0.2
greenlet==1.0.0
gunicorn==21.2.0
jsonpath-rw==1.4.0
jsonschema==2.6.0
jsonschema==3.2.0
kombu==5.0.2
lockfile==0.12.2
# Fix MarkupSafe to < 2.1.0 as 2.1.0 removes soft_unicode
Expand Down
221 changes: 221 additions & 0 deletions get-pants.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
#!/usr/bin/env bash
# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

set -euo pipefail

COLOR_RED="\x1b[31m"
COLOR_GREEN="\x1b[32m"
COLOR_YELLOW="\x1b[33m"
COLOR_RESET="\x1b[0m"

function log() {
echo -e "$@" 1>&2
}

function die() {
(($# > 0)) && log "${COLOR_RED}$*${COLOR_RESET}"
exit 1
}

function green() {
(($# > 0)) && log "${COLOR_GREEN}$*${COLOR_RESET}"
}

function warn() {
(($# > 0)) && log "${COLOR_YELLOW}$*${COLOR_RESET}"
}

function check_cmd() {
local cmd="$1"
command -v "$cmd" > /dev/null || die "This script requires the ${cmd} binary to be on the PATH."
}

help_url="https://www.pantsbuild.org/docs/getting-help"

_GC=()

function gc() {
if (($# > 0)); then
check_cmd rm
_GC+=("$@")
else
rm -rf "${_GC[@]}"
fi
}

trap gc EXIT

check_cmd uname

function calculate_os() {
local os

os="$(uname -s)"
if [[ "${os}" =~ [Ll]inux ]]; then
echo linux
elif [[ "${os}" =~ [Dd]arwin ]]; then
echo macos
elif [[ "${os}" =~ [Ww]in|[Mm][Ii][Nn][Gg] ]]; then
# Powershell reports something like: Windows_NT
# Git bash reports something like: MINGW64_NT-10.0-22621
echo windows
else
die "Pants is not supported on this operating system (${os}). Please reach out to us at ${help_url} for help."
fi
}

OS="$(calculate_os)"

check_cmd basename
if [[ "${OS}" == "windows" ]]; then
check_cmd pwsh
else
check_cmd curl
fi

function fetch() {
local url="$1"
local dest_dir="$2"

local dest
dest="${dest_dir}/$(basename "${url}")"

if [[ "${OS}" == "windows" ]]; then
pwsh -c "Invoke-WebRequest -OutFile $dest -Uri $url"
else
curl --proto '=https' --tlsv1.2 -sSfL -o "${dest}" "${url}"
fi
}

if [[ "${OS}" == "macos" ]]; then
check_cmd shasum
else
check_cmd sha256sum
fi

function sha256() {
if [[ "${OS}" == "macos" ]]; then
shasum --algorithm 256 "$@"
else
sha256sum "$@"
fi
}

check_cmd mktemp

function install_from_url() {
local url="$1"
local dest="$2"

local workdir
workdir="$(mktemp -d)"
gc "${workdir}"

fetch "${url}.sha256" "${workdir}"
fetch "${url}" "${workdir}"
(
cd "${workdir}"
sha256 -c --status ./*.sha256 ||
die "Download from ${url} did not match the fingerprint at ${url}.sha256"
)
rm "${workdir}/"*.sha256
if [[ "${OS}" == "macos" ]]; then
mkdir -p "$(dirname "${dest}")"
install -m 755 "${workdir}/"* "${dest}"
else
install -D -m 755 "${workdir}/"* "${dest}"
fi
}

function calculate_arch() {
local arch

arch="$(uname -m)"
if [[ "${arch}" =~ x86[_-]64 ]]; then
echo x86_64
elif [[ "${arch}" =~ arm64|aarch64 ]]; then
echo aarch64
else
die "Pants is not supported for this chip architecture (${arch}). Please reach out to us at ${help_url} for help."
fi
}

check_cmd cat

function usage() {
cat << EOF
Usage: $0

Installs the pants launcher binary.

You only need to run this once on a machine when you do not have "pants"
available to run yet.

The pants binary takes care of managing and running the underlying
Pants version configured in "pants.toml" in the surrounding Pants-using
project.

Once installed, if you want to update your "pants" launcher binary, use
"SCIE_BOOT=update pants" to get the latest release or
"SCIE_BOOT=update pants --help" to learn more options.

-h | --help: Print this help message.

-d | --bin-dir:
The directory to install the scie-pants binary in, "~/.local/bin" by default.

-b | --base-name:
The name to use for the scie-pants binary, "pants" by default.

-V | --version:
The version of the scie-pants binary to install, the latest version by default.
The available versions can be seen at:
https://github.com/pantsbuild/scie-pants/releases

EOF
}

bin_dir="${HOME}/.local/bin"
base_name="pants"
version="latest/download"
while (($# > 0)); do
case "$1" in
--help | -h)
usage
exit 0
;;
--bin-dir | -d)
bin_dir="$2"
shift
;;
--base-name | -b)
base_name="$2"
shift
;;
--version | -V)
version="download/v$2"
shift
;;
*)
usage
die "Unexpected argument $1\n"
;;
esac
shift
done

ARCH="$(calculate_arch)"
URL="https://github.com/pantsbuild/scie-pants/releases/${version}/scie-pants-${OS}-${ARCH}"
dest="${bin_dir}/${base_name}"

log "Downloading and installing the pants launcher ..."
install_from_url "${URL}" "${dest}"
green "Installed the pants launcher from ${URL} to ${dest}"
if ! command -v "${base_name}" > /dev/null; then
warn "${dest} is not on the PATH."
log "You'll either need to invoke ${dest} explicitly or else add ${bin_dir} to your shell's PATH."
fi

green "\nRunning \`pants\` in a Pants-enabled repo will use the version of Pants configured for that repo."
green "In a repo not yet Pants-enabled, it will prompt you to set up Pants for that repo."
Loading
Loading