Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config builder/15 latest #1

Open
wants to merge 4 commits into
base: 15-latest
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Test 🛠
name: Generated Build libpg-query no windows 🛠
'on':
workflow_dispatch: null
jobs:
Expand All @@ -17,10 +17,6 @@ jobs:
with:
node-version: 20.x
cache: yarn
- name: Configure Git 🛠
run: |
git config user.name "Cosmology"
git config user.email "[email protected]"
- name: Install and Build 📦
run: |
yarn
Expand Down
93 changes: 93 additions & 0 deletions .github/workflows/generated-build-and-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Generated Build libpg-query 🛠
'on':
workflow_dispatch: null
jobs:
build-artifacts:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- windows-latest
- macos-latest
- ubuntu-latest
steps:
- name: Checkout Repository 📥
uses: actions/checkout@v4
- name: Setup Node.js 🌐
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: yarn
- name: Install and Build 📦
run: |
yarn
yarn binary:build
- name: Save Artifacts For Supabase CDN 🏗
uses: actions/upload-artifact@v4
with:
name: build-supabase-artifact-${{ matrix.os }}
path: ./build/stage/libpg-query-node/
- name: Save Artifacts For NPM 🏗
uses: actions/upload-artifact@v4
with:
name: build-npm-artifact-${{ matrix.os }}
path: |
${{ matrix.os == 'macos-latest' && './libpg_query/osx/libpg_query.a' ||
matrix.os == 'ubuntu-latest' && './libpg_query/linux/libpg_query.a' ||
matrix.os == 'windows-latest' && './libpg_query/windows/pg_query.lib' }}
build-wasm:
needs: build-artifacts
runs-on: ubuntu-latest
steps:
- name: Checkout Repository 📥
uses: actions/checkout@v4
- name: Setup Node.js 🌐
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: yarn
- name: Install and Build 🚀
run: |
yarn
- name: Install Emscripten ✍🏻
run: |
sudo apt-get update
sudo apt-get install cmake python3 python3-pip
git clone --branch 3.1.59 --depth 1 https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install 3.1.59
./emsdk activate 3.1.59
source ./emsdk_env.sh
- name: Build with Emscripten 🏗
run: |
source ./emsdk/emsdk_env.sh
emmake make
emmake make build
- name: Archive production artifacts 🏛
uses: actions/upload-artifact@v4
with:
name: wasm-artifacts
path: wasm
prepare-and-publish:
needs: build-wasm
runs-on: ubuntu-latest
steps:
- name: Checkout Repository 📥
uses: actions/checkout@v4
- name: Get Artifacts 📚
uses: actions/download-artifact@v4
with:
path: downloaded-artifacts
- name: Prepare artifacts 📦
run: |
find ./downloaded-artifacts/
cp ./downloaded-artifacts/build-npm-artifact-windows-latest/pg_query.lib ./libpg_query/windows/queryparser.lib
cp ./downloaded-artifacts/build-npm-artifact-ubuntu-latest/libpg_query.a ./libpg_query/linux/libpg_query.a
cp ./downloaded-artifacts/build-npm-artifact-macos-latest/libpg_query.a ./libpg_query/osx/libpg_query.a
cp ./downloaded-artifacts/wasm-artifacts/libpg-query.js ./wasm/libpg-query.js
cp ./downloaded-artifacts/wasm-artifacts/libpg-query.wasm ./wasm/libpg-query.wasm
rm -rf ./downloaded-artifacts
- name: Log
run: |
find ./libpg_query/
find ./wasm
3 changes: 2 additions & 1 deletion .github/workflows/run-tests-linux.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Linux 🧪

on:
push:
pull_request:
types: [opened, push, reopened]
types: [opened, synchronize, reopened]
workflow_dispatch:

jobs:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/run-tests-mac.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Mac 🧪

on:
push:
pull_request:
types: [opened, push, reopened]
types: [opened, synchronize, reopened]
workflow_dispatch:

jobs:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/run-tests-win.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Windows 🛠

on:
push:
pull_request:
types: [opened, push, reopened]
types: [opened, synchronize, reopened]
workflow_dispatch:

jobs:
Expand Down
90 changes: 90 additions & 0 deletions .templates/buildAddon.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
@echo off

set LIBPG_REPO=___LIBPG_REPO___
set LIBPG_COMMIT=___LIBPG_COMMIT___
set LIBPG_BRANCH=___LIBPG_BRANCH___

