@@ -31,40 +31,57 @@ inputs:
3131runs :
3232 using : composite
3333 steps :
34- - name : Setup NodeJs Extensions
34+ - name : Set up Environment
35+ id : set-up-environment
3536 shell : pwsh
3637 run : |
3738 '${{ github.action_path }}' >> $Env:GITHUB_PATH
3839
39- $LombiqNodeJsExtensions = $(Resolve-Path '${{ github.action_path }}/../../../Lombiq.NodeJs.Extensions').Path
40- Write-Output "LOMBIQ_NODEJS_EXTENSIONS=$LombiqNodeJsExtensions "
41- "LOMBIQ_NODEJS_EXTENSIONS=$LombiqNodeJsExtensions " >> $Env:GITHUB_ENV
40+ $nodeJsExtensionsPath = $(Resolve-Path '${{ github.action_path }}/../../../Lombiq.NodeJs.Extensions').Path
41+ Write-Output "LOMBIQ_NODEJS_EXTENSIONS=$nodeJsExtensionsPath "
42+ "LOMBIQ_NODEJS_EXTENSIONS=$nodeJsExtensionsPath " >> $Env:GITHUB_ENV
4243 "LOMBIQ_NODEJS_EXTENSIONS_GITHUB_ACTIONS=true" >> $Env:GITHUB_ENV
4344 "LOMBIQ_NODEJS_EXTENSIONS_GITHUB_ACTIONS_ROOT=$PWD" >> $Env:GITHUB_ENV
4445 "LOMBIQ_NODEJS_EXTENSIONS_WARN_AS_ERROR=true" >> $Env:GITHUB_ENV
4546
46- # Make sure to keep the version number in sync with the matching command in
47- # Lombiq.NodeJs.Extensions/build/NodeJsExtensionsNpmPackage.targets.
48- corepack enable
49- corepack prepare pnpm@8.15.9+sha1.aa4bc353b5f59fe1f1df5d802ce049ddf7f3c60e --activate
47+ # Read the packageManager from the package.json to be able to provide it to the pnpm setup action. While it can
48+ # read it from the file, it can't access the file when the lint workflow is run from a parent workflow.
49+ $packageJsonPath = Join-Path -Path $nodeJsExtensionsPath -ChildPath 'package.json'
50+ $packageJsonContent = Get-Content -Path $packageJsonPath -Raw | ConvertFrom-Json -AsHashTable
51+ $packageManager = $packageJsonContent['packageManager']
52+ $pnpmVersion = $packageManager.Split('@')[1]
53+ Write-Output "PNPM version in Node.js Extensions: $pnpmVersion"
54+
55+ "pnpm-version=$pnpmVersion" >> $Env:GITHUB_OUTPUT
56+
57+ # Relying on corepack, and also running pnpm setup is not enough, PNPM operations will fail while telling to run
58+ # pnpm setup. Manually setting up PNPM_HOME and adding it to PATH didn't help either. So, using this action.
59+ - name : Set up PNPM
60+ uses : pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
61+ with :
62+ version : ${{ steps.set-up-environment.outputs.pnpm-version }}
63+
64+ - name : Install Dependencies
65+ shell : pwsh
66+ run : |
67+ cd $Env:LOMBIQ_NODEJS_EXTENSIONS
5068
51- cd $LombiqNodeJsExtensions
5269 pnpm install --prefer-offline --no-frozen-lockfile
5370 pnpm link --global
5471
5572 - name : Execute Linting
5673 shell : pwsh
5774 run : |
58- $library = $Env:LOMBIQ_NODEJS_EXTENSIONS
75+ $libraryPath = $Env:LOMBIQ_NODEJS_EXTENSIONS
5976
60- Invoke-NodeJsLinter -LibraryPath $library -Type scripts -Paths '${{ inputs.scripts }}'
61- Invoke-NodeJsLinter -LibraryPath $library -Type styles -Paths '${{ inputs.styles-scss }}'
62- Invoke-NodeJsLinter -LibraryPath $library -Type styles-css -Paths '${{ inputs.styles-css }}'
77+ Invoke-NodeJsLinter -LibraryPath $libraryPath -Type scripts -Paths '${{ inputs.scripts }}'
78+ Invoke-NodeJsLinter -LibraryPath $libraryPath -Type styles -Paths '${{ inputs.styles-scss }}'
79+ Invoke-NodeJsLinter -LibraryPath $libraryPath -Type styles-css -Paths '${{ inputs.styles-css }}'
6380
6481 if ('${{ inputs.lint-markdown }}' -ieq 'true')
6582 {
6683 Write-Output 'Markdown linting is enabled.'
67- Invoke-NodeJsLinter -LibraryPath $library -Type markdown -Paths '{ ".": { "markdown": { "source": "." } } }'
84+ Invoke-NodeJsLinter -LibraryPath $libraryPath -Type markdown -Paths '{ ".": { "markdown": { "source": "." } } }'
6885 }
6986 else
7087 {
0 commit comments