Skip to content

Commit 362bf2d

Browse files
committed
build(ci): Use cache in GitHub Actions
1 parent 81b7aaf commit 362bf2d

3 files changed

Lines changed: 37 additions & 15 deletions

File tree

.github/workflows/ci.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Tests
1+
name: Scoop Core CI Tests
22

33
on:
44
pull_request:
@@ -14,11 +14,14 @@ jobs:
1414
uses: actions/checkout@v2
1515
with:
1616
fetch-depth: 2
17-
- name: Init and Test
17+
- name: Init Test Suite
18+
uses: potatoqualitee/psmodulecache@v4
19+
with:
20+
modules-to-cache: PSScriptAnalyzer, BuildHelpers, Pester:4.10.1
21+
shell: powershell
22+
- name: Test Scoop Core
1823
shell: powershell
19-
run: |
20-
.\test\bin\init.ps1
21-
.\test\bin\test.ps1
24+
run: ./test/bin/test.ps1
2225
test_pwsh:
2326
name: PowerShell
2427
runs-on: windows-latest
@@ -27,8 +30,11 @@ jobs:
2730
uses: actions/checkout@v2
2831
with:
2932
fetch-depth: 2
30-
- name: Init and Test
33+
- name: Init Test Suite
34+
uses: potatoqualitee/psmodulecache@v4
35+
with:
36+
modules-to-cache: PSScriptAnalyzer, BuildHelpers, Pester:4.10.1
37+
shell: pwsh
38+
- name: Test Scoop Core
3139
shell: pwsh
32-
run: |
33-
.\test\bin\init.ps1
34-
.\test\bin\test.ps1
40+
run: ./test/bin/test.ps1

test/bin/init.ps1

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1-
#Requires -Version 5.0
1+
#Requires -Version 5.1
22
Write-Host "PowerShell: $($PSVersionTable.PSVersion)"
33
Write-Host (7z.exe | Select-String -Pattern '7-Zip').ToString()
4-
Write-Host 'Install testsuite dependencies ...'
5-
Install-Module -Repository PSGallery -Scope CurrentUser -Force -Name Pester -RequiredVersion 4.10.1 -SkipPublisherCheck
6-
Install-Module -Repository PSGallery -Scope CurrentUser -Force -Name PSScriptAnalyzer, BuildHelpers
4+
Write-Host 'Check and install testsuite dependencies ...'
5+
if (Get-InstalledModule -Name Pester -MinimumVersion 4.0 -MaximumVersion 4.99 -ErrorAction SilentlyContinue) {
6+
Write-Host 'Pester 4 is already installed.'
7+
} else {
8+
Write-Host 'Installing Pester 4 ...'
9+
Install-Module -Repository PSGallery -Scope CurrentUser -Force -Name Pester -MinimumVersion 4.0 -MaximumVersion 4.99 -SkipPublisherCheck
10+
}
11+
if (Get-InstalledModule -Name PSScriptAnalyzer -MinimumVersion 1.17 -ErrorAction SilentlyContinue) {
12+
Write-Host 'PSScriptAnalyzer is already installed.'
13+
} else {
14+
Write-Host 'Installing PSScriptAnalyzer ...'
15+
Install-Module -Repository PSGallery -Scope CurrentUser -Force -Name PSScriptAnalyzer -SkipPublisherCheck
16+
}
17+
if (Get-InstalledModule -Name BuildHelpers -MinimumVersion 2.0 -ErrorAction SilentlyContinue) {
18+
Write-Host 'BuildHelpers is already installed.'
19+
} else {
20+
Write-Host 'Installing BuildHelpers ...'
21+
Install-Module -Repository PSGallery -Scope CurrentUser -Force -Name BuildHelpers -SkipPublisherCheck
22+
}

test/bin/test.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Requires -Version 5.0
1+
#Requires -Version 5.1
22
#Requires -Modules @{ ModuleName = 'BuildHelpers'; ModuleVersion = '2.0.1' }
3-
#Requires -Modules @{ ModuleName = 'Pester'; RequiredVersion = '4.10.1' }
3+
#Requires -Modules @{ ModuleName = 'Pester'; MaximumVersion = '4.99' }
44
#Requires -Modules @{ ModuleName = 'PSScriptAnalyzer'; ModuleVersion = '1.17.1' }
55
param(
66
[String] $TestPath = $(Resolve-Path "$PSScriptRoot\..\")

0 commit comments

Comments
 (0)