Skip to content

Commit

Permalink
Merge pull request #1605 from anyproto/go-3980-searching-for-anything…
Browse files Browse the repository at this point in the history
…-causes-anytypehelper-to-crash-chat

GO-3980 Fix tantivy crash on linuxes
  • Loading branch information
fat-fellow authored Sep 24, 2024
2 parents bab8279 + 7609e91 commit a891851
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 154 deletions.
162 changes: 20 additions & 142 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,15 @@ jobs:
echo GOPATH=$(go env GOPATH) >> $GITHUB_ENV
echo GOBIN=$(go env GOPATH)/bin >> $GITHUB_ENV
echo $(go env GOPATH)/bin >> $GITHUB_PATH
- name: Install patched gox
run: |
mkdir -p "$GOPATH/src/github.com/mitchellh"
cd "$GOPATH/src/github.com/mitchellh"
git clone /~https://github.com/aslakhellesoy/gox
cd gox
git fetch
git checkout db6184738b77fbd5089e5fa1112177f391c91b24
go install github.com/mitchellh/gox
if: github.event.inputs.run-on-runner != 'ARM64' && github.event_name != 'schedule'
- name: Install brew and node deps
run: |
curl https://raw.githubusercontent.com/Homebrew/homebrew-core/31b24d65a7210ea0a5689d5ad00dd8d1bf5211db/Formula/protobuf.rb --output protobuf.rb
curl https://raw.githubusercontent.com/Homebrew/homebrew-core/d600b1f7119f6e6a4e97fb83233b313b0468b7e4/Formula/s/swift-protobuf.rb --output swift-protobuf.rb
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install ./protobuf.rb
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install --ignore-dependencies ./swift-protobuf.rb
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install mingw-w64
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install grpcurl
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install mingw-w64
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install grpcurl
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew tap messense/macos-cross-toolchains && brew install x86_64-unknown-linux-musl
npm i -g node-gyp
if: github.event.inputs.run-on-runner != 'ARM64' && github.event_name != 'schedule'
- name: Checkout
Expand Down Expand Up @@ -116,18 +107,18 @@ jobs:
make setup-go
make setup-gomobile
which gomobile
- name: Cross-compile library mac/win
- name: Cross-compile library mac/win/linux
run: |
make download-tantivy-all
echo $FLAGS
mkdir -p .release
echo $SDKROOT
gox -cgo -ldflags="$FLAGS" -osarch="darwin/amd64" --tags="envproduction nographviz nowatchdog nosigar nomutexdeadlockdetector" -output="{{.OS}}-{{.Arch}}" github.com/anyproto/anytype-heart/cmd/grpcserver
GOOS="darwin" GOARCH="amd64" CGO_ENABLED="1" go build -tags="envproduction nographviz nowatchdog nosigar nomutexdeadlockdetector" -ldflags="$FLAGS" -o darwin-amd64 github.com/anyproto/anytype-heart/cmd/grpcserver
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
echo $SDKROOT
gox -cgo -ldflags="$FLAGS" -osarch="darwin/arm64" --tags="envproduction nographviz nowatchdog nosigar nomutexdeadlockdetector" -output="{{.OS}}-{{.Arch}}" github.com/anyproto/anytype-heart/cmd/grpcserver
make protos-server
CC="x86_64-w64-mingw32-gcc" CXX="x86_64-w64-mingw32-g++" gox -cgo -ldflags="$FLAGS -linkmode external -extldflags=-static" -osarch="windows/amd64" --tags="envproduction nographviz nowatchdog nosigar nomutexdeadlockdetector noheic" -output="{{.OS}}-{{.Arch}}" github.com/anyproto/anytype-heart/cmd/grpcserver
GOOS="darwin" GOARCH="arm64" CGO_ENABLED="1" go build -tags="envproduction nographviz nowatchdog nosigar nomutexdeadlockdetector" -ldflags="$FLAGS" -o darwin-arm64 github.com/anyproto/anytype-heart/cmd/grpcserver
GOOS="windows" GOARCH="amd64" CGO_ENABLED="1" CC="x86_64-w64-mingw32-gcc" CXX="x86_64-w64-mingw32-g++" go build -tags="envproduction nographviz nowatchdog nosigar nomutexdeadlockdetector noheic" -ldflags="$FLAGS -linkmode external -extldflags=-static" -o windows-amd64 github.com/anyproto/anytype-heart/cmd/grpcserver
GOOS="linux" GOARCH="amd64" CGO_ENABLED="1" CC="x86_64-linux-musl-gcc" go build -tags="envproduction nographviz nowatchdog nosigar nomutexdeadlockdetector noheic" -ldflags="$FLAGS -linkmode external -extldflags=-static" -o linux-amd64 github.com/anyproto/anytype-heart/cmd/grpcserver
ls -lha .
- name: run perf tests
run: |
Expand Down Expand Up @@ -199,6 +190,17 @@ jobs:
mv js_${VERSION}_${OSARCH}.tar.gz .release/
done
if: github.event_name == 'push'
- name: Pack server unix
run: |
declare -a arr=("linux-amd64")
for i in "${arr[@]}"
do
OSARCH=${i%.*}
cp ./${i}* ./grpc-server
tar -czf js_${VERSION}_${OSARCH}.tar.gz grpc-server protobuf json
mv js_${VERSION}_${OSARCH}.tar.gz .release/
done
if: github.event_name == 'push'
- name: Make swift protos
run: |
mkdir -p .release
Expand Down Expand Up @@ -271,128 +273,4 @@ jobs:
fail_on_unmatched_files: true
files: '.release/*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build_linux:
if: github.event_name == 'push'
runs-on: ubuntu-22.04
steps:
- name: Install Go
uses: actions/setup-go@v1
with:
go-version: 1.22
- name: Setup GO
run: |
echo GOPATH=$(go env GOPATH) >> $GITHUB_ENV
echo GOBIN=$(go env GOPATH)/bin >> $GITHUB_ENV
echo $(go env GOPATH)/bin >> $GITHUB_PATH
- name: Setup license repositor
uses: actions/checkout@master
with:
repository: anyproto/open
ref: refs/heads/main
path: ./open

