forked from databendlabs/databend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
151 lines (133 loc) · 5.55 KB
/
Copy pathaction.yml
File metadata and controls
151 lines (133 loc) · 5.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: "Build Bindings python"
description: "Build with python bindings"
inputs:
target:
description: ""
required: true
version:
description: ""
required: false
runs:
using: "composite"
steps:
- name: Generate version
working-directory: src/bendpy
if: inputs.version
shell: bash
run: |
raw_version="${{ inputs.version }}"
# Remove v prefix and suffixes: v1.2.809-nightly -> 1.2.809
VERSION=$(echo "$raw_version" | sed 's/^v//' | sed 's/-nightly//' | sed 's/-p[0-9]*//')
echo "building version: $raw_version -> $VERSION"
# Replace any existing version in Cargo.toml and pyproject.toml
sed "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml > Cargo.toml.tmp
sed "s/^version = \".*\"/version = \"$VERSION\"/" pyproject.toml > pyproject.toml.tmp
mv Cargo.toml.tmp Cargo.toml
mv pyproject.toml.tmp pyproject.toml
echo "version in Cargo.toml: $(grep 'version' Cargo.toml)"
echo "version in pyproject.toml: $(grep 'version' pyproject.toml)"
- name: Get Toolchain
id: toolchain
shell: bash
run: |
RUST_TOOLCHAIN=$(awk -F'[ ="]+' '$1 == "channel" { print $2 }' rust-toolchain.toml)
echo "RUST_TOOLCHAIN=${RUST_TOOLCHAIN}" >> $GITHUB_OUTPUT
- name: Get opts
id: opts
shell: bash
run: |
if [[ -z "${{ inputs.version }}" ]]; then
echo "BUILD_ARGS=--strip --out dist" >> $GITHUB_OUTPUT
else
echo "BUILD_ARGS=--release --strip --out dist" >> $GITHUB_OUTPUT
fi
- name: Normalize cargo config for release wheel builds
if: inputs.version
shell: bash
run: |
marker="[target.'cfg(target_os = \"linux\")']"
if ! grep -Fq "$marker" .cargo/config.toml; then
echo "No Linux-specific cargo target override found"
else
awk -v marker="$marker" '
index($0, marker) == 1 { exit }
{ print }
' .cargo/config.toml > .cargo/config.toml.tmp
mv .cargo/config.toml.tmp .cargo/config.toml
echo "Removed Linux-specific linker overrides for release wheel builds"
fi
- name: Cross setup for macOS
if: endsWith(inputs.target, '-darwin')
shell: bash
run: |
bash ./scripts/setup/dev_setup.sh -yb
echo "JEMALLOC_SYS_WITH_LG_PAGE=14" >> $GITHUB_ENV
echo "JEMALLOC_SYS_WITH_MALLOC_CONF=oversize_threshold:0,dirty_decay_ms:5000,muzzy_decay_ms:5000" >> $GITHUB_ENV
- name: Setup build dependencies for Linux
if: contains(inputs.target, '-linux') && inputs.version == ''
shell: bash
run: |
sudo apt-get update -yq
sudo apt-get install -yq --no-install-recommends build-essential clang mold libssl-dev pkg-config cmake protobuf-compiler
if [[ "${{ inputs.target }}" == aarch64-* ]]; then
echo "JEMALLOC_SYS_WITH_LG_PAGE=16" >> $GITHUB_ENV
else
echo "JEMALLOC_SYS_WITH_LG_PAGE=14" >> $GITHUB_ENV
fi
echo "JEMALLOC_SYS_WITH_MALLOC_CONF=oversize_threshold:0,dirty_decay_ms:5000,muzzy_decay_ms:5000" >> $GITHUB_ENV
- name: Setup uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Build wheels
if: inputs.version
uses: PyO3/maturin-action@v1
env:
CARGO_PROFILE_RELEASE_LTO: "off"
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "16"
with:
rust-toolchain: ${{ steps.toolchain.outputs.RUST_TOOLCHAIN }}
working-directory: src/bendpy
target: ${{ inputs.target }}
manylinux: "2_28"
# Keep them in one line due to https://github.com/PyO3/maturin-action/issues/153
rustup-components: rustfmt
args: ${{ steps.opts.outputs.BUILD_ARGS }}
docker-options: --env RUSTC_WRAPPER=sccache --env SCCACHE_GCS_RW_MODE=READ_WRITE --env SCCACHE_GCS_BUCKET=databend-ci --env SCCACHE_GCS_KEY_PREFIX=cache/sccache/ --env MATURIN_NO_AUTO_INSTALL=1
container-options: --platform linux/amd64
before-script-linux: |
unset RUSTC_WRAPPER
# Add the target for the specified architecture
rustup target add ${{ inputs.target }}
# Install cargo-zigbuild manually to avoid musl target issues
cargo install cargo-zigbuild --target ${{ inputs.target }}
../../scripts/setup/dev_setup.sh -yb
# Create virtual environment for build dependencies (overwrite if exists)
uv venv .venv --python=python3.12 --clear
uv sync --all-groups --all-extras
- name: Setup Rust for development builds
if: inputs.version == ''
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.toolchain.outputs.RUST_TOOLCHAIN }}
components: rustfmt
- name: Build development wheel and run tests
if: inputs.version == ''
shell: bash
working-directory: src/bendpy
run: |
echo "Building development wheel for testing..."
# Create virtual environment (overwrite if exists)
uv venv .venv --python python3.12 --clear
source .venv/bin/activate
# Install development dependencies
uv pip install maturin pytest pandas polars pyarrow
# Ensure we have a clean environment
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/.cargo/bin:$PATH"
echo "Running development build tests..."
maturin develop -E test --quiet
# Run pytest tests
echo "Executing pytest tests..."
python -m pytest tests/ -v --tb=short
echo "All Python binding tests passed!"