:: Check if each required variable is set
if "%LIBPG_REPO%"=="" (
echo ERROR: LIBPG_REPO variable is not set.
exit /B 1
)

if "%LIBPG_COMMIT%"=="" (
echo ERROR: LIBPG_COMMIT variable is not set.
exit /B 1
)

if "%LIBPG_BRANCH%"=="" (
echo ERROR: LIBPG_BRANCH variable is not set.
exit /B 1
)

:: The environment variables must be set
echo Using repository: %LIBPG_REPO%
echo Using commit: %LIBPG_COMMIT%
echo Using branch: %LIBPG_BRANCH%

setlocal enabledelayedexpansion

rem Remember current's parent directory and create a new, unique, temporary directory
set buildDir=%cd%
set projectDir=%cd%\..
set tmpDir=%temp%\tmpdir.libpg_query
rmdir /s /q %tmpDir%
md %tmpDir%


rem Define the make target
set makeTarget=build

rem Change to the newly created temp directory
cd /D %tmpDir%


rem Clone the selected branch of the libpg_query Git repo
git clone -b %LIBPG_BRANCH% --single-branch %LIBPG_REPO%
cd libpg_query

rem Checkout the desired commit
git checkout %LIBPG_COMMIT%

rem needed if being invoked from within gyp
set MAKEFLAGS=
set MFLAGS=

rem set path with Windows Developer Command Prompt
echo "please ensure you are running at Windows Developer Command Prompt environments"
nmake /F Makefile.msvc clean
nmake /F Makefile.msvc build


rem Terminate if build fails
if %errorlevel% NEQ 0 (
echo ERROR: 'nmake' command failed
)

rem Search for pg_query.obj (libpg_query.a), error if not found
for /f "delims=" %%f in ('dir /b /s pg_query.lib') do set file=%%f
if not defined file (
echo "ERROR: pg_query.lib not found"

)

rem Error if pg_query.h is missing
for /f "delims=" %%f in ('dir /b /s pg_query.h') do set file=%%f
if not defined file (
echo "ERROR: pg_query.h not found"

)

rem Copy pg_query.lib to windows dir
copy /Y pg_query.lib "%projectDir%\libpg_query\windows\"

rem Copy header
copy /Y pg_query.h "%projectDir%\libpg_query\include\"

rem Cleanup: revert to original directory
cd /D %buildDir%

exit /B 0
84 changes: 84 additions & 0 deletions .templates/buildAddon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env bash

LIBPG_REPO=___LIBPG_REPO___
LIBPG_COMMIT=___LIBPG_COMMIT___
LIBPG_BRANCH=___LIBPG_BRANCH___

# Check if variables are set and exit if not
if [ -z "$LIBPG_COMMIT" ]; then
echo "ERROR: LIBPG_COMMIT variable is not set."
exit 1
fi

if [ -z "$LIBPG_BRANCH" ]; then
echo "ERROR: LIBPG_BRANCH variable is not set."
exit 1
fi

if [ -z "$LIBPG_REPO" ]; then
echo "ERROR: LIBPG_REPO variable is not set."
exit 1
fi

# Remember current directory and create a new, unique, temporary directory
rDIR=$(pwd)
tmpDir=$(mktemp -d 2>/dev/null || mktemp -d -t 'tmpdir.XXXX')

# Define the make target
makeTarget=build

# Change to the newly created temp directory
cd "$tmpDir"

# Clone the selected branch of the libpg_query Git repo
git clone -b $LIBPG_BRANCH --single-branch $LIBPG_REPO
cd libpg_query

# Checkout the desired commit
git checkout $LIBPG_COMMIT

# needed if being invoked from within gyp
unset MAKEFLAGS
unset MFLAGS

# Adaptively build for macOS or Linux
if [ "$(uname)" == "Darwin" ]; then
make CFLAGS='-mmacosx-version-min=10.7' PG_CFLAGS='-mmacosx-version-min=10.7' $makeTarget
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
make CFLAGS='' PG_CFLAGS='' $makeTarget
fi

# Terminate if build fails
if [ $? -ne 0 ]; then
echo "ERROR: 'make' command failed";
exit 1;
fi

# Search for libpg_query.a, error if not found
file=$(ls | grep 'libpg_query.a')
if [ ! $file ]; then
echo "ERROR: libpg_query.a not found";
exit 1;
fi

