Skip to content

Commit

Permalink
Test GitHub Actions for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
andyleejordan committed Dec 12, 2023
1 parent 040518b commit c5000bf
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 46 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
@@ -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'
39 changes: 11 additions & 28 deletions .vsts-ci/azure-pipelines-ci.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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:
Expand Down
26 changes: 10 additions & 16 deletions .vsts-ci/templates/ci-general.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
parameters:
- name: pwsh
type: boolean
default: true
- name: usePipelineArtifact
type: boolean
default: false
Expand Down Expand Up @@ -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
Expand All @@ -55,53 +47,55 @@ 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: |
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
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'

- task: PowerShell@2
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)
Expand Down
2 changes: 1 addition & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
11 changes: 10 additions & 1 deletion vscode-powershell.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit c5000bf

Please sign in to comment.