Skip to content

Commit

Permalink
Merge pull request #765 from StefanMaron/cachePlatformArtifacts
Browse files Browse the repository at this point in the history
Improve workflow on retrieving platform artifacts
  • Loading branch information
Arthurvdv authored Sep 14, 2024
2 parents b21d32a + dcf0be0 commit 82f4759
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 10 deletions.
16 changes: 7 additions & 9 deletions .github/actions/dotnet-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@ runs:
shell: pwsh
run: dotnet restore BusinessCentral.LinterCop

- name: Download platform artifact
shell: pwsh
env:
ASSET_URI: ${{ inputs.al-asset-uri }}
run: Invoke-WebRequest $env:ASSET_URI -OutFile ALLanguage.vsix

- name: Unzip vsix
shell: pwsh
run: 7z x ALLanguage.vsix "-oALLanguage" "extension/bin/Analyzers" -r
- name: Get AL Language platform artifacts
id: get-platform-artifacts
uses: ./.github/actions/platform-artifacts
with:
version-number: ${{ inputs.al-version-number }}
asset-uri: ${{ inputs.al-asset-uri }}
target-path: ALLanguage

- name: Set AssemblyInfo
shell: pwsh
Expand Down
51 changes: 51 additions & 0 deletions .github/actions/platform-artifacts/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Download AL Language platform artifacts
description: ""

inputs:
version-number:
required: true
description: The version number of the corresponding AL Language
asset-uri:
required: true
description: The asset uri for retrieving the VSIXPackages of the AL Language
target-path:
required: true
description: Path to store the artifacts

runs:
using: composite
steps:
- name: Get platform artifact from cache
id: get_platform_artifact
uses: actions/cache/restore@v4
with:
path: ${{ inputs.target-path }}
key: al-platform-artifact-${{ inputs.version-number }}
fail-on-cache-miss: false

- name: Download platform artifact
id: download_platform_artifact
if: steps.get_platform_artifact.outputs.cache-hit != 'true'
shell: pwsh
env:
ASSET_URI: ${{ inputs.asset-uri }}
RUNNER_TEMP: ${{ runner.temp }}
run: |
$downloadFilePath = Join-Path $env:RUNNER_TEMP 'ALLanguage.vsix'
Invoke-WebRequest $env:ASSET_URI -OutFile $downloadFilePath
echo "path=$($downloadFilePath)" >> $env:GITHUB_OUTPUT
- name: Extract platform artifact
if: steps.get_platform_artifact.outputs.cache-hit != 'true'
shell: pwsh
env:
ARCHIVE_PATH: ${{ steps.download_platform_artifact.outputs.path }}
run: 7z x $env:ARCHIVE_PATH "-o${{ inputs.target-path }}" "extension/bin/Analyzers" -r

- name: Add platform artifact to cache
id: add_hash
if: steps.get_platform_artifact.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ inputs.target-path }}
key: al-platform-artifact-${{ inputs.version-number }}
3 changes: 2 additions & 1 deletion .github/workflows/DailyCheckForUpdates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ jobs:
Write-Host "Calculated hash is: $($hashString)"
echo "hash=$($hashString)" >> $env:GITHUB_OUTPUT
- uses: actions/cache/restore@v4
- name: Get hash value from cache
id: get_hash
uses: actions/cache/restore@v4
with:
path: ${{ runner.temp }}/hash.txt
key: al-marketplace-hash-${{ steps.generate_hash.outputs.hash }}
Expand Down

0 comments on commit 82f4759

Please sign in to comment.