Skip to content
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
3 changes: 3 additions & 0 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ jobs:
- name: Check extension files for std::assert
run: ./scripts/check-no-std-assert.sh extension

- name: Test precompiled artifact download routing
run: ./scripts/test-download-liblbug.sh

- name: Ensure generated grammar files are up to date
run: |
python3 scripts/antlr4/hash.py src/antlr4/keywords.txt src/antlr4/Cypher.g4 > tmphashfile
Expand Down
7 changes: 6 additions & 1 deletion scripts/download-liblbug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ set -euo pipefail

LIB_KIND="${LBUG_LIB_KIND:-shared}"
LINUX_VARIANT="${LBUG_LINUX_VARIANT:-compat}"
REPOSITORY="${LBUG_GITHUB_REPOSITORY:-LadybugDB/ladybug}"
RUN_ID="${LBUG_PRECOMPILED_RUN_ID:-}"
VERSION_OVERRIDE="${LBUG_VERSION:-}"

if [ -n "$RUN_ID" ]; then
REPOSITORY="${LBUG_GITHUB_REPOSITORY:-${GITHUB_REPOSITORY:-LadybugDB/ladybug}}"
else
REPOSITORY="${LBUG_GITHUB_REPOSITORY:-LadybugDB/ladybug}"
fi

if [ "$LIB_KIND" != "shared" ] && [ "$LIB_KIND" != "static" ]; then
echo "Unsupported LBUG_LIB_KIND: $LIB_KIND (expected 'shared' or 'static')" >&2
exit 1
Expand Down
97 changes: 97 additions & 0 deletions scripts/test-download-liblbug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env bash
set -euo pipefail

root_dir="$(cd "$(dirname "$0")/.." && pwd)"
test_dir="$(mktemp -d)"
trap 'rm -rf "$test_dir"' EXIT

bin_dir="$test_dir/bin"
mkdir -p "$bin_dir"

cat > "$bin_dir/uname" <<'EOF'
#!/usr/bin/env bash
case "${1:-}" in
-s) printf 'Linux\n' ;;
-m) printf 'x86_64\n' ;;
*) exit 1 ;;
esac
EOF

cat > "$bin_dir/gh" <<'EOF'
#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' "$@" > "$TEST_GH_ARGS"
artifact_dir=""
while [ "$#" -gt 0 ]; do
case "$1" in
--dir)
artifact_dir="$2"
shift 2
;;
*)
shift
;;
esac
done

mkdir -p "$artifact_dir" "$TEST_PAYLOAD_DIR"
printf 'fixture\n' > "$TEST_PAYLOAD_DIR/liblbug.a"
tar czf "$artifact_dir/liblbug-static-linux-x86_64-compat.tar.gz" \
-C "$TEST_PAYLOAD_DIR" liblbug.a
EOF

cat > "$bin_dir/curl" <<'EOF'
#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' "$@" > "$TEST_CURL_ARGS"
output=""
while [ "$#" -gt 0 ]; do
case "$1" in
-o)
output="$2"
shift 2
;;
*)
shift
;;
esac
done

mkdir -p "$(dirname "$output")" "$TEST_PAYLOAD_DIR"
printf 'fixture\n' > "$TEST_PAYLOAD_DIR/liblbug.a"
tar czf "$output" -C "$TEST_PAYLOAD_DIR" liblbug.a
EOF

chmod +x "$bin_dir/uname" "$bin_dir/gh" "$bin_dir/curl"

export PATH="$bin_dir:$PATH"
export TEST_GH_ARGS="$test_dir/gh-args"
export TEST_CURL_ARGS="$test_dir/curl-args"
export TEST_PAYLOAD_DIR="$test_dir/payload"
export GITHUB_REPOSITORY="fork-owner/ladybug"
export LBUG_LIB_KIND="static"
export LBUG_PRECOMPILED_RUN_ID="12345"

export LBUG_TARGET_DIR="$test_dir/current-repository"
"$root_dir/scripts/download-liblbug.sh"
test -s "$LBUG_TARGET_DIR/liblbug.a"
test "$(awk '$0 == "--repo" { getline; print; exit }' "$TEST_GH_ARGS")" = \
"fork-owner/ladybug"

export LBUG_GITHUB_REPOSITORY="override-owner/ladybug"
export LBUG_TARGET_DIR="$test_dir/explicit-override"
"$root_dir/scripts/download-liblbug.sh"
test -s "$LBUG_TARGET_DIR/liblbug.a"
test "$(awk '$0 == "--repo" { getline; print; exit }' "$TEST_GH_ARGS")" = \
"override-owner/ladybug"

unset LBUG_GITHUB_REPOSITORY LBUG_PRECOMPILED_RUN_ID
export LBUG_VERSION="0.18.1"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove references to 0.18.x. Makes it hard to bump version numbers on the next release.

export LBUG_TARGET_DIR="$test_dir/release"
"$root_dir/scripts/download-liblbug.sh"
test -s "$LBUG_TARGET_DIR/liblbug.a"
grep -Fx \
"https://github.com/LadybugDB/ladybug/releases/download/v0.18.1/liblbug-static-linux-x86_64-compat.tar.gz" \
"$TEST_CURL_ARGS"
Loading