This is an automated email from the ASF dual-hosted git repository.

tiagobento pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git


The following commit(s) were added to refs/heads/main by this push:
     new 31ada4477fe kie-tools#3347: [CI] Implement a cache for 
drools-and-kogito (#3348)
31ada4477fe is described below

commit 31ada4477feca3dcecf8d4d69a887d764acd02ec
Author: Fabrizio Antonangeli <[email protected]>
AuthorDate: Sat Nov 22 15:43:13 2025 +0100

    kie-tools#3347: [CI] Implement a cache for drools-and-kogito (#3348)
---
 .github/actions/bootstrap/action.yml        | 24 ++++++++++++++++++++++++
 packages/drools-and-kogito/package.json     |  3 ++-
 packages/drools-and-kogito/printCacheKey.js | 26 ++++++++++++++++++++++++++
 3 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/.github/actions/bootstrap/action.yml 
b/.github/actions/bootstrap/action.yml
index 0469467b342..4738c77af4f 100644
--- a/.github/actions/bootstrap/action.yml
+++ b/.github/actions/bootstrap/action.yml
@@ -45,8 +45,32 @@ runs:
         cd ${{ inputs.working_dir }}
         df -h .
 
+    - name: "Calculate drools-and-kogito cache key"
+      id: drools_and_kogito_cache_key
+      env:
+        DROOLS_AND_KOGITO__skip: true
+      shell: bash
+      run: |
+        cd ${{ inputs.working_dir }}
+        pnpm bootstrap -F @kie-tools-core/drools-and-kogito...
+        keyOutput=$(cd packages/drools-and-kogito && pnpm run --silent 
print-cache-key)
+        echo "Drools and Kogito cache key: $keyOutput"
+        echo "key=$keyOutput" >> "$GITHUB_OUTPUT"
+
+    # Cache 'packages/drools-and-kogito/dist' using the git refs from Drools, 
OptaPlanner, Kogito Runtimes, and Kogito Apps as a unique key and refresh the 
cache on changes.
+    # The maven-base profile 'use-maven-repo-local-tail', in 
packages/maven-base/pom.xml, uses this folder for maven artifacts.
+    - name: "Cache drools-and-kogito dist folder"
+      if: ${{ steps.drools_and_kogito_cache_key.outputs.key != '' }}
+      id: drools_and_kogito_cache
+      uses: actions/cache@v4
+      with:
+        path: ${{ inputs.working_dir }}/packages/drools-and-kogito/dist
+        key: ${{ runner.os }}-drools_and_kogito_cache-${{ 
steps.drools_and_kogito_cache_key.outputs.key }}
+
     - name: "Bootstrap"
       shell: bash
+      env:
+        DROOLS_AND_KOGITO__skip: ${{ 
steps.drools_and_kogito_cache.outputs.cache-hit }}
       run: |
         echo "STEP: Bootstrap"
         cd ${{ inputs.working_dir }}
diff --git a/packages/drools-and-kogito/package.json 
b/packages/drools-and-kogito/package.json
index bb8627017d6..55cd9f7de13 100644
--- a/packages/drools-and-kogito/package.json
+++ b/packages/drools-and-kogito/package.json
@@ -4,7 +4,8 @@
   "version": "0.0.0",
   "keywords": [],
   "scripts": {
-    "install": "node install.js"
+    "install": "node install.js",
+    "print-cache-key": "node printCacheKey.js"
   },
   "dependencies": {},
   "devDependencies": {
diff --git a/packages/drools-and-kogito/printCacheKey.js 
b/packages/drools-and-kogito/printCacheKey.js
new file mode 100644
index 00000000000..730d8b62d2a
--- /dev/null
+++ b/packages/drools-and-kogito/printCacheKey.js
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+// This simple script returns a unique key used by the `bootstrap` GitHub 
Action to save and restore the a `drools-and-kogito` build.
+const { env } = require("./env");
+const repos = env.droolsAndKogito.repos;
+
+console.log(
+  
`droolsRepoGitRef-${repos.drools.gitRef}-optaplannerRepoGitRef-${repos.optaplanner.gitRef}-kogitoRuntimesRepoGitRef-${repos.kogitoRuntimes.gitRef}-kogitoAppsRepoGitRef-${repos.kogitoApps.gitRef}`
+);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to