Skip to content

Commit

Permalink
chore(ci): change build runner with target
Browse files Browse the repository at this point in the history
  • Loading branch information
everpcpc committed Feb 27, 2024
1 parent 41f99bc commit ec35af4
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 33 deletions.
7 changes: 0 additions & 7 deletions .github/actions/build_linux/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ runs:
using: "composite"
steps:
- name: Setup Build Tool
if: endsWith(inputs.target, '-linux-gnu')
uses: ./.github/actions/setup_build_tool
with:
target: base
bypass_env_vars: RUSTFLAGS,RUST_LOG
- name: Setup Build Tool
if: endsWith(inputs.target, '-linux-musl')
uses: ./.github/actions/setup_build_tool
with:
target: ${{ inputs.target }}
Expand Down
7 changes: 0 additions & 7 deletions .github/actions/build_linux_sanitizer/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ runs:
using: "composite"
steps:
- name: Setup Build Tool
if: endsWith(inputs.target, '-linux-gnu')
uses: ./.github/actions/setup_build_tool
with:
target: base
bypass_env_vars: RUSTFLAGS,RUST_LOG
- name: Setup Build Tool
if: endsWith(inputs.target, '-linux-musl')
uses: ./.github/actions/setup_build_tool
with:
target: ${{ inputs.target }}
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup_docker/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ runs:
using: "composite"
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Configure AWS Credentials
if: inputs.ecr_role_arn
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/reuse.linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ jobs:
cat license.json
build:
runs-on: [self-hosted, X64, Linux, 16c32g, "${{ inputs.runner_provider }}"]
runs-on: [self-hosted, "${{ matrix.runner }}", Linux, 16c32g, "${{ inputs.runner_provider }}"]
strategy:
fail-fast: false
matrix:
include:
- { arch: x86_64, libc: gnu }
- { target: x86_64-unknown-linux-gnu, runner: X64 }
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -69,16 +69,16 @@ jobs:
timeout-minutes: 60
with:
sha: ${{ github.sha }}
target: ${{ matrix.arch }}-unknown-linux-${{ matrix.libc }}
target: ${{ matrix.target }}
artifacts: all

build_address_sanitizer:
runs-on: [ self-hosted, ARM64, Linux, 8c16g, "${{ inputs.runner_provider }}" ]
runs-on: [ self-hosted, "${{ matrix.runner }}", Linux, 16c32g, "${{ inputs.runner_provider }}" ]
strategy:
fail-fast: false
matrix:
include:
- { arch: aarch64, libc: gnu }
- { target: aarch64-unknown-linux-gnu, runner: ARM64 }
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -87,16 +87,16 @@ jobs:
- uses: ./.github/actions/build_linux_sanitizer
timeout-minutes: 60
with:
target: ${{ matrix.arch }}-unknown-linux-${{ matrix.libc }}
target: ${{ matrix.target }}
artifacts: query

build_other:
runs-on: [self-hosted, X64, Linux, 8c16g, "${{ inputs.runner_provider }}"]
runs-on: [self-hosted, "${{ matrix.runner }}", Linux, 16c32g, "${{ inputs.runner_provider }}"]
strategy:
fail-fast: false
matrix:
include:
- { arch: aarch64, libc: musl }
- { target: aarch64-unknown-linux-musl, runner: ARM64 }
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -106,7 +106,7 @@ jobs:
timeout-minutes: 60
with:
sha: ${{ github.sha }}
target: ${{ matrix.arch }}-unknown-linux-${{ matrix.libc }}
target: ${{ matrix.target }}
artifacts: query

