-
Notifications
You must be signed in to change notification settings - Fork 8
156 lines (123 loc) · 5 KB
/
copilot-setup-steps.yml
File metadata and controls
156 lines (123 loc) · 5 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: 'Copilot Setup Steps'
# This workflow sets up a complete development environment for the PowerShell module project
# when executed by GitHub Copilot Agent for development assistance.
on:
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/copilot-setup-steps.yml'
push:
paths:
- '.github/workflows/copilot-setup-steps.yml'
# cSpell: ignore unshallow
jobs:
copilot-setup-steps:
name: Setup PowerShell Development Environment
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history needed for GitVersion
# This step is needed for GitVersion because Copilot switches to its working branch
# after checkout and fetches only depth 2.
- name: Ensure full history for GitVersion
shell: pwsh
run: |
Write-Host 'Ensuring full history for GitVersion...' -ForegroundColor Green
$isShallow = (& git rev-parse --is-shallow-repository) -eq 'true'
if ($isShallow)
{
Write-Host 'Repository is shallow. Fetching full history and tags...' -ForegroundColor DarkGray
git fetch --prune --unshallow --tags --no-recurse-submodules
if ($LASTEXITCODE -ne 0)
{
throw 'git fetch --unshallow failed'
}
}
else
{
Write-Host 'Repository is not shallow. Refreshing tags...' -ForegroundColor DarkGray
git fetch --prune --tags --no-recurse-submodules
if ($LASTEXITCODE -ne 0)
{
throw 'git fetch --tags failed'
}
}
Write-Host 'History ready for GitVersion.' -ForegroundColor Green
- name: Install .NET Tools
shell: pwsh
run: |
Write-Host 'Installing/Updating .NET tools...' -ForegroundColor Green
# Install GitVersion for semantic versioning (idempotent)
dotnet tool update --global GitVersion.Tool --version 5.* `
|| dotnet tool install --global GitVersion.Tool --version 5.*
# Verify installation
dotnet-gitversion /version
Write-Host '.NET tools ready.' -ForegroundColor Green
- name: Verify GitVersion
shell: pwsh
run: |
Write-Host 'Running GitVersion to determine semantic version...' -ForegroundColor Green
dotnet-gitversion | ConvertFrom-Json
- name: Resolve Dependencies
shell: pwsh
run: |
Write-Host 'Resolving project dependencies...' -ForegroundColor Green
# Run dependency resolution
./build.ps1 -ResolveDependency -Tasks 'noop' -ErrorAction Stop
Write-Host 'Dependencies resolved successfully.' -ForegroundColor Green
- name: Build Module
shell: pwsh
run: |
$moduleName = 'DscResource.Test'
Write-Host "Building $moduleName module..." -ForegroundColor Green
# Build the module
./build.ps1 -Tasks 'build' -ErrorAction Stop
# Verify build output
if (Test-Path -Path "output\builtModule\$moduleName")
{
Write-Host "Module built successfully at: output\builtModule\$moduleName" -ForegroundColor Green
Get-ChildItem -Path "output\builtModule\$moduleName" -Recurse | Select-Object Name, Length | Format-Table
}
else
{
Write-Error 'Module build failed - output directory not found'
exit 1
}
- name: Import Built Module
shell: pwsh
run: |
$moduleName = 'DscResource.Test'
Write-Host "Importing built $moduleName module..." -ForegroundColor Green
./build.ps1 -Tasks 'noop'
Import-Module -Name $moduleName -Force
# Verify module is loaded
$module = Get-Module -Name $moduleName -ErrorAction SilentlyContinue
if ($module)
{
Write-Host 'Module imported successfully:' -ForegroundColor Green
Write-Host " Name: $($module.Name)" -ForegroundColor Cyan
Write-Host " Version: $($module.Version)" -ForegroundColor Cyan
Write-Host " Path: $($module.Path)" -ForegroundColor Cyan
# Show available commands
$commands = Get-Command -Module $moduleName
if ($commands.Count -gt 0)
{
Write-Host " Exported Commands: $($commands.Count)" -ForegroundColor Cyan
Write-Host 'Available Commands:' -ForegroundColor Cyan
$commands |
Select-Object Name, ModuleName | Format-Table -AutoSize
}
else
{
Write-Host 'No commands exported by the module.' -ForegroundColor Yellow
}
}
else
{
Write-Error 'Failed to import module'
exit 1
}