Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-azhan committed Oct 26, 2024
1 parent 9954047 commit a270e65
Show file tree
Hide file tree
Showing 6 changed files with 3,848 additions and 1 deletion.
152 changes: 152 additions & 0 deletions .github/scripts/install_protoc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#!/bin/sh

set -eu

SCRIPT_NAME="$(basename "$0")"

echo "${SCRIPT_NAME} is running... "

PROTOC_VERSION=28.3
PROTOC_OS=""
PROTOC_ARCH=""
PROTOC_ZIP=""
SUDO_CMD=""

buildProtocZIPName() {
PROTOC_ZIP=protoc-${PROTOC_VERSION}-${PROTOC_OS}-${PROTOC_ARCH}.zip
}

getOSName(){
KERNEL_TYPE=$(uname -s | tr '[:upper:]' '[:lower:]')

case "${KERNEL_TYPE}" in
linux)
PROTOC_OS="linux"
;;
darwin)
PROTOC_OS="osx"
;;
freebsd)
PROTOC_OS="freebsd"
;;
msys* | cygwin*)
PROTOC_OS="win"
echo "Your Operating System ${KERNEL_TYPE}-> ITS NOT SUPPORTED"
exit 1
;;
* )
echo "Your Operating System ${KERNEL_TYPE} -> ITS NOT SUPPORTED"
exit 1
;;
esac
}

getArch(){
ARCH=$(uname -m)

# supported archs
# - amd64
# - arm64
# - 386
# - armv7

case "${ARCH}" in
x86)
PROTOC_ARCH="x86_32"
;;
i?86)
PROTOC_ARCH="x86_32"
;;
amd64)
PROTOC_ARCH="x86_64"
;;
arm64)
PROTOC_ARCH="arm64"
;;
x86_64)
PROTOC_ARCH="x86_64"
;;
aarch64)
PROTOC_ARCH="aarch_64"
;;
* )
echo "Your Architecture ${ACRH} -> ITS NOT SUPPORTED."
;;
esac
}

cleanup() {
trap - EXIT
rm -rf ./protoc-*
}

downloadProtoc() {
URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/${PROTOC_ZIP}"

echo "Gonna to download ${PROTOC_ZIP} at ${URL}"

wget --no-check-certificate -O "${PROTOC_ZIP}" "${URL}" &&
"${SUDO_CMD}"unzip -o "${PROTOC_ZIP}" -d /usr/local bin/protoc &&
"${SUDO_CMD}"unzip -o "${PROTOC_ZIP}" -d /usr/local 'include/*' &&
"${SUDO_CMD}"chmod +x /usr/local/bin/protoc
}

osxInstall() {
echo "OSX"

SUDO_CMD=""

PROTOC_ARCH="x86_64"
}

linuxInstall() {
echo "LINUX"

DISTRO_ID=$(grep '^ID=' /etc/os-release | sed "s/ID=//")
echo "${DISTRO_ID}"

case "${DISTRO_ID}" in
alpine*)
SUDO_CMD=""
;;
ubuntu*)
SUDO_CMD="sudo "
;;
esac
}

install() {
getOSName
getArch

case "${PROTOC_OS}" in
osx*)
osxInstall
;;
linux*)
linuxInstall
;;
win*)
## TODO(o.balunenko): add windows installation.
echo "WINDOWS"
exit 1
;;
*)
echo "unsupported os: ${PROTOC_OS}"
exit 1
;;
esac

buildProtocZIPName

downloadProtoc

cleanup


echo "Protoc version: $(protoc --version)"
}

install

echo "${SCRIPT_NAME} done."
4 changes: 4 additions & 0 deletions .github/workflows/precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install protoc
run: .github/scripts/install_protoc.sh
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Decrypt parameters.py
Expand All @@ -291,6 +293,8 @@ jobs:
run: |
"TZ=EST" >> $env:GITHUB_ENV
echo "TZ=EST" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: protoc
run: python -m tox -e proto
- name: Run tests
# TODO: SNOW-1763186 use pytest marker to test multiple TZs
run: TZ=EST python -m tox -e "py${PYTHON_VERSION/\./}-ast"
Expand Down
Loading

0 comments on commit a270e65

Please sign in to comment.