Skip to content

Commit 400e22e

Browse files
authored
[release/v7.4] Refactor: Centralize xUnit tests into reusable workflow and remove legacy verification (#26864)
1 parent 383a4c5 commit 400e22e

File tree

11 files changed

+517
-73
lines changed

11 files changed

+517
-73
lines changed

.github/actions/build/ci/action.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,8 @@ runs:
3333
Import-Module .\tools\ci.psm1
3434
Invoke-CIBuild
3535
shell: pwsh
36-
- name: xUnit Tests
37-
if: success()
38-
continue-on-error: true
39-
run: |-
40-
Write-Verbose -Verbose "Running xUnit tests..."
41-
Import-Module .\tools\ci.psm1
42-
Restore-PSOptions
43-
Invoke-CIxUnit -SkipFailing
44-
shell: pwsh
4536
- name: Upload build artifact
4637
uses: actions/upload-artifact@v4
4738
with:
4839
name: build
4940
path: ${{ runner.workspace }}/build
50-
- name: Upload xunit artifact
51-
uses: actions/upload-artifact@v4
52-
with:
53-
name: testResults-xunit
54-
path: ${{ runner.workspace }}/xunit

.github/actions/test/verify_xunit/action.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Build Configuration Guide
2+
3+
## Choosing the Right Configuration
4+
5+
### For Testing
6+
7+
**Use: Default (Debug)**
8+
9+
```yaml
10+
- name: Build for Testing
11+
shell: pwsh
12+
run: |
13+
Import-Module ./tools/ci.psm1
14+
Start-PSBuild
15+
```
16+
17+
**Why Debug:**
18+
- Includes debugging symbols
19+
- Better error messages
20+
- Faster build times
21+
- Suitable for xUnit and Pester tests
22+
23+
**Do NOT use:**
24+
- `-Configuration 'Release'` (unnecessary for tests)
25+
- `-ReleaseTag` (not needed for tests)
26+
- `-CI` (unless you specifically need Pester module)
27+
28+
### For Release/Packaging
29+
30+
**Use: Release with version tag**
31+
32+
```yaml
33+
- name: Build for Release
34+
shell: pwsh
35+
run: |
36+
Import-Module ./tools/ci.psm1
37+
$releaseTag = Get-ReleaseTag
38+
Start-PSBuild -Configuration 'Release' -ReleaseTag $releaseTag
39+
```
40+
41+
**Why Release:**
42+
- Optimized binaries
43+
- No debug symbols (smaller size)
44+
- Production-ready
45+
46+
### For Code Coverage
47+
48+
**Use: CodeCoverage configuration**
49+
50+
```yaml
51+
- name: Build with Coverage
52+
shell: pwsh
53+
run: |
54+
Import-Module ./tools/ci.psm1
55+
Start-PSBuild -Configuration 'CodeCoverage'
56+
```
57+
58+
## Platform Considerations
59+
60+
### All Platforms
61+
62+
Same commands work across Linux, Windows, and macOS:
63+
64+
```yaml
65+
strategy:
66+
matrix:
67+
os: [ubuntu-latest, windows-latest, macos-latest]
68+
runs-on: ${{ matrix.os }}
69+
steps:
70+
- name: Build PowerShell
71+
shell: pwsh
72+
run: |
73+
Import-Module ./tools/ci.psm1
74+
Start-PSBuild
75+
```
76+
77+
### Output Locations
78+
79+
**Linux/macOS:**
80+
```
81+
src/powershell-unix/bin/Debug/<netversion>/<runtime>/publish/
82+
```
83+
84+
**Windows:**
85+
```
86+
src/powershell-win-core/bin/Debug/<netversion>/<runtime>/publish/
87+
```
88+
89+
## Best Practices
90+
91+
1. Use default configuration for testing
92+
2. Avoid redundant parameters
93+
3. Match configuration to purpose
94+
4. Use `-CI` only when needed
95+
5. Always specify `-ReleaseTag` for release or packaging builds
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Git Requirements for Building PowerShell
2+
3+
## Fetch Depth
4+
5+
**Required:** `fetch-depth: 1000`
6+
7+
The PowerShell build process uses `git describe --abbrev=60 --long` to generate version information. This requires access to git history and tags.
8+
9+
### Problem
10+
11+
Without sufficient fetch depth, builds fail with:
12+
```
13+
error MSB3073: The command "git describe --abbrev=60 --long" exited with code 128.
14+
```
15+
16+
### Solution
17+
18+
Always use `fetch-depth: 1000` in the checkout step:
19+
20+
```yaml
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 1000
25+
```
26+
27+
## Tag Synchronization
28+
29+
**Required:** `Sync-PSTags -AddRemoteIfMissing`
30+
31+
The build process needs git tags to properly version the build.
32+
33+
### Problem
34+
35+
Without tag synchronization:
36+
- Version information is incorrect
37+
- Build versioning fails
38+
39+
### Solution
40+
41+
Include tag synchronization in the bootstrap step:
42+
43+
```yaml
44+
- name: Bootstrap
45+
shell: pwsh
46+
run: |
47+
Import-Module ./tools/ci.psm1
48+
Sync-PSTags -AddRemoteIfMissing
49+
```
50+
51+
## Complete Example
52+
53+
```yaml
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v4
57+
with:
58+
fetch-depth: 1000
59+
60+
- name: Setup .NET
61+
uses: actions/setup-dotnet@v4
62+
with:
63+
global-json-file: ./global.json
64+
65+
- name: Bootstrap
66+
shell: pwsh
67+
run: |
68+
Import-Module ./tools/ci.psm1
69+
Invoke-CIInstall -SkipUser
70+
Sync-PSTags -AddRemoteIfMissing
71+
```
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Start-PSBuild Basics
2+
3+
## Purpose
4+
5+
`Start-PSBuild` builds PowerShell from source. It's defined in `build.psm1` and used in CI/CD workflows.
6+
7+
## Default Usage
8+
9+
For most scenarios, use with no parameters:
10+
11+
```powershell
12+
Import-Module ./tools/ci.psm1
13+
Start-PSBuild
14+
```
15+
16+
**Default behavior:**
17+
- Configuration: `Debug`
18+
- PSModuleRestore: Enabled
19+
- Runtime: Auto-detected for platform
20+
21+
## Common Configurations
22+
23+
### Debug Build (Default)
24+
25+
```powershell
26+
Start-PSBuild
27+
```
28+
29+
Use for:
30+
- Testing (xUnit, Pester)
31+
- Development
32+
- Debugging
33+
34+
### Release Build
35+
36+
```powershell
37+
Start-PSBuild -Configuration 'Release'
38+
```
39+
40+
Use for:
41+
- Production packages
42+
- Distribution
43+
- Performance testing
44+
45+
### Code Coverage Build
46+
47+
```powershell
48+
Start-PSBuild -Configuration 'CodeCoverage'
49+
```
50+
51+
Use for:
52+
- Code coverage analysis
53+
- Test coverage reports
54+
55+
## Common Parameters
56+
57+
### -Configuration
58+
59+
Values: `Debug`, `Release`, `CodeCoverage`, `StaticAnalysis`
60+
61+
Default: `Debug`
62+
63+
### -CI
64+
65+
Restores Pester module for CI environments.
66+
67+
```powershell
68+
Start-PSBuild -CI
69+
```
70+
71+
### -PSModuleRestore
72+
73+
Now enabled by default. Use `-NoPSModuleRestore` to skip.
74+
75+
### -ReleaseTag
76+
77+
Specifies version tag for release builds:
78+
79+
```powershell
80+
$releaseTag = Get-ReleaseTag
81+
Start-PSBuild -Configuration 'Release' -ReleaseTag $releaseTag
82+
```
83+
84+
## Workflow Example
85+
86+
```yaml
87+
- name: Build PowerShell
88+
shell: pwsh
89+
run: |
90+
Import-Module ./tools/ci.psm1
91+
Start-PSBuild
92+
```
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Troubleshooting Build Issues
2+
3+
## Git Describe Error
4+
5+
**Error:**
6+
```
7+
error MSB3073: The command "git describe --abbrev=60 --long" exited with code 128.
8+
```
9+
10+
**Cause:** Insufficient git history (shallow clone)
11+
12+
**Solution:** Add `fetch-depth: 1000` to checkout step
13+
14+
```yaml
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 1000
19+
```
20+
21+
## Version Information Incorrect
22+
23+
**Symptom:** Build produces wrong version numbers
24+
25+
**Cause:** Git tags not synchronized
26+
27+
**Solution:** Run `Sync-PSTags -AddRemoteIfMissing`:
28+
29+
```yaml
30+
- name: Bootstrap
31+
shell: pwsh
32+
run: |
33+
Import-Module ./tools/ci.psm1
34+
Invoke-CIInstall -SkipUser
35+
Sync-PSTags -AddRemoteIfMissing
36+
```
37+
38+
## PowerShell Binary Not Built
39+
40+
**Error:**
41+
```
42+
Exception: CoreCLR pwsh.exe was not built
43+
```
44+
45+
**Causes:**
46+
1. Build failed (check logs)
47+
2. Wrong configuration used
48+
3. Build output location incorrect
49+
50+
**Solutions:**
51+
1. Check build logs for errors
52+
2. Verify correct configuration for use case
53+
3. Use default parameters: `Start-PSBuild`
54+
55+
## Module Restore Issues
56+
57+
**Symptom:** Slow build or module restore failures
58+
59+
**Causes:**
60+
- Network issues
61+
- Module cache problems
62+
- Package source unavailable
63+
64+
**Solutions:**
65+
1. Retry the build
66+
2. Check network connectivity
67+
3. Use `-NoPSModuleRestore` if modules not needed
68+
4. Clear package cache if persistent
69+
70+
## .NET SDK Not Found
71+
72+
**Symptom:** Build can't find .NET SDK
73+
74+
**Solution:** Ensure .NET setup step runs first:
75+
76+
```yaml
77+
- name: Setup .NET
78+
uses: actions/setup-dotnet@v4
79+
with:
80+
global-json-file: ./global.json
81+
```
82+
83+
## Bootstrap Failures
84+
85+
**Symptom:** Invoke-CIInstall fails
86+
87+
**Causes:**
88+
- Missing dependencies
89+
- Network issues
90+
- Platform-specific requirements not met
91+
92+
**Solution:** Check prerequisites for your platform in build system docs

0 commit comments

Comments
 (0)