From f73c9adbdba7a2d92a3231f8e8282833a9d073b2 Mon Sep 17 00:00:00 2001 From: Andy Jordan <2226434+andyleejordan@users.noreply.github.com> Date: Tue, 13 Feb 2024 09:58:42 -0800 Subject: [PATCH] Add Azure NPM registry to CI test workflow --- .github/workflows/ci-test.yml | 6 ++++++ .github/workflows/npmrc | 13 +++++++++++++ .vsts-ci/templates/publish-markets.yml | 2 +- vscode-powershell.build.ps1 | 4 ++-- 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/npmrc diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index 5b957f160e..480b947d65 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -54,6 +54,10 @@ jobs: cache: npm cache-dependency-path: vscode-powershell/package-lock.json + - name: Deploy NPM configuration + shell: pwsh + run: Copy-Item .github/workflows/npmrc .npmrc + - name: Start X virtual framebuffer if: matrix.os == 'ubuntu-latest' run: /usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & @@ -61,6 +65,8 @@ jobs: - name: Build, test and package shell: pwsh run: Invoke-Build + env: + NPM_AUTH_TOKEN: ${{ secrets.AZURE_NPM_TOKEN }} - name: Upload build artifacts uses: actions/upload-artifact@v4 diff --git a/.github/workflows/npmrc b/.github/workflows/npmrc new file mode 100644 index 0000000000..b40e145d9c --- /dev/null +++ b/.github/workflows/npmrc @@ -0,0 +1,13 @@ +; This requires NPM_AUTH_TOKEN to be available as a base64 encoded secret, since +; Azure DevOps does not support actual auth tokens. + +; begin auth token +//pkgs.dev.azure.com/powershell-rel/PowerShellEditorServices/_packaging/PSESFeed/npm/registry/:username=powershell-rel +//pkgs.dev.azure.com/powershell-rel/PowerShellEditorServices/_packaging/PSESFeed/npm/registry/:_password=${NPM_AUTH_TOKEN} +//pkgs.dev.azure.com/powershell-rel/PowerShellEditorServices/_packaging/PSESFeed/npm/registry/:email=powershell-rel +//pkgs.dev.azure.com/powershell-rel/PowerShellEditorServices/_packaging/PSESFeed/npm/:username=powershell-rel +//pkgs.dev.azure.com/powershell-rel/PowerShellEditorServices/_packaging/PSESFeed/npm/:_password=${NPM_AUTH_TOKEN} +//pkgs.dev.azure.com/powershell-rel/PowerShellEditorServices/_packaging/PSESFeed/npm/:email=powershell-rel +; end auth token +registry=https://pkgs.dev.azure.com/powershell-rel/PowerShellEditorServices/_packaging/PSESFeed/npm/registry/ +always-auth=true diff --git a/.vsts-ci/templates/publish-markets.yml b/.vsts-ci/templates/publish-markets.yml index 0cadb54960..16f686a5ae 100644 --- a/.vsts-ci/templates/publish-markets.yml +++ b/.vsts-ci/templates/publish-markets.yml @@ -10,7 +10,7 @@ steps: workingFile: .npmrc - pwsh: | - npm ci --loglevel=error + npm ci --loglevel=error --ignore-scripts Import-Module $(Build.SourcesDirectory)/tools/VersionTools.psm1 $Version = Get-Version -RepositoryName vscode-powershell $PackageVersion = Get-MajorMinorPatch -Version $Version diff --git a/vscode-powershell.build.ps1 b/vscode-powershell.build.ps1 index bdca9c9700..ad75b91bbf 100644 --- a/vscode-powershell.build.ps1 +++ b/vscode-powershell.build.ps1 @@ -26,8 +26,8 @@ task RestoreNodeModules -If { !(Test-Path ./node_modules) } { Write-Host "`n### Restoring vscode-powershell dependencies`n" -ForegroundColor Green # When in a CI build use the --loglevel=error parameter so that # package install warnings don't cause PowerShell to throw up - if ($env:TF_BUILD) { - Invoke-BuildExec { & npm ci --loglevel=error } + if ($env:CI -or $env:TF_BUILD) { + Invoke-BuildExec { & npm ci --loglevel=error --ignore-scripts } } else { Invoke-BuildExec { & npm install } }