-
Notifications
You must be signed in to change notification settings - Fork 193
Use R2 bucket for duckdb libraries #8486
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| name: DuckDB R2 mirror | ||
|
|
||
| # If we have an archive for a commit or a tag in R2, return it. | ||
| # Otherwise, if it's a tag, download release archive from Duckdb Github | ||
| # page and upload it to R2. | ||
| # If it's a commit, build Duckdb from source and upload it to R2. | ||
| on: | ||
| workflow_call: { } | ||
|
|
||
| concurrency: | ||
| group: duckdb-r2-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: false | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| PUBLIC_BASE_URL: "https://ci-builds.vortex.dev" | ||
| R2_BUCKET: "duckdb-builds" | ||
| R2_ENDPOINT_URL: "https://52bdeab5651e1584747feefd051fd566.r2.cloudflarestorage.com" | ||
|
|
||
| jobs: | ||
| check: | ||
| name: "Resolve DuckDB version and check R2" | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| outputs: | ||
| version: ${{ steps.resolve.outputs.version }} | ||
|
myrrc marked this conversation as resolved.
|
||
| ref_dir: ${{ steps.resolve.outputs.ref_dir }} | ||
| release: ${{ steps.resolve.outputs.release }} | ||
| matrix: ${{ steps.resolve.outputs.matrix }} | ||
| any_missing: ${{ steps.resolve.outputs.any_missing }} | ||
| steps: | ||
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 | ||
| - name: Resolve version and check R2 | ||
| id: resolve | ||
| run: sh scripts/duckdb-r2-resolve.sh | ||
|
|
||
| mirror: | ||
| name: "Mirror DuckDB ${{ matrix.archive }} to R2" | ||
| needs: check | ||
| if: >- | ||
| needs.check.outputs.any_missing == 'true' && | ||
| github.repository == 'vortex-data/vortex' && | ||
| github.event.pull_request.head.repo.full_name == github.repository | ||
| environment: duckdb-build | ||
| timeout-minutes: 120 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: ${{ fromJSON(needs.check.outputs.matrix) }} | ||
| runs-on: ${{ matrix.runner }} | ||
| steps: | ||
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 | ||
|
|
||
| - name: Install build dependencies (Linux) | ||
| if: needs.check.outputs.release != 'true' && runner.os == 'Linux' | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y ninja-build libcurl4-openssl-dev zip unzip | ||
|
|
||
| # MacOS already has ninja and p7zip | ||
|
|
||
| - name: Prepare ${{ matrix.archive }} | ||
| env: | ||
| ARCHIVE: ${{ matrix.archive }} | ||
| REF_DIR: ${{ needs.check.outputs.ref_dir }} | ||
| RELEASE: ${{ needs.check.outputs.release }} | ||
| PLATFORM_OS: ${{ matrix.os }} | ||
| run: sh scripts/duckdb-r2-prepare.sh | ||
|
|
||
| - name: Upload to R2 | ||
| env: | ||
| AWS_ACCESS_KEY_ID: ${{ secrets.DUCKDB_R2_ACCESS_KEY_ID }} | ||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.DUCKDB_R2_SECRET_ACCESS_KEY }} | ||
| AWS_REGION: "us-east-1" | ||
| AWS_ENDPOINT_URL: ${{ env.R2_ENDPOINT_URL }} | ||
| run: | | ||
| set -Eeuo pipefail | ||
| python3 scripts/s3-upload.py \ | ||
| --bucket "$R2_BUCKET" \ | ||
| --key "${{ needs.check.outputs.ref_dir }}/${{ matrix.archive }}" \ | ||
| --body "${{ matrix.archive }}" \ | ||
| --checksum-algorithm CRC32 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| #!/bin/sh | ||
|
|
||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright the Vortex contributors | ||
| # | ||
| # Produce $ARCHIVE for upload to R2: either download DuckDB release for | ||
| # $REF_DIR or build DuckDB from source at commit $REF_DIR and pack | ||
| # libraries and headers. | ||
| # | ||
| # Required env vars: ARCHIVE, REF_DIR, RELEASE, PLATFORM_OS | ||
|
|
||
| set -eu | ||
|
|
||
| if [ "$RELEASE" = "true" ]; then | ||
| echo "Mirroring DuckDB release ${REF_DIR}/${ARCHIVE}" | ||
| curl -fSL --retry 3 -o "$ARCHIVE" \ | ||
| "https://github.com/duckdb/duckdb/releases/download/${REF_DIR}/${ARCHIVE}" | ||
| else | ||
| echo "Building DuckDB commit ${REF_DIR} from source" | ||
|
|
||
| curl -fSL --retry 3 -o duckdb-src.zip \ | ||
| "https://github.com/duckdb/duckdb/archive/${REF_DIR}.zip" | ||
|
|
||
| # macos zip extract error: cannot create | ||
| # <...>/issue2628_������.csv Illegal byte sequence | ||
| if [ "$PLATFORM_OS" = "osx" ]; then | ||
|
0ax1 marked this conversation as resolved.
|
||
| 7z x duckdb-src.zip | ||
| else | ||
| unzip -q duckdb-src.zip | ||
| fi | ||
|
|
||
| src_dir="duckdb-${REF_DIR}" | ||
| extra="" | ||
| if [ "$PLATFORM_OS" = "osx" ]; then | ||
| extra="OSX_BUILD_UNIVERSAL=1" | ||
| fi | ||
|
|
||
| make -C "$src_dir" \ | ||
| GEN=ninja \ | ||
| DISABLE_SANITIZER=1 \ | ||
| THREADSAN=0 \ | ||
| BUILD_SHELL=false \ | ||
| BUILD_UNITTESTS=false \ | ||
| ENABLE_UNITTEST_CPP_TESTS=false \ | ||
| BUILD_EXTENSIONS="parquet;tpch;tpcds" \ | ||
| $extra | ||
|
|
||
| lib_dir="${src_dir}/build/release/src" | ||
| stage="stage" | ||
| mkdir -p "$stage" | ||
|
|
||
| cp -a "${lib_dir}/libduckdb.so" "$stage/" 2>/dev/null || true | ||
|
0ax1 marked this conversation as resolved.
|
||
| cp -a "${lib_dir}/libduckdb.dylib" "$stage/" 2>/dev/null || true | ||
| cp -a "${lib_dir}/libduckdb_static.a" "$stage/" | ||
| cp -a "${src_dir}/src/include/duckdb.h" "$stage/" 2>/dev/null || true | ||
| cp -a "${src_dir}/src/include/duckdb.hpp" "$stage/" 2>/dev/null || true | ||
|
|
||
| ( cd "$stage" && zip -r "../${ARCHIVE}" . ) | ||
| fi | ||
|
|
||
| ls -la "$ARCHIVE" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #!/bin/sh | ||
|
|
||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright the Vortex contributors | ||
| # | ||
| # Resolve DuckDB version in vortex-duckdb/build.rs and check which archives | ||
| # are present in R2. Output "version", "ref_dir", "release", "matrix", and | ||
| # "any_missing". | ||
| # | ||
| # Required env vars: PUBLIC_BASE_URL, GITHUB_OUTPUT | ||
|
|
||
| set -eu | ||
|
0ax1 marked this conversation as resolved.
|
||
|
|
||
| version=$(grep -oP 'DEFAULT_DUCKDB_VERSION:\s*&str\s*=\s*"\K[^"]+' \ | ||
| vortex-duckdb/build.rs) | ||
|
|
||
| # vortex-duckdb/build.rs: >=2 dot-separated numbers are a | ||
| # tagged release (ref dir "vX.Y.Z"), anything else is a commit. | ||
| ref=${version#v} | ||
| if printf '%s' "$ref" | grep -Eq '^[0-9]+(\.[0-9]+)+$'; then | ||
| release=true | ||
| ref_dir="v$ref" | ||
| else | ||
| release=false | ||
| ref_dir="$ref" | ||
| fi | ||
|
|
||
| echo "DuckDB $version release=$release" | ||
|
|
||
| entries=$(mktemp) | ||
| trap 'rm -f "$entries"' EXIT | ||
|
|
||
| for archive in \ | ||
| libduckdb-linux-amd64.zip \ | ||
| libduckdb-linux-arm64.zip \ | ||
| libduckdb-osx-universal.zip; do | ||
|
|
||
| url="${PUBLIC_BASE_URL}/${ref_dir}/${archive}" | ||
| code=$(curl -o /dev/null -s -w '%{http_code}' --head "$url" || echo 000) | ||
| if [ "$code" = "200" ]; then | ||
| echo "present in R2: $archive" | ||
| continue | ||
| fi | ||
|
|
||
| echo "missing in R2 (HTTP $code): $archive" | ||
| case "$archive" in | ||
| *linux-amd64*) runner=ubuntu-latest; os=linux; arch=amd64 ;; | ||
| *linux-arm64*) runner=ubuntu-24.04-arm; os=linux; arch=arm64 ;; | ||
| *osx-universal*) runner=macos-14; os=osx; arch=universal ;; | ||
| esac | ||
| jq -nc \ | ||
| --arg archive "$archive" \ | ||
| --arg runner "$runner" \ | ||
| --arg os "$os" \ | ||
| --arg arch "$arch" \ | ||
| '{archive: $archive, runner: $runner, os: $os, arch: $arch}' >> "$entries" | ||
| done | ||
|
|
||
| if [ -s "$entries" ]; then | ||
|
0ax1 marked this conversation as resolved.
|
||
| include=$(jq -sc '.' < "$entries") | ||
| matrix=$(jq -nc --argjson include "$include" '{include: $include}') | ||
| any_missing=true | ||
| else | ||
| matrix='{"include":[]}' | ||
| any_missing=false | ||
| fi | ||
|
|
||
| echo "any_missing=$any_missing" | ||
|
|
||
| { | ||
| echo "version=$version" | ||
| echo "ref_dir=$ref_dir" | ||
| echo "release=$release" | ||
| echo "matrix=$matrix" | ||
| echo "any_missing=$any_missing" | ||
| } >> "$GITHUB_OUTPUT" | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.