# Error if pg_query.h is missing
file=$(ls | grep 'pg_query.h')
if [ ! $file ]; then
echo "ERROR: pg_query.h not found";
exit 1;
fi

# Copy queryparser.cc, binding.gyp to current directory
if [ "$(uname)" == "Darwin" ]; then
cp $(pwd)/libpg_query.a $rDIR/libpg_query/osx/
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
cp $(pwd)/libpg_query.a $rDIR/libpg_query/linux/
fi

# Copy header
cp $(pwd)/pg_query.h $rDIR/libpg_query/include/
cp $(pwd)/protobuf/*.proto $rDIR/libpg_query/protobuf/

# Cleanup: revert to original directory and remove the temp
cd "$rDIR"
rm -rf "$tmpDir"
7 changes: 7 additions & 0 deletions .yamlize/versions/14-latest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
env:
JOB: pg-14
LIBPG_REPO: https://github.com/pganalyze/libpg_query.git
LIBPG_COMMIT: 1577ef7c6c349542149e34ffbfafc244ab942ec6
LIBPG_BRANCH: 14-latest
PGSQL_TYPES: 14.0.0
OPERATING_SYSTEMS: [linux,mac]
7 changes: 7 additions & 0 deletions .yamlize/versions/15-latest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
env:
JOB: pg-15
LIBPG_REPO: https://github.com/pganalyze/libpg_query.git
LIBPG_COMMIT: db39825bc7c1ddd45962ec6a626d740b7f8f027a
LIBPG_BRANCH: 15-latest
PGSQL_TYPES: 15.0.2
OPERATING_SYSTEMS: [linux,mac]
7 changes: 7 additions & 0 deletions .yamlize/versions/16-latest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
env:
JOB: pg-16
LIBPG_REPO: https://github.com/pganalyze/libpg_query.git
LIBPG_COMMIT: 1ec38940e5c6f09a4c1d17a46d839a881c4f2db7
LIBPG_BRANCH: 16-latest
PGSQL_TYPES: 16.0.0
OPERATING_SYSTEMS: [linux,mac,win]
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Build and Test 🛠
name: Build and Publish 🚀

on:
workflow_dispatch:

jobs:
build-artifacts:
import-yaml: yaml/build-artifacts.yaml
import-yaml: yaml/build-artifacts-no-win.yaml

build-wasm:
needs: build-artifacts
import-yaml: yaml/build-wasm.yaml

prepare-and-publish:
needs: build-wasm
import-yaml: yaml/prepare-and-log.yaml
import-yaml: yaml/prepare-and-publish-no-win.yaml
7 changes: 7 additions & 0 deletions .yamlize/workflows/yaml/artifacts/npm-no-win.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: Save Artifacts For NPM 🏗
uses: actions/upload-artifact@v4
with:
name: build-npm-artifact-${{ matrix.os }}
path: |
${{ matrix.os == 'macos-latest' && './libpg_query/osx/libpg_query.a' ||
matrix.os == 'ubuntu-latest' && './libpg_query/linux/libpg_query.a' }}
3 changes: 2 additions & 1 deletion .yamlize/workflows/yaml/artifacts/npm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ with:
name: build-npm-artifact-${{ matrix.os }}
path: |
${{ matrix.os == 'macos-latest' && './libpg_query/osx/libpg_query.a' ||
matrix.os == 'ubuntu-latest' && './libpg_query/linux/libpg_query.a' }}
matrix.os == 'ubuntu-latest' && './libpg_query/linux/libpg_query.a' ||
matrix.os == 'windows-latest' && './libpg_query/windows/pg_query.lib' }}
8 changes: 8 additions & 0 deletions .yamlize/workflows/yaml/artifacts/prepare-no-win.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Prepare artifacts 📦
run: |
find ./downloaded-artifacts/
cp ./downloaded-artifacts/build-npm-artifact-ubuntu-latest/libpg_query.a ./libpg_query/linux/libpg_query.a
cp ./downloaded-artifacts/build-npm-artifact-macos-latest/libpg_query.a ./libpg_query/osx/libpg_query.a
cp ./downloaded-artifacts/wasm-artifacts/libpg-query.js ./wasm/libpg-query.js
cp ./downloaded-artifacts/wasm-artifacts/libpg-query.wasm ./wasm/libpg-query.wasm
rm -rf ./downloaded-artifacts
Loading
Loading