Skip to content

Commit e36d82c

Browse files
Setup GitHub Actions CI (#2018)
And CFS.
1 parent d1a1bcb commit e36d82c

File tree

4 files changed

+69
-4
lines changed

4 files changed

+69
-4
lines changed

Diff for: .github/workflows/ci-test.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
ci:
11+
name: pester
12+
strategy:
13+
matrix:
14+
os: [ windows-latest, macos-latest, ubuntu-latest ]
15+
runs-on: ${{ matrix.os }}
16+
env:
17+
DOTNET_NOLOGO: true
18+
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Install dotnet
24+
uses: actions/setup-dotnet@v4
25+
with:
26+
cache: true
27+
cache-dependency-path: '**/*.csproj'
28+
29+
- name: Install PSResources
30+
run: ./tools/installPSResources.ps1
31+
shell: pwsh
32+
33+
- name: Build
34+
run: ./build.ps1 -Configuration Release -All
35+
shell: pwsh
36+
37+
- name: Test
38+
run: ./build.ps1 -Test
39+
shell: pwsh
40+
41+
- name: Test Windows PowerShell
42+
run: |
43+
Install-Module Pester -Scope CurrentUser -Force -SkipPublisherCheck
44+
./build.ps1 -Test
45+
if: matrix.os == 'windows-latest'
46+
shell: powershell
47+
48+
- name: Upload test results
49+
uses: actions/upload-artifact@v4
50+
if: always()
51+
with:
52+
name: PSScriptAnalyzer-tests-${{ matrix.os }}
53+
path: testResults.xml

Diff for: NuGet.Config

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<packageSources>
44
<clear />
5-
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
5+
<add key="PowerShellCore_PublicPackages" value="https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/nuget/v3/index.json" />
66
</packageSources>
77
</configuration>

Diff for: build.psm1

+1-2
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ function Test-ScriptAnalyzer
386386
else {
387387
$testModulePath = Join-Path "${projectRoot}" -ChildPath out
388388
}
389-
$testResultsFile = "'$(Join-Path ${projectRoot} -childPath TestResults.xml)'"
390389
$testScripts = "'${projectRoot}\Tests\Build','${projectRoot}\Tests\Engine','${projectRoot}\Tests\Rules','${projectRoot}\Tests\Documentation'"
391390
try {
392391
if ( $major -lt 5 ) {
@@ -395,7 +394,7 @@ function Test-ScriptAnalyzer
395394
$savedModulePath = $env:PSModulePath
396395
$env:PSModulePath = "${testModulePath}{0}${env:PSModulePath}" -f [System.IO.Path]::PathSeparator
397396
$analyzerPsd1Path = Join-Path -Path $script:destinationDir -ChildPath "$analyzerName.psd1"
398-
$scriptBlock = [scriptblock]::Create("Import-Module '$analyzerPsd1Path'; Invoke-Pester -Path $testScripts")
397+
$scriptBlock = [scriptblock]::Create("Import-Module '$analyzerPsd1Path'; Invoke-Pester -Path $testScripts -CI")
399398
if ( $InProcess ) {
400399
& $scriptBlock
401400
}

Diff for: tools/installPSResources.ps1

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
$ErrorActionPreference = 'Stop'
5+
6+
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null
7+
if ($PSVersionTable.PSVersion.Major -lt 6) {
8+
throw "The build script requires PowerShell 7!"
9+
}
10+
11+
# TODO: Switch to Install-PSResource when CI uses PowerShell 7.4
12+
Install-Module -Name platyPS -Scope CurrentUser
13+
Install-Module -Name Pester -Scope CurrentUser

0 commit comments

Comments
 (0)