Skip to content

Commit

Permalink
SNOW-1639544 automate manual WHL checks 2.8.2 (#1675)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-mraba authored Oct 7, 2024
1 parent 2ba832a commit af67803
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 15 deletions.
4 changes: 3 additions & 1 deletion .compat/build_snowflake-cli-labs.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh
#!/bin/bash
set -eo pipefail

git config --global --add safe.directory /snowflake-cli

cd $(git rev-parse --show-toplevel)

python .compat/snowflake-cli-labs_version_sync.py
Expand Down
40 changes: 26 additions & 14 deletions scripts/packaging/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,31 @@ services:
build: .
volumes:
- ../../:/snowflake-cli
centos:
image: centos:latest
container_name: centos
command: tail -f /dev/null
tty: true
stdin_open: true
cli-builder:
build: .
volumes:
- ../../:/snowflake-cli
environment:
- RELEASE_TYPE
command: /bin/bash -c "pyenv exec hatch build --clean"
cli-test:
build: .
volumes:
- ../../:/snowflake-cli
environment:
- RELEASE_TYPE
command: /bin/bash -c "eval \"$(pyenv init -)\" && ./scripts/packaging/python/test_cli_whl.sh"
cli-labs-builder:
build: .
volumes:
- ../../:/data
centos7:
image: centos:7
container_name: centos
command: tail -f /dev/null
tty: true
stdin_open: true
- ../../:/snowflake-cli
environment:
- RELEASE_TYPE
command: /bin/bash -c "pyenv exec hatch run legacy-pypi-build"
cli-labs-test:
build: .
volumes:
- ../../:/data
- ../../:/snowflake-cli
environment:
- RELEASE_TYPE
command: /bin/bash -c "eval \"$(pyenv init -)\" && ./scripts/packaging/python/test_cli_labs_whl.sh"
87 changes: 87 additions & 0 deletions scripts/packaging/python/test_cli_labs_whl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash
set -eoux pipefail

git config --global --add safe.directory /snowflake-cli

if [[ -z "${RELEASE_TYPE+x}" ]]; then
echo "RELEASE_TYPE is not set"
exit 1
fi

ROOT_DIR="$(git rev-parse --show-toplevel)"
VERSION=$(hatch version)

check_tag_version_for_release() {
if [[ ${RELEASE_TYPE} == "release" ]]; then
echo "checking for proper tag set to commit"

TAG_VERSION=$(git tag --points-at HEAD | sed 's/^v//')

if [[ -n "$TAG_VERSION" && "$TAG_VERSION" != "$VERSION" ]]; then
echo "Tag version $TAG_VERSION does not match package version $VERSION"
exit 1
fi
fi
}

check_tag_version_for_release

CLI_WHL_FILE="${ROOT_DIR}/dist/snowflake_cli-${VERSION}-py3-none-any.whl"
CLI_LABS_WHL_FILE="${ROOT_DIR}/.compat/snowflake-cli-labs/dist/snowflake_cli_labs-${VERSION}-py3-none-any.whl"

echo $CLI_WHL_FILE
echo $CLI_LABS_WHL_FILE

if [[ ! -f $CLI_WHL_FILE ]]; then
echo "File not found: $CLI_WHL_FILE"
exit 1
fi

if [[ ! -f $CLI_LABS_WHL_FILE ]]; then
echo "File not found: $CLI_LABS_WHL_FILE"
exit 1
fi

test_version() {
cli_version=$($1 --version)
if [[ $cli_version != "Snowflake CLI version: $VERSION" ]]; then
echo "Version mismatch ${VERSION} != ${cli_version}"
exit 1
fi
$1 --help
# we skip connection test for now
# due to the fact that required fuse secrets
# do not work with job (only pipeline is supported)
#
# $1 connection test
# $1 sql -q "select current_timestamp()"
}

validate_from_whl() {
python -m venv cli_whl_venv
source cli_whl_venv/bin/activate

pip install $1
test_version "./cli_whl_venv/bin/snow"

deactivate
}

validate_from_tag() {
python -m venv cli_tag_venv
source cli_tag_venv/bin/activate

pip install git+https://github.com/snowflakedb/snowflake-cli.git@v${VERSION}

test_version ./cli_tag_venv/bin/snow
deactivate
}

rm -rf cli_whl_venv || true
rm -rf cli_tag_venv || true

validate_from_whl $CLI_WHL_FILE
validate_from_whl $CLI_LABS_WHL_FILE

rm -rf cli_whl_venv || true
rm -rf cli_tag_venv || true
87 changes: 87 additions & 0 deletions scripts/packaging/python/test_cli_whl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash
set -eoux pipefail

git config --global --add safe.directory /snowflake-cli

if [[ -z "${RELEASE_TYPE+x}" ]]; then
echo "RELEASE_TYPE is not set"
exit 1
fi

ROOT_DIR="$(git rev-parse --show-toplevel)"
VERSION=$(hatch version)

check_tag_version_for_release() {
if [[ ${RELEASE_TYPE} == "release" ]]; then
echo "checking for proper tag set to commit"

TAG_VERSION=$(git tag --points-at HEAD | sed 's/^v//')

if [[ -n "$TAG_VERSION" && "$TAG_VERSION" != "$VERSION" ]]; then
echo "Tag version $TAG_VERSION does not match package version $VERSION"
exit 1
fi
fi
}

check_tag_version_for_release

CLI_WHL_FILE="${ROOT_DIR}/dist/snowflake_cli-${VERSION}-py3-none-any.whl"
CLI_LABS_WHL_FILE="${ROOT_DIR}/.compat/snowflake-cli-labs/dist/snowflake_cli_labs-${VERSION}-py3-none-any.whl"

echo $CLI_WHL_FILE
echo $CLI_LABS_WHL_FILE

if [[ ! -f $CLI_WHL_FILE ]]; then
echo "File not found: $CLI_WHL_FILE"
exit 1
fi

if [[ ! -f $CLI_LABS_WHL_FILE ]]; then
echo "File not found: $CLI_LABS_WHL_FILE"
exit 1
fi

test_version() {
cli_version=$($1 --version)
if [[ $cli_version != "Snowflake CLI version: $VERSION" ]]; then
echo "Version mismatch ${VERSION} != ${cli_version}"
exit 1
fi
$1 --help
# we skip connection test for now
# due to the fact that required fuse secrets
# do not work with job (only pipeline is supported)
#
# $1 connection test
# $1 sql -q "select current_timestamp()"
}

validate_from_whl() {
python -m venv cli_whl_venv
source cli_whl_venv/bin/activate

pip install $1
test_version "./cli_whl_venv/bin/snow"

deactivate
}

validate_from_tag() {
python -m venv cli_tag_venv
source cli_tag_venv/bin/activate

pip install git+https://github.com/snowflakedb/snowflake-cli.git@v${VERSION}

test_version ./cli_tag_venv/bin/snow
deactivate
}

rm -rf cli_whl_venv || true
rm -rf cli_tag_venv || true

validate_from_whl $CLI_WHL_FILE
validate_from_whl $CLI_LABS_WHL_FILE

rm -rf cli_whl_venv || true
rm -rf cli_tag_venv || true

0 comments on commit af67803

Please sign in to comment.