Skip to content

Commit

Permalink
Import existing codebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
badmonster0 committed Mar 3, 2025
1 parent 278d74e commit 87bf611
Show file tree
Hide file tree
Showing 120 changed files with 40,370 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .env.lib_debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export RUST_LOG=warn,cocoindex_engine=trace,tower_http=trace
export RUST_BACKTRACE=1

export COCOINDEX_SERVER_CORS_ORIGIN=http://localhost:3000
22 changes: 22 additions & 0 deletions .github/scripts/update_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash -e

# Extract version from tag (e.g. refs/tags/v1.2.3 -> 1.2.3)
if [[ ! "$GITHUB_REF" =~ ^refs/tags/v ]]; then
echo "No version tag found"
exit 0
fi
VERSION="${GITHUB_REF#refs/tags/v}"

echo "Building release version: $VERSION"

# Detect OS and set sed inline flag accordingly.
if [[ "$(uname)" == "Darwin" ]]; then
# macOS/BSD sed requires an empty string as backup extension
SED_INLINE=(-i '')
else
# GNU sed on Linux can use -i without a backup extension
SED_INLINE=(-i)
fi

# Update Cargo.toml
sed "${SED_INLINE[@]}" "s/^version = .*/version = \"$VERSION\"/" Cargo.toml
45 changes: 45 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This file is autogenerated by maturin v1.8.1
# To update, run
#
# maturin generate-ci github
#
name: CI

on:
pull_request:
branches: [main]
paths:
- src/**
- python/**
- "*.toml"
push:
branches: [main]
paths:
- src/**
- python/**
- "*.toml"
workflow_dispatch:

permissions:
contents: read

jobs:
build:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- { os: linux, runner: ubuntu-22.04, target: aarch64 }
- { os: macos, runner: macos-14, target: aarch64 }
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
manylinux: auto
67 changes: 67 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: docs

on:
pull_request:
branches: [main]
paths:
- docs/**
push:
branches: [main]
paths:
- docs/**
workflow_dispatch:

permissions:
contents: write

jobs:
test-deploy:
if: github.event_name != 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
sparse-checkout: docs
path: src-staging
- name: Move docs
run: |
shopt -s dotglob
mv src-staging/docs/* .
- uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Test build website
run: yarn build

deploy:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
sparse-checkout: docs
path: src-staging
- name: Move docs
run: |
shopt -s dotglob
mv src-staging/docs/* .
- uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn
- uses: webfactory/ssh-agent@v0.5.0
with:
ssh-private-key: ${{ secrets.GH_PAGES_DEPLOY }}
- name: Deploy to GitHub Pages
env:
USE_SSH: true
run: |
git config --global user.email "cocoindex.io@gmail.com"
git config --global user.name "CocoIndex"
yarn install --frozen-lockfile
yarn deploy
112 changes: 112 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# This file is autogenerated by maturin v1.8.1
# To update, run
#
# maturin generate-ci github
#
name: release

on:
push:
tags:
- 'v*'
workflow_dispatch:

permissions:
contents: read

jobs:
create-versioned-toml:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: ./.github/scripts/update_version.sh
- uses: actions/upload-artifact@v4
with:
name: Cargo.toml
path: Cargo.toml

build:
runs-on: ${{ matrix.platform.runner }}
needs: [create-versioned-toml]
strategy:
matrix:
platform:
- { os: linux, runner: ubuntu-22.04, target: x86_64 }
- { os: linux, runner: ubuntu-22.04, target: aarch64 }
- { os: linux, runner: ubuntu-22.04, target: armv7 }
- { os: musllinux, runner: ubuntu-22.04, target: x86_64 }
- { os: musllinux, runner: ubuntu-22.04, target: aarch64 }
- { os: musllinux, runner: ubuntu-22.04, target: armv7 }
- { os: windows, runner: windows-latest, target: x64 }
- { os: macos, runner: macos-13, target: x86_64 }
- { os: macos, runner: macos-14, target: aarch64 }
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: Cargo.toml
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.platform.os }}-${{ matrix.platform.target }}
path: dist

sdist:
runs-on: ubuntu-latest
needs: [create-versioned-toml]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: Cargo.toml
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: dist

release:
name: Release
runs-on: ubuntu-latest
needs: [create-versioned-toml, build, sdist]
permissions:
# Use to sign the release artifacts
id-token: write
# Used to upload release artifacts
contents: write
# Used to generate artifact attestation
attestations: write
environment: release
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: Cargo.toml
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-path: 'wheels-*/*'
- name: Publish to PyPI
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: PyO3/maturin-action@v1
with:
command: upload
args: --non-interactive --skip-existing wheels-*/*
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/target

# Byte-compiled / optimized / DLL files
__pycache__/
.pytest_cache/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.venv/
dist/

.DS_Store

# Lock files for dependencies should be ignored for library
/Cargo.lock

*.egg-info/
37 changes: 37 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "cocoindex"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "cocoindex_engine"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.23.4" }
anyhow = { version = "1.0.95", features = ["std"] }
async-trait = "0.1.85"
axum = "0.7.9"
axum-extra = { version = "0.9.6", features = ["query"] }
base64 = "0.22.1"
chrono = "0.4.39"
config = "0.14.1"
const_format = "0.2.34"
env_logger = "0.11.6"
futures = "0.3.31"
log = "0.4.25"
regex = "1.11.1"
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.137"
sqlx = { version = "0.8.3", features = ["chrono", "postgres", "runtime-tokio"] }
tokio = { version = "1.43.0", features = ["macros", "rt-multi-thread"] }
tower = "0.5.2"
tower-http = { version = "0.6.2", features = ["cors", "trace"] }
indexmap = { version = "2.7.1", features = ["serde"] }
blake2 = "0.10.6"
pgvector = { version = "0.4.0", features = ["sqlx"] }
blocking = "1.6.1"
indenter = "0.3.3"
itertools = "0.14.0"
derivative = "2.2.0"
Loading

0 comments on commit 87bf611

Please sign in to comment.