test_unit:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,4 @@ sentry = { git = "https://github.com/getsentry/sentry-rust", rev = "6ef6d97" }
micromarshal = { git = "https://github.com/ariesdevil/opensrv", rev = "6c96813" }
async-backtrace = { git = "https://github.com/zhang2014/async-backtrace.git", rev = "dea4553" }
geozero = { git = "https://github.com/georust/geozero", rev = "1d78b36" }
#proj = { git = "https://github.com/ariesdevil/proj", rev = "51e1c60" }
# proj = { git = "https://github.com/ariesdevil/proj", rev = "51e1c60" }
1 change: 0 additions & 1 deletion docker/build-tool/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ RUN curl -sSfLo /tmp/mold.tar.gz https://github.com/rui314/mold/releases/downloa
rm -rf /tmp/mold.tar.gz && \
ln -sf /usr/local/bin/mold /usr/bin/$(uname -m)-linux-gnu-ld

ENV LIBCLANG_PATH /usr/lib/llvm17/lib
ENV RUSTUP_HOME /opt/rust/rustup
ENV CARGO_HOME /opt/rust/cargo
ENV PATH /opt/rust/cargo/bin:/opt/java/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Expand Down
3 changes: 1 addition & 2 deletions docker/build-tool/dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
ARG RUST_TOOLCHAIN

FROM datafuselabs/build-tool:base-${RUST_TOOLCHAIN}
FROM datafuselabs/build-tool:debian-${RUST_TOOLCHAIN}

ARG ARCH
COPY rust-tools.txt /build/scripts/setup/rust-tools.txt
RUN /build/scripts/setup/dev_setup.sh -ycd && \
rm -rf /opt/rust/cargo/git && \
Expand Down
28 changes: 23 additions & 5 deletions scripts/setup/run_build_tool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,39 @@ TOOLCHAIN_VERSION=$(awk -F'[ ="]+' '$1 == "channel" { print $2 }' rust-toolchain

_UID=$(id -u)
_GID=$(id -g)
USER=${USER:-$(whoami)}

case $TARGET in
x86_64-unknown-linux-gnu | aarch64-unknown-linux-gnu | x86_64-unknown-linux-musl | aarch64-unknown-linux-musl)
RUNNER_OS="debian"
USER_CMD="useradd -u ${_UID} -M -s /bin/bash ${USER}"
;;
# x86_64-unknown-linux-musl | aarch64-unknown-linux-musl)
# RUNNER_OS="alpine"
# USER_CMD="adduser -u ${_UID} -D -H -s /bin/bash ${USER}"
# ;;
*)
RUNNER_OS="dev"
USER_CMD="useradd -u ${_UID} -M -s /bin/bash ${USER}"
;;
esac

# skip building temporary image for root
if [[ ${_UID} == 0 ]]; then
IMAGE="datafuselabs/build-tool:${TARGET}-${TOOLCHAIN_VERSION}"
IMAGE="datafuselabs/build-tool:${RUNNER_OS}-${TOOLCHAIN_VERSION}"
else
USER=${USER:-$(whoami)}
IMAGE="${USER}/build-tool:${TARGET}-${TOOLCHAIN_VERSION}"
IMAGE="${USER}/build-tool:${RUNNER_OS}-${TOOLCHAIN_VERSION}"

if [[ $(docker image ls "${IMAGE}" --format="true") ]]; then
echo "==> build-tool using image ${IMAGE}"
else
echo "==> preparing temporary build-tool image ${IMAGE} ..."
tmpdir=$(mktemp -d)
cat >"${tmpdir}/Dockerfile" <<EOF
FROM datafuselabs/build-tool:${TARGET}-${TOOLCHAIN_VERSION}
RUN useradd -u ${_UID} ${USER}
FROM datafuselabs/build-tool:${RUNNER_OS}-${TOOLCHAIN_VERSION}
RUN ${USER_CMD}
RUN cd /build && rustup target add ${TARGET}
RUN chown -R ${USER} /opt/rust/
RUN printf "${USER} ALL=(ALL:ALL) NOPASSWD:ALL\\n" > /etc/sudoers.d/databend
EOF
docker build -t "${IMAGE}" "${tmpdir}"
Expand Down

0 comments on commit ec35af4

Please sign in to comment.