Skip to content

Commit

Permalink
Merge pull request #17 from jingchen2222/faet/release-zetasql-linux-p…
Browse files Browse the repository at this point in the history
…ackage

Faet/release zetasql linux package
  • Loading branch information
jingchen2222 authored May 26, 2021
2 parents 80f848c + 17157ab commit ff791b6
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 73 deletions.
141 changes: 99 additions & 42 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ on:

env:
target: '//zetasql/parser/...'
build_argv: ''
build_argv: '--features=-supports_dynamic_linker '

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
linux-build:
debian-build:
runs-on: ubuntu-latest
container: 'debian:buster'
timeout-minutes: 120
Expand Down Expand Up @@ -65,36 +65,6 @@ jobs:
run: |
bazel test ${{ env.build_argv }} --test_summary=detailed ${{ env.target }}
mac-build:
runs-on: macos-latest
timeout-minutes: 120
env:
build_argv: '--features=-supports_dynamic_linker '
bazel_version: '3.7.2'
steps:
- uses: actions/checkout@v2

- name: update bazel version
run: echo ${{ env.bazel_version }} > .bazelversion

- name: install bazelisk
run: |
brew install bazelisk
- name: print toolchain info
run: |
gcc -v
g++ -v
python -V
java -version
- name: build
run: |
bazel build ${{ env.build_argv }} ${{ env.target }}
- name: test
run: |
bazel test ${{ env.build_argv }} --test_summary=detailed ${{ env.target }}
centos7-build:
strategy:
Expand Down Expand Up @@ -146,17 +116,15 @@ jobs:
source /opt/rh/rh-python38/enable
bazel test ${{ env.build_argv }} --test_summary=detailed --test_output=errors ${{ env.target }}
release:
linux-build:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
container:
image: ghcr.io/aceforeverd/hybridsql-base:0.0.8
env:
BAZEL_LINKOPTS: '-static-libstdc++:-lm'
BAZEL_LINKLIBS: '-l%:libstdc++.a'
target: '//zetasql/...'
build_argv: ''
build_argv: '--features=-supports_dynamic_linker '
steps:
- uses: actions/checkout@v2
- name: Setup Bazel
Expand All @@ -167,32 +135,121 @@ jobs:
run: |
yum install -y java-1.8.0-openjdk-devel
- name: build zetasql
- name: build zetasql parser
run: |
source /opt/rh/devtoolset-8/enable
source /opt/rh/rh-python38/enable
bazel build ${{ env.build_argv }} ${{ env.target }}
- name: Find Orphan Library
bazel build ${{ env.target }} ${{ env.build_argv }}
- name: Test
run: |
./find_orphan_so.sh
bazel test ${{ env.build_argv }} --test_summary=detailed ${{ env.target }}
- name: build zetasql parser dependencies
if: ${{ github.event_name == 'push' }}
run: |
bazel query 'deps(${{ env.target }})' |grep //zetasql|xargs bazel build ${{ env.build_argv }}
bazel build "@com_googleapis_googleapis//:all" ${{ env.build_argv }}
bazel build "@com_google_file_based_test_driver//file_based_test_driver:all" ${{ env.build_argv }}
bazel build "@com_googlesource_code_re2//:re2" ${{ env.build_argv }}
- name: Determine Version
if: ${{ github.event_name == 'push' }}
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
VERSION=$(echo $VERSION | sed -e 's/^v//')
echo "TAG=$VERSION" >> $GITHUB_ENV
- name: pack libzetasql
if: ${{ github.event_name == 'push' }}
run: |
./pack_zetasql.sh
env:
TAG: ${{ env.TAG }}

- name: Upload Artifacts
if: ${{ github.event_name == 'push' }}
uses: actions/upload-artifact@v2
with:
path: libzetasql-*.tar.gz
name: release-artifacts

macos-build:
runs-on: macos-latest
timeout-minutes: 120
env:
build_argv: '--features=-supports_dynamic_linker '
bazel_version: '3.7.2'
steps:
- uses: actions/checkout@v2

- name: update bazel version
run: echo ${{ env.bazel_version }} > .bazelversion

