Skip to content

Commit

Permalink
Setup GitHub Actions CI (#2018)
Browse files Browse the repository at this point in the history
And CFS.
  • Loading branch information
andyleejordan authored Aug 6, 2024
1 parent d1a1bcb commit e36d82c
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 4 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
ci:
name: pester
strategy:
matrix:
os: [ windows-latest, macos-latest, ubuntu-latest ]
runs-on: ${{ matrix.os }}
env:
DOTNET_NOLOGO: true
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dotnet
uses: actions/setup-dotnet@v4
with:
cache: true
cache-dependency-path: '**/*.csproj'

- name: Install PSResources
run: ./tools/installPSResources.ps1
shell: pwsh

- name: Build
run: ./build.ps1 -Configuration Release -All
shell: pwsh

- name: Test
run: ./build.ps1 -Test
shell: pwsh

- name: Test Windows PowerShell
run: |
Install-Module Pester -Scope CurrentUser -Force -SkipPublisherCheck
./build.ps1 -Test
if: matrix.os == 'windows-latest'
shell: powershell

- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: PSScriptAnalyzer-tests-${{ matrix.os }}
path: testResults.xml
4 changes: 2 additions & 2 deletions NuGet.Config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="PowerShellCore_PublicPackages" value="https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/nuget/v3/index.json" />
</packageSources>
</configuration>
3 changes: 1 addition & 2 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ function Test-ScriptAnalyzer
else {
$testModulePath = Join-Path "${projectRoot}" -ChildPath out
}
$testResultsFile = "'$(Join-Path ${projectRoot} -childPath TestResults.xml)'"
$testScripts = "'${projectRoot}\Tests\Build','${projectRoot}\Tests\Engine','${projectRoot}\Tests\Rules','${projectRoot}\Tests\Documentation'"
try {
if ( $major -lt 5 ) {
Expand All @@ -395,7 +394,7 @@ function Test-ScriptAnalyzer
$savedModulePath = $env:PSModulePath
$env:PSModulePath = "${testModulePath}{0}${env:PSModulePath}" -f [System.IO.Path]::PathSeparator
$analyzerPsd1Path = Join-Path -Path $script:destinationDir -ChildPath "$analyzerName.psd1"
$scriptBlock = [scriptblock]::Create("Import-Module '$analyzerPsd1Path'; Invoke-Pester -Path $testScripts")
$scriptBlock = [scriptblock]::Create("Import-Module '$analyzerPsd1Path'; Invoke-Pester -Path $testScripts -CI")
if ( $InProcess ) {
& $scriptBlock
}
Expand Down
13 changes: 13 additions & 0 deletions tools/installPSResources.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

$ErrorActionPreference = 'Stop'

Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null
if ($PSVersionTable.PSVersion.Major -lt 6) {
throw "The build script requires PowerShell 7!"
}

# TODO: Switch to Install-PSResource when CI uses PowerShell 7.4
Install-Module -Name platyPS -Scope CurrentUser
Install-Module -Name Pester -Scope CurrentUser

0 comments on commit e36d82c

Please sign in to comment.