- name: Check licenses
run: |
cd open
python3 tools/generate.py --platform golang
cd ..
sudo gem install license_finder
license_finder inherited_decisions add open/decisions.yml
license_finder --enabled-package-managers gomodules
- name: Install patched gox
run: |
rm -rf $GOPATH/src/github.com/mitchellh
mkdir -p $GOPATH/src/github.com/mitchellh
cd $GOPATH/src/github.com/mitchellh
git clone /~https://github.com/aslakhellesoy/gox
cd gox
git fetch
git checkout db6184738b77fbd5089e5fa1112177f391c91b24
go install github.com/mitchellh/gox
- name: Apt install and node deps
run: |
sudo apt update
sudo apt install -y protobuf-compiler libprotoc-dev
curl -O https://pub-c60a000d68b544109df4fe5837762101.r2.dev/linux-compiler-musl-x86.zip
unzip linux-compiler-musl-x86.zip -d $HOME
npm i -g node-gyp
- name: Checkout
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go-version }}-
- name: Set env vars
env:
UNSPLASH_KEY: ${{ secrets.UNSPLASH_KEY }}
INHOUSE_KEY: ${{ secrets.INHOUSE_KEY }}
run: |
GIT_SUMMARY=$(git describe --tags --always)
echo GOPRIVATE=github.com/anyproto >> $GITHUB_ENV
echo "FLAGS=-X github.com/anyproto/anytype-heart/util/vcs.GitSummary=${GIT_SUMMARY} -X github.com/anyproto/anytype-heart/metrics.DefaultInHouseKey=${INHOUSE_KEY} -X github.com/anyproto/anytype-heart/util/unsplash.DefaultToken=${UNSPLASH_KEY}" >> $GITHUB_ENV
echo VERSION=${GITHUB_REF##*/} >> $GITHUB_ENV
git config --global url."https://${{ secrets.ANYTYPE_PAT }}@github.com/".insteadOf "/~https://github.com/"
- name: Go mod download
run: |
go mod download
- name: install protoc
run: |
HAS_SYSTEM_PROTOBUF=false make setup-protoc
- name: setup go
run: |
make setup-go
- name: Cross-compile library for linux amd64/arm64
run: |
make download-tantivy-all
echo $FLAGS
mkdir -p .release
CXX=$HOME/linux-compiler-musl-x86/bin/x86_64-linux-musl-g++ CC=$HOME/linux-compiler-musl-x86/bin/x86_64-linux-musl-gcc gox -cgo -osarch="linux/amd64" -ldflags="$FLAGS -linkmode external -extldflags=-static" --tags="envproduction nographviz nowatchdog nosigar nomutexdeadlockdetector" -output="{{.OS}}-{{.Arch}}" github.com/anyproto/anytype-heart/cmd/grpcserver
make protos-server
- name: Make JS protos
run: |
make protos-js
mv dist/js/pb protobuf
mkdir -p protobuf/protos
cp pb/protos/*.proto ./protobuf/protos
cp pb/protos/service/*.proto ./protobuf/protos
cp pkg/lib/pb/model/protos/*.proto ./protobuf/protos
- name: Add system relations
run: |
mkdir -p json/
cp pkg/lib/bundle/systemRelations.json ./json
cp pkg/lib/bundle/systemTypes.json ./json
cp pkg/lib/bundle/internalRelations.json ./json
cp pkg/lib/bundle/internalTypes.json ./json
- name: Upload protobuf artifact for linux build
uses: actions/upload-artifact@v4
with:
name: libs
path: |
protobuf
if-no-files-found: error
retention-days: 1
- name: Pack server unix
run: |
declare -a arr=("linux-amd64")
for i in "${arr[@]}"
do
OSARCH=${i%.*}
cp ./${i}* ./grpc-server
tar -czf js_${VERSION}_${OSARCH}.tar.gz grpc-server protobuf json
mv js_${VERSION}_${OSARCH}.tar.gz .release/
done
- name: Release
if: github.event_name == 'push'
uses: softprops/action-gh-release@v1
with:
prerelease: ${{ contains(github.ref, '-rc') }}
fail_on_unmatched_files: true
files: '.release/*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ endif
### Tantivy Section

REPO := anyproto/tantivy-go
VERSION := v0.1.0
VERSION := v0.1.1
OUTPUT_DIR := deps/libs
SHA_FILE = tantivity_sha256.txt

Expand Down
22 changes: 11 additions & 11 deletions tantivity_sha256.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
7a472fd61b7c32b1aecc130a0d65a0b1e36f404c97144b2dc993c7bfe628ea6b deps/libs/android-386.tar.gz
7c3902588b98d6c4951124b8ded78b956448483a057c03e7ef85cb05182a7afd deps/libs/android-amd64.tar.gz
f12a6a9b2904a67a7cec36863a65dc128b8efd9c6968db29bb7904ca79040381 deps/libs/android-arm.tar.gz
d15a085afb2887a839697080101772525b614667924c5df98aa212ae3d72a825 deps/libs/android-arm64.tar.gz
dc6eca09d7946dbf0b0fd7615be555edfc6d6f1be9a47dd757d90626a6d05c09 deps/libs/darwin-amd64.tar.gz
216a751320edb4e5e737ebeb7eb3181fbdab71f2ec4d441621ce723056a5bc03 deps/libs/darwin-arm64.tar.gz
87d629216a127eb29064cb3d1dca63ef360d1920330bfcbecf0ca78e35f37756 deps/libs/ios-amd64.tar.gz
4a82c10a149f84073af08f2cf85dce680fd3301fc7cd19279227dddd60effbcc deps/libs/ios-arm64.tar.gz
b55ecde8d30fd38ab12ffe2d51415b2c7a74ff5af7b61cd35c401345a33a482d deps/libs/ios-arm64-sim.tar.gz
a514c9e61dd8e6fea7c5236cf359ffd14bc2fd5db52fc1ca8b0e3df10a00cbcd deps/libs/linux-amd64-musl.tar.gz
3bbab5b3a28cab4306b3ced4dd0c60f06a85e01592367ccf910f3a59c7db674b deps/libs/windows-amd64.tar.gz
03ed207923dd1f17882dd7b521669a17c2fa70199ed19a5ce87e93c23e627d95 deps/libs/android-386.tar.gz
0f9cc0190fa412dae498f790ff0629b9c5d3f4531095a9b2b756d295d483b173 deps/libs/android-amd64.tar.gz
8da9dd9060d02811c774f913d1b165f354d045b1237ff05aa5daab841a096481 deps/libs/android-arm.tar.gz
9b6c9973af588d984b214619fdc56dfc463b622bc933cd95fd0278e6f23bf63c deps/libs/android-arm64.tar.gz
eb3354937db4ec79a3586b06e0db0e474b5fdeb54fd4cf0b0b8f15f7167112aa deps/libs/darwin-amd64.tar.gz
abc15c4db91dc854461b3bc0665ab5221aa63694263c322d2833170ada279e7a deps/libs/darwin-arm64.tar.gz
1d93858fe723b24eda7c1ebaf2f5e191513125dc97a89282ae5c607bd4245c1b deps/libs/ios-amd64.tar.gz
4c5256eee402fa7d73c9db5d407ff76227cf144caca0504a4c051db18af67dc0 deps/libs/ios-arm64.tar.gz
7984768b08c8873b959b180d21aeccb4b4641d89f5980673c64ec5fa833a48e1 deps/libs/ios-arm64-sim.tar.gz
727643dab7d31ce3b08de4b9d85265a6dd9939e7323e6310457d0a8355791dcc deps/libs/linux-amd64-musl.tar.gz
628f3d449505f560a60885e46c40f16a6fa63d3ce98133e7ddce05176bbd3444 deps/libs/windows-amd64.tar.gz

0 comments on commit a891851

Please sign in to comment.