- name: install bazelisk
run: |
brew install bazelisk
- name: install utils tools
run: |
brew install coreutils
brew install binutils
- name: print toolchain info
run: |
gcc -v
g++ -v
python -V
java -version
- name: build
run: |
bazel build ${{ env.build_argv }} ${{ env.target }}
bazel build "@com_googleapis_googleapis//:all" ${{ env.build_argv }}
bazel build "@com_google_file_based_test_driver//file_based_test_driver:all" ${{ env.build_argv }}
bazel build "@com_googlesource_code_re2//:re2" ${{ env.build_argv }}
- name: test
run: |
bazel test ${{ env.build_argv }} --test_summary=detailed ${{ env.target }}
- name: Determine Version
if: ${{ github.event_name == 'push' }}
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
VERSION=$(echo $VERSION | sed -e 's/^v//')
echo "TAG=$VERSION" >> $GITHUB_ENV
- name: pack libzetasql
if: ${{ github.event_name == 'push' }}
run: |
./pack_zetasql.sh
env:
TAG: ${{ env.TAG }}

- name: Upload Artifacts
if: ${{ github.event_name == 'push' }}
uses: actions/upload-artifact@v2
with:
path: libzetasql-*.tar.gz
name: release-artifacts

release:
runs-on: ubuntu-latest
needs: ["linux-build", "macos-build"]
if: startsWith(github.ref, 'refs/tags/v')
timeout-minutes: 120
steps:
- name: Download Release Artifacts
uses: actions/download-artifact@v2
with:
name: release-artifacts

- name: Release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: softprops/action-gh-release@v1
with:
files: |
libzetasql-*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

103 changes: 76 additions & 27 deletions pack_zetasql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,75 +7,124 @@ set -eE
cd "$(dirname "$0")"
VERSION=${TAG:-$(git rev-parse --short HEAD)}
export ROOT=$(pwd)
export PREFIX="$ROOT/libzetasql-$VERSION"
export ZETASQL_LIB_NAME="libzetasql-$VERSION"
export PREFIX="$ROOT/${ZETASQL_LIB_NAME}"

rm -rf tmp-lib libzetasql.mri
rm -rf tmp-lib libzetasql.mri ${PREFIX}
mkdir -p tmp-lib
mkdir -p ${PREFIX}
mkdir -p ${PREFIX}/lib

install_lib() {
local file
file=$1
local libname
libname=lib$(echo "$file" | tr '/' '_' | sed -e 's/lib//')
install -D "$file" "$ROOT/tmp-lib/$libname"

if [[ "$OSTYPE" == "linux-gnu"* ]]
then
INSTALL_BIN="install"
else
INSTALL_BIN="ginstall"
fi
${INSTALL_BIN} -D "$file" "$ROOT/tmp-lib/$libname"
}

install_gen_include_file() {
local file
file=$1
local outfile
outfile=$(echo "$file" | sed -e 's/^.*proto\///')
install -D "$file" "$PREFIX/include/$outfile"

if [[ "$OSTYPE" == "linux-gnu"* ]]
then
INSTALL_BIN="install"
else
INSTALL_BIN="ginstall"
fi
${INSTALL_BIN} -D "$file" "$PREFIX/include/$outfile"
}

install_external_lib() {
local file
file=$1
local libname
libname=$(basename "$file")
install -D "$file" "$PREFIX/lib/$libname"
if [[ "$OSTYPE" == "linux-gnu"* ]]
then
INSTALL_BIN="install"
else
INSTALL_BIN="ginstall"
fi
${INSTALL_BIN} -D "$file" "$PREFIX/lib/$libname"
}

export -f install_gen_include_file
export -f install_lib
export -f install_external_lib


if [[ "$OSTYPE" == "linux-gnu"* ]]
then
INSTALL_BIN="install"
else
INSTALL_BIN="ginstall"
fi

pushd bazel-bin/
# exlucde test so
find zetasql -maxdepth 4 -type f -iname '*.so' -exec bash -c 'install_lib $0' {} \;
find zetasql -type f -iname '*.a' -exec bash -c 'install_lib $0' {} \;

# external lib headers
pushd "$(realpath .)/../../../../../external/com_googlesource_code_re2"
find re2 -iname "*.h" -exec install -D {} "$PREFIX"/include/{} \;
find re2 -iname "*.h" -exec ${INSTALL_BIN} -D {} "$PREFIX"/include/{} \;
popd

