fix(ci): cache Windows Craft dependencies #12220
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors | |
| # SPDX-License-Identifier: GPL-2.0-or-later | |
| name: Windows Build and Test | |
| on: | |
| pull_request: | |
| types: [opened, reopened, synchronize, ready_for_review] | |
| jobs: | |
| build: | |
| if: ${{ !github.event.pull_request.draft }} | |
| name: Windows Build and Test | |
| runs-on: windows-2022 | |
| env: | |
| CRAFT_TARGET: windows-msvc2022_64-cl | |
| CRAFT_MASTER_LOCATION: ${{ github.workspace }}\CraftMaster | |
| CRAFT_MASTER_CONFIG: ${{ github.workspace }}\craftmaster.ini | |
| PYTHON_VERSION: '3.12' | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 1 | |
| - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Resolve Craft dependency revisions | |
| 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) { | |
| throw "Could not resolve $ref from $repository." | |
| } | |
| return ($revision -split '\s+')[0] | |
| } | |
| $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 | |
| 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" | |
| function craft() { | |
| python "${{ env.CRAFT_MASTER_LOCATION }}\CraftMaster.py" --config "${{ env.CRAFT_MASTER_CONFIG }}" --target ${{ env.CRAFT_TARGET }} -c $args | |
| if($LASTEXITCODE -ne 0) {exit $LASTEXITCODE} | |
| } | |
| 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: 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 }} | |
| ${{ 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 | |
| # uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| # with: | |
| # path: C:\Program Files\inkscape | |
| # key: ${{ runner.os }}-cache-install-inkscape | |
| - name: Install inkscape | |
| # if: steps.cache-install-inkscape.outputs.cache-hit != 'true' | |
| shell: pwsh | |
| run: | | |
| choco install inkscape | |
| - name: Setup PATH | |
| shell: pwsh | |
| run: | | |
| echo "${{ github.workspace }}\${{ env.CRAFT_TARGET }}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| - name: Compile | |
| shell: pwsh | |
| run: | | |
| function craft() { | |
| python "${{ env.CRAFT_MASTER_LOCATION }}\CraftMaster.py" --config "${{ env.CRAFT_MASTER_CONFIG }}" --target ${{ env.CRAFT_TARGET }} -c $args | |
| if($LASTEXITCODE -ne 0) {exit $LASTEXITCODE} | |
| } | |
| craft --src-dir ${{ github.workspace }} nextcloud-client | |
| - name: Run tests | |
| shell: pwsh | |
| run: | | |
| function runTests() { | |
| $buildFolder = "${{ github.workspace }}\${{ env.CRAFT_TARGET }}\build\nextcloud-client\work\build" | |
| cd $buildFolder | |
| $binFolder = "$buildFolder\bin" | |
| & ctest --output-on-failure --timeout 300 | |
| } | |
| runTests |