From 6afdac9a531302aefa3f38ddf064eb0234bf1f70 Mon Sep 17 00:00:00 2001
From: Dmitry Rodionov <d.rodionov@picodata.io>
Date: Tue, 9 Jul 2024 19:02:42 +0300
Subject: [PATCH] chore: incorporate webui submodule

---
 .gitlab-ci.yml       |  6 +++---
 build.rs             | 20 +++++++++++---------
 webui/.gitlab-ci.yml | 22 ----------------------
 webui/package.json   |  3 +--
 4 files changed, 15 insertions(+), 36 deletions(-)
 delete mode 100644 webui/.gitlab-ci.yml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 907128f9c4..bca9f56bad 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -77,10 +77,10 @@ variables:
 
 .base_node: &base_node
   paths:
-    - picodata-webui/node_modules/
+    - webui/node_modules/
   key:
     files:
-      - picodata-webui/yarn.lock
+      - webui/yarn.lock
 
 .py_cache: &py_cache
   paths:
@@ -459,7 +459,7 @@ deploy-docker:
     project: picodata/devops/picodata-in-docker
     branch: main
     strategy: depend
-    
+
 # Stages of independent stress testing in downstream pipeline
 # We cannot move artefacts to the downstream pipeline, so we need to build and upload them to our repo
 upload-picodata-to-binary:
diff --git a/build.rs b/build.rs
index e4821b022c..4204e71882 100644
--- a/build.rs
+++ b/build.rs
@@ -7,6 +7,8 @@ use std::path::Path;
 use std::process::Command;
 use std::process::Stdio;
 
+const WEBUI_DIR: &str = "webui";
+
 // See also: https://doc.rust-lang.org/cargo/reference/build-scripts.html
 fn main() {
     do_compile_time_checks();
@@ -22,10 +24,10 @@ fn main() {
     // │   ├── CMakeLists.txt // used for dynamic build
     // │   └── static-build
     // │       └── CMakeLists.txt // configures above CMakeLists.txt for static build
-    // ├── picodata-webui
+    // ├── webui
     // └── <target-dir>/<build-type>/build  // <- build_root
     //     ├── picodata-<smth>/out          // <- std::env::var("OUT_DIR")
-    //     ├── picodata-webui
+    //     ├── webui
     //     ├── tarantool-http
     //     └── tarantool-sys/{static,dynamic}
     //         ├── ncurses-prefix
@@ -38,8 +40,7 @@ fn main() {
 
     // Running `cargo build` and `cargo clippy` produces 2 different
     // `out_dir` paths. To avoid unnecessary rebuilds we use a different
-    // build root for foreign deps (tarantool-sys, tarantool-http,
-    // picodata-webui)
+    // build root for foreign deps (tarantool-sys, tarantool-http, webui)
     let build_root = Path::new(&out_dir).ancestors().nth(2).unwrap();
     dbg!(&build_root); // "<target-dir>/<build-type>/build"
 
@@ -236,16 +237,17 @@ fn generate_export_stubs(out_dir: &str) {
 fn rerun_if_webui_changed() {
     use std::fs;
 
-    let source_dir = std::env::current_dir().unwrap().join("picodata-webui");
+    let source_dir = std::env::current_dir().unwrap().join(WEBUI_DIR);
     // Do not rerun for generated files changes
     let ignored_files = ["node_modules", ".husky"];
     for entry in fs::read_dir(source_dir)
-        .expect("failed to scan picodata-webui dir")
+        .expect("failed to scan webui dir")
         .flatten()
     {
         if !ignored_files.contains(&entry.file_name().to_str().unwrap()) {
             println!(
-                "cargo:rerun-if-changed=picodata-webui/{}",
+                "cargo:rerun-if-changed={}/{}",
+                WEBUI_DIR,
                 entry.file_name().to_string_lossy()
             );
         }
@@ -260,8 +262,8 @@ fn build_webui(build_root: &Path) {
     }
 
     println!("building webui_bundle ...");
-    let source_dir = std::env::current_dir().unwrap().join("picodata-webui");
-    let out_dir = build_root.join("picodata-webui");
+    let source_dir = std::env::current_dir().unwrap().join(WEBUI_DIR);
+    let out_dir = build_root.join(WEBUI_DIR);
     let out_dir_str = out_dir.display().to_string();
 
     let webui_bundle = out_dir.join("bundle.json");
diff --git a/webui/.gitlab-ci.yml b/webui/.gitlab-ci.yml
deleted file mode 100644
index 8c119e6543..0000000000
--- a/webui/.gitlab-ci.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-default:
-  tags:
-    - docker
-  image: node:19.8-alpine
-
-stages:
-  - lint
-  - test
-
-lint:
-  stage: lint
-  before_script:
-    - yarn add eslint
-  script:
-    - yarn lint
-
-.test:
-  stage: test
-  before_script:
-    - yarn add jest
-  script:
-    - yarn test
diff --git a/webui/package.json b/webui/package.json
index 76ae934727..f8edb9bdaf 100644
--- a/webui/package.json
+++ b/webui/package.json
@@ -12,8 +12,7 @@
     "lint": "eslint src --max-warnings 0",
     "lint:fix": "eslint --fix src",
     "type-check:watch": "tsc -w --pretty",
-    "type-check": "tsc --noEmit",
-    "prepare": "husky install"
+    "type-check": "tsc --noEmit"
   },
   "lint-staged": {
     "*.ts": "yarn tsc --noEmit",
-- 
GitLab