diff --git a/.drone.yml b/.drone.yml index 1dd8084..cfa3955 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,7 +3,17 @@ type: docker name: default steps: -- name: test - image: 1.81-bookworm + +- name: build (rust) + image: rust:1.81-bookworm commands: - cargo test --verbose --all + - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + - (cd um_wasm && wasm-pack build --release --target web --out-dir ../um_wasm_loader/pkg) + +- name: build (node) + image: node:22.9-bookworm + commands: + - corepack enable + - pnpm i + - BUILD_SKIP_WASM_PACK=1 pnpm build diff --git a/Dockerfile b/Dockerfile index 6f14faa..9606bc3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,3 +15,4 @@ RUN git config --global --add safe.directory /a ENV PATH="/h/.local/share/pnpm:$PATH" WORKDIR /a +CMD ["/usr/bin/sleep", "infinity"] diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 index 463d8d8..0b23d7a --- a/build.sh +++ b/build.sh @@ -5,7 +5,18 @@ 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)" + +run_container() { + 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 \ + umc_rust +} + +umc_rust_id="$(run_container)" docker exec -i -u root "${umc_rust_id}" chown "$(id -u):$(id -g)" \ /h/.cargo \ @@ -22,4 +33,3 @@ docker exec -i "${umc_rust_id}" bash <<'EOF' EOF docker stop "${umc_rust_id}" docker rm -f "${umc_rust_id}" - diff --git a/um_wasm_loader/build.js b/um_wasm_loader/build.js index 605c6d1..90c0a12 100644 --- a/um_wasm_loader/build.js +++ b/um_wasm_loader/build.js @@ -77,12 +77,15 @@ async function main() { const wasmSourceDir = path.join(__dirname, '..', 'um_wasm'); const wasmOutDir = path.resolve(__dirname, 'pkg'); const wasmDistDir = path.resolve(__dirname, 'dist'); - await rm(wasmOutDir, { recursive: true, force: true }); const wasmRelOutDir = path.relative(wasmSourceDir, wasmOutDir); const profileFlag = parseBoolean(process.env.BUILD_RELEASE, true) ? '--release' : '--dev'; - await run(['wasm-pack', 'build', profileFlag, '--target', 'web', '--out-dir', wasmRelOutDir], { - cwd: path.resolve(__dirname, '..', 'um_wasm'), - }); + + if (process.env.BUILD_SKIP_WASM_PACK !== '1') { + await rm(wasmOutDir, { recursive: true, force: true }); + await run(['wasm-pack', 'build', profileFlag, '--target', 'web', '--out-dir', wasmRelOutDir], { + cwd: path.resolve(__dirname, '..', 'um_wasm'), + }); + } // Remove unneeded files await Promise.all([ @@ -93,7 +96,7 @@ async function main() { ]); const homeDir = os.homedir(); - const dummyHome = '/h' + homeDir.slice(3).replace(/./g, '_') + '/'; + const dummyHome = '/h' + homeDir.slice(2).replace(/./g, '_'); // Patch some files... await Promise.all([