pushd "$(realpath .)/../../../../../external/com_googleapis_googleapis"
find google -iname "*.h" -exec ${INSTALL_BIN} -D {} "$PREFIX"/include/{} \;
popd

pushd "$(realpath .)/../../../../../external/com_google_file_based_test_driver"
find file_based_test_driver -iname "*.h" -exec ${INSTALL_BIN} -D {} "$PREFIX"/include/{} \;
popd

# external lib
pushd external
find icu -type f -iregex ".*/.*\.\(so\|a\)\$" -exec bash -c 'install_external_lib $0' {} \;
find com_googlesource_code_re2 -type f -iregex ".*/.*\.\(so\|a\)\$" -exec bash -c 'install_external_lib $0' {} \;
find com_googleapis_googleapis -type f -iname '*.so' -exec bash -c 'install_external_lib $0' {} \;

find icu -type f -iname '*.a' -exec bash -c 'install_external_lib $0' {} \;
find com_googlesource_code_re2 -type f -iname '*.a' -exec bash -c 'install_external_lib $0' {} \;
find com_googleapis_googleapis -type f -iname '*.a' -exec bash -c 'install_external_lib $0' {} \;
find com_google_file_based_test_driver -type f -iname '*.a' -exec bash -c 'install_external_lib $0' {} \;

popd

# zetasql generated files: protobuf & template generated files
find zetasql -type f -iname "*.h" -exec install -D {} "$PREFIX"/include/{} \;
find zetasql -type f -iname "*.h" -exec ${INSTALL_BIN} -D {} "$PREFIX"/include/{} \;
find zetasql -iregex ".*/_virtual_includes/.*\.h\$" -exec bash -c 'install_gen_include_file $0' {} \;
popd # bazel-bin

# header files from source
find zetasql -type f -iname "*.h" -exec install -D {} "$PREFIX"/include/{} \;


echo 'create libzetasql.a' >> libzetasql.mri
find tmp-lib/ -iname "*.a" -type f -exec bash -c 'echo "addlib $0" >> libzetasql.mri' {} \;
echo "save" >> libzetasql.mri
echo "end" >> libzetasql.mri

ar -M <libzetasql.mri
ranlib libzetasql.a
mv libzetasql.a "$PREFIX/lib"
mv tmp-lib/*.so "$PREFIX/lib"


tar czf "libzetasql-$VERSION.tar.gz" "libzetasql-$VERSION"/
find zetasql -type f -iname "*.h" -exec ${INSTALL_BIN} -D {} "$PREFIX"/include/{} \;


if [[ "$OSTYPE" == "linux-gnu"* ]]
then
echo 'create libzetasql.a' >> libzetasql.mri
find tmp-lib/ -iname "*.a" -type f -exec bash -c 'echo "addlib $0" >> libzetasql.mri' {} \;
echo "save" >> libzetasql.mri
echo "end" >> libzetasql.mri

ar -M <libzetasql.mri
ranlib libzetasql.a
mv libzetasql.a "$PREFIX/lib/"
else
libtool -static -o libzetasql.a tmp-lib/*.a
mv libzetasql.a "$PREFIX/lib"
fi
echo "ls zetasqllib"
ls "${PREFIX}/lib"
if [[ "$OSTYPE" == "linux-gnu"* ]]
then
tar czf "${ZETASQL_LIB_NAME}-linux-x86_64.tar.gz" "${ZETASQL_LIB_NAME}"/
else
tar czf "${ZETASQL_LIB_NAME}-darwin-x86_64.tar.gz" "${ZETASQL_LIB_NAME}"/
fi
5 changes: 1 addition & 4 deletions zetasql/parser/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,7 @@ genyacc(

[gen_parser_test(
filename = f.split("/")[-1],
srcs = select({
"@bazel_tools//src/conditions:darwin": ["run_parser_test.cc"],
"//conditions:default": [],
}),
srcs = ["run_parser_test.cc"],
) for f in glob(["testdata/*.test"])]

bzl_library(
Expand Down

0 comments on commit ff791b6

Please sign in to comment.