From a3a6bdca9894ffa39a3b2340e4cb56bd8e574489 Mon Sep 17 00:00:00 2001
From: Shiina Kin <shiina@sakurasou.io>
Date: Sun, 15 Dec 2024 00:17:35 +0800
Subject: [PATCH] chore: update CI workflow to include PNPM setup and build
 steps

---
 .github/workflows/ci.yml | 18 +++++++++++++++-
 ui/build.gradle.kts      | 45 +---------------------------------------
 2 files changed, 18 insertions(+), 45 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7e12de02..4c1e53e9 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -41,8 +41,24 @@ jobs:
         with:
           node-version: 20
 
+      - name: Setup PNPM
+        uses: pnpm/action-setup@v4
+        with:
+          version: 9.15.0
+
+      - name: Install dependencies
+        run: cd ui && pnpm install
+
+      - name: Build Packages
+        run: cd ui && pnpm build-packages
+
+      - name: Build UI
+        run: cd ui && pnpm build
+
       - name: Build with Gradle Wrapper
-        run: chmod +x ./gradlew && ./gradlew build
+        run: |
+          chmod +x ./gradlew
+          ./gradlew build
 
       - name: Upload artifact
         uses: actions/upload-artifact@v4
diff --git a/ui/build.gradle.kts b/ui/build.gradle.kts
index 1962a392..bfa9a554 100644
--- a/ui/build.gradle.kts
+++ b/ui/build.gradle.kts
@@ -1,46 +1,3 @@
-import java.nio.file.Files
-import kotlin.io.path.Path
-import org.siouan.frontendgradleplugin.infrastructure.gradle.InstallFrontendTask
-
-plugins {
-    id("org.siouan.frontend-jdk21") version "8.1.0"
-}
-
-repositories {
-    mavenCentral()
-}
-
-dependencies {
-}
-
-frontend {
-    nodeVersion.set("20.18.0")
-    assembleScript.set("pnpm run build-packages && pnpm run build")
-    checkScript.set("run lint")
-    verboseModeEnabled.set(true)
-}
-
-tasks.named<InstallFrontendTask>("installFrontend") {
-    val ciPlatformPresent = providers.environmentVariable("CI").isPresent
-    val lockFilePath = "${projectDir}\\pnpm-lock.yaml"
-    val retainedMetadataFileNames: Set<String>
-    if (ciPlatformPresent) {
-        retainedMetadataFileNames = setOf(lockFilePath)
-    } else {
-        // The naive configuration below allows to skip the task if the last successful execution did not change neither
-        // the package.json file, nor the pnpm-lock.yaml file, nor the node_modules directory. Any other scenario where
-        // for example the lock file is regenerated will lead to another execution before the task is "up-to-date"
-        // because the lock file is both an input and an output of the task.
-        retainedMetadataFileNames = mutableSetOf("${projectDir}\\package.json")
-        if (Files.exists(Path(lockFilePath))) {
-            retainedMetadataFileNames.add(lockFilePath)
-        }
-        outputs.file(lockFilePath).withPropertyName("lockFile")
-    }
-    inputs.files(retainedMetadataFileNames).withPropertyName("metadataFiles")
-    outputs.dir("${projectDir}\\node_modules").withPropertyName("nodeModulesDirectory")
-}
-
 tasks.register<Delete>("cleanDist") {
     delete("${projectDir}\\dist")
 }
@@ -49,6 +6,6 @@ tasks.register<Delete>("cleanNodeModules") {
     delete("${projectDir}\\node_modules")
 }
 
-tasks.named("clean") {
+tasks.register("clean") {
     dependsOn("cleanDist")
 }
\ No newline at end of file