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

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 515c4ad38b33b02fd38a7a569ea451b7e113bdb3
Author: Szymon Janc <[email protected]>
AuthorDate: Wed Oct 14 11:21:24 2026 +0200

    ci: Share repositories cache between systems
    
    Repositories cache was saved only by Linux job, but cache key was
    specific to system, so Windows and macOS jobs never found cache and
    always downloaded all repositories.
    
    Use single cache created on Linux for all systems. Repositories
    restored on Windows may appear modified (e.g. due to symlinks or line
    endings) and newt silently skips upgrade of modified repositories, so
    those are reset and removed if still modified, so that newt clones
    them again.
    
    Assisted-by: Claude:claude-opus-5-5
---
 .github/actions/newt-project/action.yml | 35 +++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/.github/actions/newt-project/action.yml 
b/.github/actions/newt-project/action.yml
index 0d7da005d..f4ad58d8b 100644
--- a/.github/actions/newt-project/action.yml
+++ b/.github/actions/newt-project/action.yml
@@ -21,9 +21,10 @@ name: Set up newt project
 description: >
   Create newt project for testing current commit. External repositories
   are restored from cache and then upgraded by newt, so only changes
-  since cache was created are downloaded. Cache should be saved only by
-  one job and only from master branch, since only caches from default
-  branch are available to pull requests.
+  since cache was created are downloaded. Cache is created on Linux and
+  shared with other systems. Cache should be saved only by one job and
+  only from master branch, since only caches from default branch are
+  available to pull requests.
 
 inputs:
   project:
@@ -35,7 +36,7 @@ inputs:
     required: false
     default: build
   save-cache:
-    description: Save repositories to cache (master branch only)
+    description: Save repositories to cache (Linux and master branch only)
     required: false
     default: 'false'
 
@@ -48,7 +49,7 @@ runs:
       run: |
         newt new "${{ inputs.path }}"
         cp -f "${{ inputs.project }}" "${{ inputs.path }}/project.yml"
-        echo "cache-prefix=newt-repos-${{ runner.os }}-" >> "$GITHUB_OUTPUT"
+        echo "cache-prefix=newt-repos-shared-" >> "$GITHUB_OUTPUT"
 
     - name: Restore repositories from cache
       id: restore
@@ -57,6 +58,26 @@ runs:
         path: ${{ inputs.path }}/repos
         key: ${{ steps.project.outputs.cache-prefix }}${{ github.sha }}
         restore-keys: ${{ steps.project.outputs.cache-prefix }}
+        # Cache is created on Linux, Windows needs this to restore it
+        enableCrossOsArchive: true
+
+    # Repositories restored on Windows from cache created on Linux may
+    # appear modified (e.g. due to symlinks or line endings). newt silently
+    # skips upgrade of modified repositories, so reset them to match local
+    # git settings and remove those still modified, so that they are
+    # cloned again.
+    - name: Clean up restored repositories
+      if: runner.os == 'Windows' && steps.restore.outputs.cache-matched-key != 
''
+      shell: bash
+      working-directory: ${{ inputs.path }}
+      run: |
+        for d in repos/*/; do
+          git -C "$d" reset -q --hard
+          if [ -n "$(git -C "$d" status --porcelain --untracked-files=no)" ]; 
then
+            echo "::warning::$d modified after restore from cache, removing"
+            rm -rf "$d"
+          fi
+        done
 
     # First upgrade uses master version of apache-mynewt-core to get all
     # repositories, then core is switched to tested commit and upgraded
@@ -86,10 +107,12 @@ runs:
 
     - name: Save repositories to cache
       if: >-
-        inputs.save-cache == 'true' && github.ref == 'refs/heads/master' &&
+        inputs.save-cache == 'true' && runner.os == 'Linux' &&
+        github.ref == 'refs/heads/master' &&
         github.event_name != 'pull_request' &&
         steps.restore.outputs.cache-matched-key != steps.key.outputs.key
       uses: actions/cache/save@v6
       with:
         path: ${{ inputs.path }}/repos
         key: ${{ steps.key.outputs.key }}
+        enableCrossOsArchive: true

Reply via email to