Skip to content

Commit

Permalink
feat: move extension to open source
Browse files Browse the repository at this point in the history
  • Loading branch information
louisjoecodes committed May 6, 2024
1 parent d5e2f38 commit f51a9f1
Show file tree
Hide file tree
Showing 221 changed files with 50,805 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
proto/gen linguist-generated=true
js/packages/proto/src/generated linguist-generated=true
cargo.lock linguist-generated=true
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
version: 2
updates:
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'weekly'
- package-ecosystem: 'cargo'
directory: '/'
schedule:
Expand Down
98 changes: 97 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,85 @@ jobs:
run: go install github.com/sethvargo/ratchet@latest
- name: Ratchet Check
run: make ratchet_check
commitlint-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # ratchet:actions/checkout@v3
with:
fetch-depth: '0'
- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # ratchet:actions/setup-node@v3
- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # ratchet:pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- name: Install dependencies
run: pnpm install --filter "@quary/root"
- name: Validate all commits from PR
run: pnpx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
node-check:
runs-on: ubicloud-standard-16
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # ratchet:actions/checkout@v3
with:
submodules: 'true'
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # ratchet:actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown
override: true
profile: minimal
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # ratchet:Swatinem/rust-cache@v2
- name: Install buf
run: BIN="/usr/local/bin" && VERSION="1.31.0" && curl -sSL "https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-$(uname -s)-$(uname -m)" -o "${BIN}/buf" && chmod +x "${BIN}/buf"
- run: make proto
- uses: taiki-e/cache-cargo-install-action@5b024fe3a0a2c7f2aaff0e47871acf0d14b07207 # ratchet:taiki-e/cache-cargo-install-action@v1
with:
tool: wasm-bindgen-cli
- name: Build rust wasm
run: make rust_build_wasm
- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # ratchet:actions/setup-node@v3
- name: Install pnpm
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # ratchet:pnpm/action-setup@v2
with:
version: 8
- name: Install dependencies
run: pnpm install -r
- name: Run CI tests
run: pnpm run ci
bash-scripts-check:
runs-on: ubuntu-latest
env:
PLAYWRIGHT_SKIP_DOWNLOAD_BROWSER: true
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # ratchet:actions/checkout@v3
# Comes from https://github.com/ludeeus/action-shellcheck/blob/master/action.yaml
- name: Download shellcheck
run: sudo apt-get install -y shellcheck
- name: Check shells
run: make bash_lint
rust-compile:
name: Rust Compile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # ratchet:actions/checkout@v3
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # ratchet:actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@35cdeaf60df48fb1fb7eac25fea4ebde1f72fc46 # ratchet:Homebrew/actions/setup-homebrew@master
- name: Install buf
run: brew install bufbuild/buf/buf
- run: make proto
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # ratchet:Swatinem/rust-cache@v2
- uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # ratchet:actions-rs/cargo@v1
with:
command: check
rust-lint:
name: Rust Lint
runs-on: ubuntu-latest
Expand Down Expand Up @@ -116,10 +195,27 @@ jobs:
run: pip install sqlfluff
- name: Lint template
run: make sql_lint_template
check-versions-match:
name: Check versions match
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # ratchet:actions/checkout@v3
- name: Install jq
run: sudo apt-get install jq
- run: make check_versions_match
prettier-yaml-lint:
name: Prettier YAML Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # ratchet:actions/checkout@v4
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # ratchet:actions/setup-node@v4
- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # ratchet:actions/setup-node@v3
- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # ratchet:pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- name: Install dependencies
run: pnpm install --filter "@quary/root"
- run: make prettier_lint
59 changes: 59 additions & 0 deletions .github/workflows/release-vsix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Release VSIX Workflow
on:
release:
types: [published]
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
CARGO_INCREMENTAL: 0
jobs:
check-versions-match:
name: Check versions match
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # ratchet:actions/checkout@v3
with:
submodules: 'true'
- name: Install jq
run: sudo apt-get install jq
- run: make check_versions_match
upload-vsix-release:
name: Upload VSIX Release
runs-on: ubuntu-latest
needs:
- check-versions-match
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # ratchet:actions/checkout@v3
with:
submodules: 'true'
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # ratchet:actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown
override: true
profile: minimal
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # ratchet:Swatinem/rust-cache@v2
- uses: taiki-e/cache-cargo-install-action@5b024fe3a0a2c7f2aaff0e47871acf0d14b07207 # ratchet:taiki-e/cache-cargo-install-action@v1
with:
tool: wasm-bindgen-cli
- name: Install buf
run: BIN="/usr/local/bin" && VERSION="1.31.0" && curl -sSL "https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-$(uname -s)-$(uname -m)" -o "${BIN}/buf" && chmod +x "${BIN}/buf"
- run: make proto
- name: Build rust wasm
run: make rust_build_wasm
- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # ratchet:actions/setup-node@v3
- name: Install pnpm
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # ratchet:pnpm/action-setup@v2
with:
version: 8
- name: Install dependencies
run: pnpm install -r
- name: Build extension
run: pnpm run build_extension
- name: Upload Release Asset
uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 # ratchet:softprops/action-gh-release@v2.0.4
with:
files: ./js/packages/quary-extension/quary-*.vsix
- run: pnpx vsce publish --packagePath $(find ./js/packages/quary-extension/quary-*.vsix)
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
37 changes: 37 additions & 0 deletions .github/workflows/rust-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: rust-lint
on:
pull_request:
paths:
- 'rust/**'
merge_group:
push:
branches:
- main
jobs:
rust-lint:
name: Rust Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # ratchet:actions/checkout@v3
with:
submodules: 'true'
- name: Install stable toolchain
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # ratchet:actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: wasm32-unknown-unknown
override: true
components: rustfmt, clippy
- name: Install buf
run: BIN="/usr/local/bin" && VERSION="1.31.0" && curl -sSL "https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-$(uname -s)-$(uname -m)" -o "${BIN}/buf" && chmod +x "${BIN}/buf"
- run: make proto
- name: Run cargo fmt
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # ratchet:actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Run clippy
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # ratchet:actions-rs/cargo@v1
with:
command: clippy
27 changes: 27 additions & 0 deletions .hacking/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM --platform=$BUILDPLATFORM golang:alpine AS build
ARG TARGETPLATFORM
ARG BUILDPLATFORM

