ci: test pipeline
Some checks failed
continuous-integration/drone Build is failing

This commit is contained in:
鲁树人 2024-09-24 20:34:29 +01:00
parent c7983ddce2
commit ac9558a9ac
4 changed files with 33 additions and 9 deletions

View File

@ -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

View File

@ -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"]

14
build.sh Normal file → Executable file
View File

@ -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}"

View File

@ -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([