From c7983ddce2fc94435f44e2ceb1e5fc0e5e95f481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Sun, 22 Sep 2024 19:12:12 +0100 Subject: [PATCH] [wip] ci: ci work --- .drone.yml | 9 +++++++++ .gitignore | 1 + Dockerfile | 17 +++++++++++++++++ build.sh | 25 +++++++++++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 .drone.yml create mode 100644 Dockerfile create mode 100644 build.sh diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..1dd8084 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,9 @@ +kind: pipeline +type: docker +name: default + +steps: +- name: test + image: 1.81-bookworm + commands: + - cargo test --verbose --all diff --git a/.gitignore b/.gitignore index 7b3cd89..e4541e7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ target/ pkg/ pkg-*/ node_modules/ +.pnpm-store *.local diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6f14faa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM rust:1.81-bookworm + +RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + +ARG uid=1998 +ARG gid=1998 + +RUN groupadd -g "$gid" builder \ + && useradd -u "$uid" -g "$gid" -m -d /h builder + +USER builder + +RUN curl -fsL https://get.pnpm.io/install.sh | ENV="$HOME/.bashrc" SHELL="$(which bash)" bash - +RUN git config --global --add safe.directory /a +ENV PATH="/h/.local/share/pnpm:$PATH" + +WORKDIR /a diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..463d8d8 --- /dev/null +++ b/build.sh @@ -0,0 +1,25 @@ +#!/bin/bash -ex + +docker volume create umc_rust_cache +docker volume create umc_rust_pnpm_cache +docker volume create umc_rust_target_cache +docker volume create umc_pnpm_loader_cache +docker buildx build --build-arg uid="$(id -u)" --build-arg gid="$(id -g)" -t umc_rust . +umc_rust_id="$(docker run -d -v umc_rust_cache:/h/.cargo -v "${PWD}:/a" -v umc_rust_pnpm_cache:/a/.pnpm-store -v umc_rust_target_cache:/a/target -v umc_pnpm_loader_cache:/a/um_wasm_loader/node_modules --entrypoint /usr/bin/sleep umc_rust infinity)" + +docker exec -i -u root "${umc_rust_id}" chown "$(id -u):$(id -g)" \ + /h/.cargo \ + /a/.pnpm-store \ + /a/target \ + /a/um_wasm_loader/node_modules + +docker exec -i "${umc_rust_id}" bash <<'EOF' + export npm_config_use_node_version=22.9.0 + cd um_wasm_loader + pnpm --package-import-method=copy i + pnpm build + pnpm pack +EOF +docker stop "${umc_rust_id}" +docker rm -f "${umc_rust_id}" +