# Set the working directory
WORKDIR /app

RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" > /log

# Download binary
RUN wget https://github.com/quarylabs/quary/releases/download/0.0.102/quary-0.0.102-quary-linux-aarch64-gnu.zip

# Install unzip
RUN apk add --no-cache unzip
# Unzip binary
RUN unzip /app/quary-0.0.102-quary-linux-aarch64-gnu.zip

RUN ls -la

FROM --platform=$BUILDPLATFORM alpine

WORKDIR /app

COPY --from=build /app/quary /app/quary

# Set the binary as the entrypoint
ENTRYPOINT ["quary"]
66 changes: 66 additions & 0 deletions .hacking/project_scripts/materialize_all_to_tables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

# This script materializes all models in a Quary project to TABLE
# Usage: python .hacking/project_scripts/materialize_all_to_tables.py <target_directory i.e. ../models>

import os
import yaml
def find_closest_schema_file(dir_path, base_path):
"""Search for the closest schema file in the parent directories."""
current_path = dir_path
while current_path != base_path:
for file in os.listdir(current_path):
if file.endswith("_models.yaml") or file == "schema.yaml":
return os.path.join(current_path, file)
parent_path = os.path.dirname(current_path)
if parent_path == current_path: # Reached the root directory
break
current_path = parent_path
return None

def create_or_update_schema_file(base_path, dir_path, model_name):
schema_file = find_closest_schema_file(dir_path, base_path)
if not schema_file:
schema_file = os.path.join(dir_path, "schema.yaml")
with open(schema_file, 'w') as f:
yaml.dump({'models': []}, f)

with open(schema_file, 'r') as f:
data = yaml.safe_load(f) or {'models': []}

model_found = False
for model in data['models']:
if model['name'] == model_name:
model['materialization'] = 'table'
model_found = True
break
if not model_found:
data['models'].append({'name': model_name, 'materialization': 'table'})

with open(schema_file, 'w') as f:
yaml.safe_dump(data, f, sort_keys=False)

def process_directory(base_path, dir_path):
if "sources" in dir_path:
return

sql_files = [f for f in os.listdir(dir_path) if os.path.isfile(os.path.join(dir_path, f)) and f.endswith('.sql')]
for sql_file in sql_files:
model_name = os.path.splitext(sql_file)[0]
create_or_update_schema_file(base_path, dir_path, model_name)

for item in os.listdir(dir_path):
full_path = os.path.join(dir_path, item)
if os.path.isdir(full_path) and not item == "sources":
process_directory(base_path, full_path)

def main(target_dir):
base_path = os.path.abspath(target_dir)
process_directory(base_path, base_path)

if __name__ == "__main__":
import sys
if len(sys.argv) != 2:
print("Usage: python script.py <target_directory>")
sys.exit(1)

main(sys.argv[1])
8 changes: 8 additions & 0 deletions .hacking/scripts/bash_lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -euxo pipefail

for f in ./.hacking/scripts/*.sh
do
shellcheck "$f"
done
40 changes: 40 additions & 0 deletions .hacking/scripts/build_for_releases.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

set -euxo pipefail

# Check if a version number is provided as an argument
if [ -z "$1" ]; then
echo "Please provide a version number as an argument."
exit 1
fi

# Set variables
version="$1"
project_name="quary"
timestamp=$(date +%Y%m%d-%H%M%S)
build_dir="build/$project_name-$timestamp"

# Create the build directory
mkdir -p "$build_dir"

# Iterate over the architectures and operating systems
archs=("amd64" "arm64")
oses=("linux" "darwin")

for arch in "${archs[@]}"; do
for os in "${oses[@]}"; do
# Set the output binary name
output_binary="$build_dir/${project_name}_${os}_${arch}_${version}"

# Build the Go binary for the specific architecture and operating system
echo "Building $project_name for $os/$arch..."
env CGO=0 GOOS="$os" GOARCH="$arch" go build -o "$output_binary" ./main.go

echo "Build successful: $output_binary"

# Compress the binary using gzip
echo "Compressing binary..."
gzip "$output_binary"
echo "Compression successful: ${output_binary}.gz"
done
done
Loading

0 comments on commit f51a9f1

Please sign in to comment.