Skip to content
Merged
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
File renamed without changes.
161 changes: 81 additions & 80 deletions .github/workflows/flutter-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ jobs:
- name: Install Linux build and test dependencies
run: sudo apt-get update && sudo apt-get install --yes clang cmake ninja-build pkg-config libgtk-3-dev libreoffice-calc xvfb

- name: Set up Nim
uses: jiro4989/setup-nim-action@v2
with:
nim-version: stable

- name: Resolve locked DecentDB version
id: decentdb-version
shell: bash
Expand Down Expand Up @@ -56,28 +51,19 @@ jobs:
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "tag=$tag" >> "$GITHUB_OUTPUT"

- name: Check out DecentDB ${{ steps.decentdb-version.outputs.tag }}
run: git clone --depth 1 --branch "${{ steps.decentdb-version.outputs.tag }}" https://github.com/sphildreth/decentdb.git ../decentdb

- name: Build libpg_query (Linux)
working-directory: ../decentdb
- name: Install pinned DecentDB native library
shell: bash
run: |
if [ ! -d "/tmp/libpg_query" ]; then
git clone --depth 1 https://github.com/pganalyze/libpg_query.git /tmp/libpg_query
make -C /tmp/libpg_query
fi
mkdir -p build/lib
cp /tmp/libpg_query/libpg_query.a build/lib/

- name: Install DecentDB Nim dependencies
working-directory: ../decentdb
run: nimble setup -y

- name: Build DecentDB native library
working-directory: ../decentdb
shell: bash
run: nimble build_lib
set -euo pipefail
tag="${{ steps.decentdb-version.outputs.tag }}"
asset="decentdb-dart-native-${tag}-Linux-x64.tar.gz"
url="https://github.com/sphildreth/decentdb/releases/download/${tag}/${asset}"
work_dir="$RUNNER_TEMP/decentdb-native"
archive_path="$RUNNER_TEMP/$asset"
mkdir -p "$work_dir"
curl -fsSL "$url" -o "$archive_path"
tar -xzf "$archive_path" -C "$work_dir"
sudo install -m 0644 "$work_dir/libdecentdb.so" /usr/local/lib/libdecentdb.so

- name: Flutter pub get
working-directory: apps/decent-bench
Expand All @@ -93,7 +79,36 @@ jobs:

- name: Flutter integration test
working-directory: apps/decent-bench
run: xvfb-run -a flutter test integration_test
shell: bash
run: |
set -euo pipefail
display_file="$(mktemp)"
Xvfb -displayfd 3 -screen 0 1600x1000x24 -ac 3>"$display_file" >"$RUNNER_TEMP/xvfb.log" 2>&1 &
xvfb_pid=$!
cleanup() {
kill "$xvfb_pid" 2>/dev/null || true
wait "$xvfb_pid" 2>/dev/null || true
rm -f "$display_file"
}
trap cleanup EXIT
for _ in $(seq 1 100); do
if [ -s "$display_file" ]; then
break
fi
sleep 0.1
done
export DISPLAY=":$(cat "$display_file")"
# Run integration tests; retry once on non-zero exit to handle the
# known Linux desktop shutdown crash where all test assertions pass
# but the binary exits non-zero during cleanup.
set +e
flutter test integration_test
it_exit=$?
set -e
if [ "$it_exit" -ne 0 ]; then
echo "::warning::Integration test exited with $it_exit on first attempt; retrying..."
flutter test integration_test
fi

desktop-package-verify:
runs-on: ${{ matrix.os }}
Expand All @@ -104,15 +119,20 @@ jobs:
- os: ubuntu-latest
flutter_target: linux
bundle_path: build/linux/x64/release/bundle
native_lib: ../../../decentdb/build/libdecentdb.so
decentdb_release_suffix: Linux-x64
native_archive_extension: tar.gz
native_lib_name: libdecentdb.so
- os: macos-latest
flutter_target: macos
bundle_path: build/macos/Build/Products/Release/decent_bench.app
native_lib: ../../../decentdb/build/libdecentdb.dylib
native_archive_extension: tar.gz
native_lib_name: libdecentdb.dylib
Comment on lines 125 to +129
- os: windows-latest
flutter_target: windows
bundle_path: build/windows/x64/runner/Release
native_lib: ../../../decentdb/build/c_api.dll
decentdb_release_suffix: Windows-x64
native_archive_extension: zip
native_lib_name: decentdb.dll

steps:
- name: Check out Decent Bench
Expand All @@ -128,11 +148,6 @@ jobs:
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install --yes clang cmake ninja-build pkg-config libgtk-3-dev

- name: Set up Nim
uses: jiro4989/setup-nim-action@v2
with:
nim-version: stable

