From 2d7748620318566b985d866b11837f5aac565c4c Mon Sep 17 00:00:00 2001 From: Rello Date: Mon, 31 Aug 2026 14:13:54 +0200 Subject: [PATCH 1/2] fix(ci): cache Windows Craft dependencies Cache the dependency-only Craft environment using the current CraftMaster and blueprint revisions. Remove the unused OpenCppCoverage setup and use a shallow checkout. Signed-off-by: Rello Assisted-by: Codex:GPT-5 --- .github/workflows/windows-build-and-test.yml | 53 +++++++++++++++----- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/.github/workflows/windows-build-and-test.yml b/.github/workflows/windows-build-and-test.yml index f0b08dca6f4cc..03ebd3fe57429 100644 --- a/.github/workflows/windows-build-and-test.yml +++ b/.github/workflows/windows-build-and-test.yml @@ -10,18 +10,48 @@ jobs: runs-on: windows-2022 env: CRAFT_TARGET: windows-msvc2022_64-cl - COBERTURA_COVERAGE_FILE: ${{ github.workspace }}\cobertura_coverage\coverage.xml CRAFT_MASTER_LOCATION: ${{ github.workspace }}\CraftMaster CRAFT_MASTER_CONFIG: ${{ github.workspace }}\craftmaster.ini + PYTHON_VERSION: '3.12' steps: - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + fetch-depth: 1 - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: - python-version: '3.12' + python-version: ${{ env.PYTHON_VERSION }} + + - name: Resolve Craft dependency revisions + id: craft-revisions + shell: pwsh + run: | + function remoteRevision($repository, $ref) { + $revision = git ls-remote $repository $ref + if($LASTEXITCODE -ne 0 -or !$revision) { + throw "Could not resolve $ref from $repository." + } + return ($revision -split '\s+')[0] + } + + $craftMasterRevision = remoteRevision "https://invent.kde.org/packaging/craftmaster.git" "HEAD" + $kdeBlueprintRevision = remoteRevision "https://github.com/nextcloud/craft-blueprints-kde.git" "refs/heads/stable-34.0" + $nextcloudBlueprintRevision = remoteRevision "https://github.com/nextcloud/craft-blueprints-nextcloud.git" "refs/heads/stable-34.0" + "key=$craftMasterRevision-$kdeBlueprintRevision-$nextcloudBlueprintRevision" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + + - name: Restore Craft dependencies + id: craft-cache + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: | + ${{ env.CRAFT_MASTER_LOCATION }} + ${{ env.CRAFT_MASTER_CONFIG }} + ${{ github.workspace }}\craft-clone + ${{ github.workspace }}\${{ env.CRAFT_TARGET }} + key: ${{ runner.os }}-craft-v1-${{ env.CRAFT_TARGET }}-python-${{ env.PYTHON_VERSION }}-${{ steps.craft-revisions.outputs.key }} + - name: Install Craft Master with Nextcloud Client Deps + if: steps.craft-cache.outputs.cache-hit != 'true' shell: pwsh run: | & cmd /C "git clone -q --depth=1 https://invent.kde.org/packaging/craftmaster.git ${{ env.CRAFT_MASTER_LOCATION }} 2>&1" @@ -40,14 +70,12 @@ jobs: id: cache-install-opencppcoverage uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 with: - path: C:\Program Files\OpenCppCoverage - key: ${{ runner.os }}-cache-install-opencppcoverage - - - name: Install OpenCppCoverage - if: steps.cache-install-opencppcoverage.outputs.cache-hit != 'true' - shell: pwsh - run: | - choco install opencppcoverage + path: | + ${{ env.CRAFT_MASTER_LOCATION }} + ${{ env.CRAFT_MASTER_CONFIG }} + ${{ github.workspace }}\craft-clone + ${{ github.workspace }}\${{ env.CRAFT_TARGET }} + key: ${{ runner.os }}-craft-v1-${{ env.CRAFT_TARGET }}-python-${{ env.PYTHON_VERSION }}-${{ steps.craft-revisions.outputs.key }} #- name: Cache Install inkscape # id: cache-install-inkscape @@ -65,7 +93,6 @@ jobs: - name: Setup PATH shell: pwsh run: | - echo "C:\Program Files\OpenCppCoverage" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append echo "${{ github.workspace }}\${{ env.CRAFT_TARGET }}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - name: Compile @@ -78,7 +105,7 @@ jobs: craft --src-dir ${{ github.workspace }} nextcloud-client - - name: Run tests with coverage + - name: Run tests shell: pwsh run: | function runTests() { From c13683c66237ff317d2ad0e0893bbe7e8cd8611c Mon Sep 17 00:00:00 2001 From: Rello Date: Tue, 1 Sep 2026 12:05:47 +0200 Subject: [PATCH 2/2] fix(ci): derive Craft cache refs from config Read the pinned Craft revision and both blueprint refs from craftmaster.ini. Reuse the blueprint refs for repository setup and resolve their current commits for the cache key. Preserve the dependency-only cache save in the backport. Signed-off-by: Rello Assisted-by: Codex:GPT-5 --- .github/workflows/windows-build-and-test.yml | 34 ++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/.github/workflows/windows-build-and-test.yml b/.github/workflows/windows-build-and-test.yml index 03ebd3fe57429..c8ba90d2c670d 100644 --- a/.github/workflows/windows-build-and-test.yml +++ b/.github/workflows/windows-build-and-test.yml @@ -26,6 +26,19 @@ jobs: id: craft-revisions shell: pwsh run: | + function configValue($key) { + $escapedKey = [regex]::Escape($key) + $matches = @(Select-String -Path "${{ env.CRAFT_MASTER_CONFIG }}" -Pattern "^\s*$escapedKey\s*=\s*(.+?)\s*$") + if($matches.Count -ne 1) { + throw "Expected exactly one $key value in craftmaster.ini." + } + return $matches[0].Matches[0].Groups[1].Value.Trim() + } + + $craftRevision = configValue "CraftRevision" + $kdeBlueprintRef = configValue "craft/craft-blueprints-kde.revision" + $nextcloudBlueprintRef = configValue "craft/craft-blueprints-nextcloud.revision" + function remoteRevision($repository, $ref) { $revision = git ls-remote $repository $ref if($LASTEXITCODE -ne 0 -or !$revision) { @@ -34,10 +47,13 @@ jobs: return ($revision -split '\s+')[0] } - $craftMasterRevision = remoteRevision "https://invent.kde.org/packaging/craftmaster.git" "HEAD" - $kdeBlueprintRevision = remoteRevision "https://github.com/nextcloud/craft-blueprints-kde.git" "refs/heads/stable-34.0" - $nextcloudBlueprintRevision = remoteRevision "https://github.com/nextcloud/craft-blueprints-nextcloud.git" "refs/heads/stable-34.0" - "key=$craftMasterRevision-$kdeBlueprintRevision-$nextcloudBlueprintRevision" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + $kdeBlueprintRevision = remoteRevision "https://github.com/nextcloud/craft-blueprints-kde.git" "refs/heads/$kdeBlueprintRef" + $nextcloudBlueprintRevision = remoteRevision "https://github.com/nextcloud/craft-blueprints-nextcloud.git" "refs/heads/$nextcloudBlueprintRef" + @( + "kde_ref=$kdeBlueprintRef" + "nextcloud_ref=$nextcloudBlueprintRef" + "key=$craftRevision-$kdeBlueprintRevision-$nextcloudBlueprintRevision" + ) | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append - name: Restore Craft dependencies id: craft-cache @@ -61,14 +77,14 @@ jobs: if($LASTEXITCODE -ne 0) {exit $LASTEXITCODE} } - craft --add-blueprint-repository "https://github.com/nextcloud/craft-blueprints-kde.git|stable-34.0|" - craft --add-blueprint-repository "https://github.com/nextcloud/craft-blueprints-nextcloud.git|stable-34.0|" + craft --add-blueprint-repository "https://github.com/nextcloud/craft-blueprints-kde.git|${{ steps.craft-revisions.outputs.kde_ref }}|" + craft --add-blueprint-repository "https://github.com/nextcloud/craft-blueprints-nextcloud.git|${{ steps.craft-revisions.outputs.nextcloud_ref }}|" craft craft craft --install-deps nextcloud-client - - name: Cache Install OpenCppCoverage - id: cache-install-opencppcoverage - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + - name: Save Craft dependencies + if: steps.craft-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: | ${{ env.CRAFT_MASTER_LOCATION }}