-
Notifications
You must be signed in to change notification settings - Fork 57
132 lines (119 loc) · 4.22 KB
/
Copy pathbuild.yml
File metadata and controls
132 lines (119 loc) · 4.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: write # to tag the repository
jobs:
build:
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
steps:
- name: Install EarthBuild
uses: EarthBuild/actions-setup@v2.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version: 'latest' # or pin to an specific version, e.g. "0.8.1"
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: earth +test
if: github.ref != 'refs/heads/main'
run: earth --strict +test
- name: earth +push
if: github.ref == 'refs/heads/main'
run: earth --push --secret NUGET_API_KEY --secret PSGALLERY_API_KEY --strict +all
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }}
- name: Upload Built Modules
uses: actions/upload-artifact@v4
with:
name: Modules
path: |
Modules/*
!Modules/*-TestResults
- uses: actions/upload-artifact@v4
with:
name: TestResults
path: Modules/ModuleBuilder-TestResults
# These ones are just for the test matrix
- name: Upload Tests
uses: actions/upload-artifact@v4
with:
name: PesterTests
path: ${{github.workspace}}/Tests
- name: Upload build.requires.psd1
uses: actions/upload-artifact@v4
with:
name: build.requires.psd1
path: ${{github.workspace}}/build.requires.psd1
test:
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ windows-latest, ubuntu-latest, macos-latest ]
steps:
- name: Download build.requires.psd1
uses: actions/download-artifact@v4
with:
name: build.requires.psd1
- name: Download Pester Tests
uses: actions/download-artifact@v4
with:
name: PesterTests
path: PesterTests
- name: Download Build Output
uses: actions/download-artifact@v4
with:
name: Modules
path: Modules # /home/runner/work/ModuleBuilder/ModuleBuilder/Modules
- name: Install Output Modules
shell: pwsh
run: | # PowerShell
# https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-powershell#powershell-module-locations
$ModuleDestination = if ($IsWindows) {
Join-Path ([Environment]::GetFolderPath('MyDocuments')) 'PowerShell/Modules'
} else {
Join-Path $HOME '.local/share/powershell/Modules'
}
Get-ChildItem -Directory Modules -OutVariable Modules
| Move-Item -Destination { Join-Path $ModuleDestination $_.Name } -Force
Write-Host "Installing $($Modules -join ', ') to $ModuleDestination"
Get-ChildItem -Directory $ModuleDestination
Write-Host "PSModulePath:"
$Env:PSModulePath -split ([IO.Path]::PathSeparator) | Out-Host
@(Get-Content build.requires.psd1)
| Where { $_ -notmatch "ModuleBuilder"}
| Set-Content build.requires.psd1
- name: ⚡ Install Required Modules
uses: JustinGrote/ModuleFast-action@v0.0.1
- name: Invoke Pester Tests
id: pester
uses: zyborg/pester-tests-report@v1
with:
# include_paths: tests
# exclude_paths: tests/powershell1,tests/powershell2
# exclude_tags: skip_ci
report_name: ${{ matrix.os }}_validation
report_title: My Module Tests
github_token: ${{ secrets.GITHUB_TOKEN }}
tests_fail_step: true
skip_check_run: true # Our test results are too large
- name: Summarize test results
shell: pwsh
run: | # PowerShell
Write-ActionInfo 'Total Tests Executed...: ${{ steps.pester.outputs.total_count }}'
Write-ActionInfo 'Total Tests Passed.....: ${{ steps.pester.outputs.passed_count }}'
if (${{ steps.pester.outputs.failed_count }} -gt 0) {
Set-ActionFailed 'Total Tests Failed.....: ${{ steps.pester.outputs.failed_count }}'
} else {
Write-ActionInfo 'Total Tests Failed.....: ${{ steps.pester.outputs.failed_count }}'
}