- name: Resolve locked DecentDB version
id: decentdb-version
shell: bash
Expand Down Expand Up @@ -160,56 +175,42 @@ jobs:
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "tag=$tag" >> "$GITHUB_OUTPUT"

- name: Check out DecentDB ${{ steps.decentdb-version.outputs.tag }}
run: git clone --depth 1 --branch "${{ steps.decentdb-version.outputs.tag }}" https://github.com/sphildreth/decentdb.git ../decentdb

- name: Build libpg_query (Linux)
if: runner.os == 'Linux'
working-directory: ../decentdb
shell: bash
run: |
if [ ! -d "/tmp/libpg_query" ]; then
git clone --depth 1 https://github.com/pganalyze/libpg_query.git /tmp/libpg_query
make -C /tmp/libpg_query
fi
mkdir -p build/lib
cp /tmp/libpg_query/libpg_query.a build/lib/

- name: Build libpg_query (macOS)
if: runner.os == 'macOS'
working-directory: ../decentdb
- name: Download DecentDB Dart-native asset (Linux/macOS)
if: runner.os != 'Windows'
shell: bash
run: |
if [ ! -d "/tmp/libpg_query" ]; then
git clone --depth 1 https://github.com/pganalyze/libpg_query.git /tmp/libpg_query
make -C /tmp/libpg_query
set -euo pipefail
tag="${{ steps.decentdb-version.outputs.tag }}"
# Use the matrix-provided suffix when available; for macOS the
# suffix is derived at runtime from RUNNER_ARCH so the workflow
# stays correct if GitHub changes the runner architecture.
release_suffix="${{ matrix.decentdb_release_suffix }}"
if [[ -z "$release_suffix" ]]; then
arch="$(echo "${RUNNER_ARCH}" | tr '[:upper:]' '[:lower:]')"
release_suffix="${RUNNER_OS}-${arch}"
fi
mkdir -p build/lib
cp /tmp/libpg_query/libpg_query.a build/lib/

- name: Build libpg_query (Windows)
asset="decentdb-dart-native-${tag}-${release_suffix}.${{ matrix.native_archive_extension }}"
url="https://github.com/sphildreth/decentdb/releases/download/${tag}/${asset}"
work_dir="$RUNNER_TEMP/decentdb-native"
archive_path="$RUNNER_TEMP/$asset"
mkdir -p "$work_dir"
curl -fsSL "$url" -o "$archive_path"
tar -xzf "$archive_path" -C "$work_dir"
echo "DECENTDB_NATIVE_PATH=$work_dir/${{ matrix.native_lib_name }}" >> "$GITHUB_ENV"

- name: Download DecentDB Dart-native asset (Windows)
if: runner.os == 'Windows'
working-directory: ../decentdb
shell: bash
shell: pwsh
run: |
repo_root="$PWD"
if [ ! -d "/tmp/libpg_query" ]; then
git clone --depth 1 https://github.com/pganalyze/libpg_query.git /tmp/libpg_query
cd /tmp/libpg_query
make
fi
cd /tmp/libpg_query
mkdir -p "$repo_root/build/lib"
cp libpg_query.a "$repo_root/build/lib/"

- name: Install DecentDB Nim dependencies
working-directory: ../decentdb
run: nimble setup -y

- name: Build DecentDB native library
working-directory: ../decentdb
shell: bash
run: nimble build_lib
$tag = "${{ steps.decentdb-version.outputs.tag }}"
$asset = "decentdb-dart-native-$tag-${{ matrix.decentdb_release_suffix }}.${{ matrix.native_archive_extension }}"
$url = "https://github.com/sphildreth/decentdb/releases/download/$tag/$asset"
$workDir = Join-Path $env:RUNNER_TEMP "decentdb-native"
$archivePath = Join-Path $env:RUNNER_TEMP $asset
New-Item -ItemType Directory -Force $workDir | Out-Null
Invoke-WebRequest -Uri $url -OutFile $archivePath
Expand-Archive -Path $archivePath -DestinationPath $workDir -Force
Add-Content -Path $env:GITHUB_ENV -Value "DECENTDB_NATIVE_PATH=$workDir\\${{ matrix.native_lib_name }}"

- name: Flutter pub get
working-directory: apps/decent-bench
Expand Down Expand Up @@ -249,7 +250,7 @@ jobs:

- name: Stage DecentDB native library into bundle
working-directory: apps/decent-bench
run: dart run tool/stage_decentdb_native.dart --bundle "${{ matrix.bundle_path }}" --source "${{ matrix.native_lib }}"
run: dart run tool/stage_decentdb_native.dart --bundle "${{ matrix.bundle_path }}" --source "${{ env.DECENTDB_NATIVE_PATH }}"

- name: Verify bundled native library
working-directory: apps/decent-bench
Expand Down
Loading
Loading