From c5000bf6638c8f8ecdfb6ad143d8dc93a51ead14 Mon Sep 17 00:00:00 2001 From: Andy Jordan <2226434+andyleejordan@users.noreply.github.com> Date: Mon, 11 Dec 2023 17:30:18 -0800 Subject: [PATCH] Test GitHub Actions for CI --- .github/workflows/ci-test.yml | 71 +++++++++++++++++++++++++++++++ .vsts-ci/azure-pipelines-ci.yml | 39 +++++------------ .vsts-ci/templates/ci-general.yml | 26 +++++------ docs/development.md | 2 +- vscode-powershell.build.ps1 | 11 ++++- 5 files changed, 103 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/ci-test.yml diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml new file mode 100644 index 0000000000..b829bc3e11 --- /dev/null +++ b/.github/workflows/ci-test.yml @@ -0,0 +1,71 @@ +name: CI Tests + +on: + push: + branches: [ main ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ main ] + paths-ignore: [ '**/*.md' ] + merge_group: + types: [ checks_requested ] + +jobs: + os_matrix: + strategy: + matrix: + os: [ windows-latest, macos-latest, ubuntu-latest ] + runs-on: ${{ matrix.os }} + env: + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + DOTNET_GENERATE_ASPNET_CERTIFICATE: false + DISPLAY: ':99.0' + defaults: + run: + shell: pwsh + working-directory: vscode-powershell + steps: + - name: Checkout PowerShellEditorServices + uses: actions/checkout@v4 + with: + repository: PowerShell/PowerShellEditorServices + path: PowerShellEditorServices + ref: andyleejordan/github-ci + - name: Checkout vscode-powershell + uses: actions/checkout@v4 + with: + path: vscode-powershell + - name: Install dotnet + uses: actions/setup-dotnet@v4 + with: + cache: true + cache-dependency-path: 'PowerShellEditorServices/**/packages.lock.json' + dotnet-version: | + 6.0.x + 7.0.x + - name: Install PSResources + run: ../PowerShellEditorServices/tools/installPSResources.ps1 + - uses: actions/setup-node@v4 + with: + node-version: 18 + cache: npm + cache-dependency-path: vscode-powershell/package-lock.json + - name: Start X virtual framebuffer + if: matrix.os == 'ubuntu-latest' + shell: bash + run: /usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & + - name: Build, test and package + run: Invoke-Build + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + if: always() + with: + name: vscode-powershell-vsix-${{ matrix.os }} + path: vscode-powershell/powershell-*.vsix + - name: Upload test results + uses: actions/upload-artifact@v3 + if: always() + with: + name: vscode-powershell-test-results-${{ matrix.os }} + path: '**/test-results.xml' diff --git a/.vsts-ci/azure-pipelines-ci.yml b/.vsts-ci/azure-pipelines-ci.yml index 8781747ace..d37b41213c 100644 --- a/.vsts-ci/azure-pipelines-ci.yml +++ b/.vsts-ci/azure-pipelines-ci.yml @@ -1,19 +1,22 @@ name: CI-$(Build.SourceBranchName)-$(Date:yyyyMMdd)$(Rev:.rr) +pr: none + trigger: - - gh-readonly-queue/main/* -pr: - paths: - exclude: - - '**/*.md' + branches: + include: + - release variables: # Don't download unneeded packages - - name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE + - name: DOTNET_NOLOGO value: 'true' # Improve performance by not sending telemetry - name: DOTNET_CLI_TELEMETRY_OPTOUT value: 'true' + # Improve performance by not generating certificates + - name: DOTNET_GENERATE_ASPNET_CERTIFICATE + value: 'false' resources: repositories: @@ -25,34 +28,14 @@ resources: jobs: - job: windows2022 - displayName: Windows 2022 PowerShell 5.1 - pool: - vmImage: windows-2022 - steps: - - template: templates/ci-general.yml - parameters: - pwsh: false - continueOnError: true - -- job: windows2022pwsh - displayName: Windows 2022 PowerShell 7 + displayName: Windows 2022 pool: vmImage: windows-2022 steps: - template: templates/ci-general.yml - job: windows2019 - displayName: Windows 2019 PowerShell 5.1 - pool: - vmImage: windows-2019 - steps: - - template: templates/ci-general.yml - parameters: - pwsh: false - continueOnError: true - -- job: windows2019pwsh - displayName: Windows 2019 PowerShell 7 + displayName: Windows 2019 pool: vmImage: windows-2019 steps: diff --git a/.vsts-ci/templates/ci-general.yml b/.vsts-ci/templates/ci-general.yml index 53e7ac0e52..abba8d3854 100644 --- a/.vsts-ci/templates/ci-general.yml +++ b/.vsts-ci/templates/ci-general.yml @@ -1,7 +1,4 @@ parameters: - - name: pwsh - type: boolean - default: true - name: usePipelineArtifact type: boolean default: false @@ -34,11 +31,6 @@ steps: archiveFilePatterns: $(Pipeline.Workspace)/PowerShellEditorServices.zip destinationFolder: $(Build.SourcesDirectory)/vscode-powershell/modules -- task: NodeTool@0 - displayName: Install Node.js - inputs: - versionSpec: 16.x - - task: UseDotNet@2 condition: not(${{ parameters.usePipelineArtifact }}) displayName: Install .NET 7.0.x SDK @@ -55,19 +47,23 @@ steps: version: 6.0.x performMultiLevelLookup: true -# The build script is always run with PowerShell Core +- task: UseNode@1 + inputs: + version: 18.x + +# We don't just use installPSResources.ps1 because we haven't always cloned PowerShellEditorServices - task: PowerShell@2 displayName: Build and package inputs: targetType: inline + pwsh: true script: | - Install-Module InvokeBuild -Scope CurrentUser -Force - Install-Module platyPS -Scope CurrentUser -Force + Install-Module -Name InvokeBuild -Scope CurrentUser -Force + Install-Module -Name platyPS -Scope CurrentUser -Force Invoke-Build -Configuration Release Package $PackageJson = Get-Content -Raw package.json | ConvertFrom-Json Write-Host "##vso[task.setvariable variable=vsixPath]$(Resolve-Path powershell-$($PackageJson.version).vsix)" workingDirectory: $(Build.SourcesDirectory)/vscode-powershell - pwsh: true # Necessary on Linux to run VS Code unit tests - bash: | @@ -75,19 +71,17 @@ steps: displayName: Start X virtual framebuffer condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) -# Tests in particular are run with either PowerShell Core or Windows PowerShell - task: PowerShell@2 displayName: Run unit tests inputs: targetType: inline + pwsh: true script: | $PSVersionTable Get-ChildItem env: Get-Module -ListAvailable Pester - Install-Module InvokeBuild -Scope CurrentUser -Force Invoke-Build -Configuration Release Test workingDirectory: $(Build.SourcesDirectory)/vscode-powershell - pwsh: ${{ parameters.pwsh }} env: DISPLAY: ':99.0' @@ -95,13 +89,13 @@ steps: displayName: Assert PowerShellEditorServices release configuration inputs: targetType: inline + pwsh: true script: | $assembly = [Reflection.Assembly]::LoadFile('$(Build.SourcesDirectory)/vscode-powershell/modules/PowerShellEditorServices.VSCode/bin/Microsoft.PowerShell.EditorServices.VSCode.dll') if ($assembly.GetCustomAttributes([System.Diagnostics.DebuggableAttribute], $true).IsJITOptimizerDisabled) { Write-Host '##vso[task.LogIssue type=error;]PowerShell Editor Services bits were not built in release configuration!' exit 1 } - pwsh: true - publish: $(vsixPath) artifact: vscode-powershell-vsix-$(System.JobId) diff --git a/docs/development.md b/docs/development.md index 24fdb32eaa..66c2024f5c 100644 --- a/docs/development.md +++ b/docs/development.md @@ -12,7 +12,7 @@ 3. Follow the [development instructions](https://github.com/PowerShell/PowerShellEditorServices#development) for PowerShell Editor Services. **You will need to complete this step before proceeding**. -4. Install [Node.js](https://nodejs.org/en/) 16.x or higher. +4. Install [Node.js](https://nodejs.org/en/) 18.x or higher. 5. Install [Visual Studio Code](https://code.visualstudio.com). Open the multi-root workspace file in this repo, `extension-dev.code-workspace`. diff --git a/vscode-powershell.build.ps1 b/vscode-powershell.build.ps1 index 3c164dc25d..bdca9c9700 100644 --- a/vscode-powershell.build.ps1 +++ b/vscode-powershell.build.ps1 @@ -133,7 +133,16 @@ task Package Build, { Assert-Build ($packageJson.version -eq $packageVersion) Write-Host "`n### Packaging powershell-$packageVersion.vsix`n" -ForegroundColor Green - Assert-Build ((Get-Item ./modules).LinkType -ne "SymbolicLink") "Packaging requires a copy of PSES, not a symlink!" + + # Packaging requires a copy of the modules folder, not a symbolic link. But + # we might have built in Debug configuration, not Release, and still want to + # package it. So delete the symlink and copy what we just built. + if ((Get-Item ./modules -ErrorAction SilentlyContinue).LinkType -eq "SymbolicLink") { + Write-Host "`n### PSES is a symbolic link, replacing with copy!" -ForegroundColor Green + Remove-BuildItem ./modules + Copy-Item -Recurse -Force "$(Split-Path (Get-EditorServicesPath))/module" ./modules + } + if (Test-IsPreRelease) { Write-Host "`n### This is a pre-release!`n" -ForegroundColor Green Invoke-BuildExec { & npm run package -- --pre-release }