Skip to content

Commit 2993b5b

Browse files
bolenscursoragent
andcommitted
fix(ci): install git before Arch checkout
Arch containers lack git at job start, so actions/checkout fell back to a REST archive without .git and Get-TestRepoRoot failed. Bootstrap pacman git first, and accept profile markers / GITHUB_WORKSPACE as repo-root fallbacks. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 60ef051 commit 2993b5b

4 files changed

Lines changed: 63 additions & 2 deletions

File tree

.github/workflows/ci-powershell.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ jobs:
5757
runs-on: ${{ matrix.os }}
5858
container: ${{ matrix.container }}
5959
steps:
60+
# Arch images ship without git; checkout then uses a REST archive (no .git).
61+
- name: Bootstrap Arch git for checkout
62+
if: matrix.label == 'arch-latest'
63+
shell: bash
64+
run: |
65+
set -euo pipefail
66+
pacman -Sy --noconfirm
67+
pacman -S --noconfirm git
6068
- uses: actions/checkout@v7
6169
- name: Setup Arch Linux
6270
if: matrix.label == 'arch-latest'

.github/workflows/test-pester.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ jobs:
9292
fail-fast: false
9393
matrix: ${{ fromJson(needs.changes.outputs.matrix) }}
9494
steps:
95+
# Arch images ship without git; checkout then uses a REST archive (no .git).
96+
- name: Bootstrap Arch git for checkout
97+
if: matrix.label == 'arch-latest'
98+
shell: bash
99+
run: |
100+
set -euo pipefail
101+
pacman -Sy --noconfirm
102+
pacman -S --noconfirm git
95103
- uses: actions/checkout@v7
96104
- name: Setup Arch Linux
97105
if: matrix.label == 'arch-latest'

.github/workflows/validate-profile.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,15 @@ jobs:
189189
container: archlinux:latest
190190
powershell: pwsh
191191
steps:
192+
# Arch images ship without git; checkout then uses a REST archive (no .git).
193+
- name: Bootstrap Arch git for checkout
194+
if: matrix.label == 'arch-latest'
195+
shell: bash
196+
run: |
197+
set -euo pipefail
198+
pacman -Sy --noconfirm
199+
pacman -S --noconfirm git
200+
192201
- name: Checkout
193202
uses: actions/checkout@v7
194203

tests/TestSupport/TestPaths.ps1

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,40 @@
33
# Test path resolution and directory utilities
44
# ===============================================
55

6+
<#
7+
.SYNOPSIS
8+
Returns $true when a directory looks like this repository's root.
9+
.DESCRIPTION
10+
Accepts a real Git checkout (.git present) or an archive-style checkout
11+
(profile entrypoint + profile.d), which GitHub Actions uses when git is
12+
missing from the job container PATH at checkout time.
13+
#>
14+
function Test-TestRepoRootMarker {
15+
param(
16+
[Parameter(Mandatory)]
17+
[string]$Path
18+
)
19+
20+
if ([string]::IsNullOrWhiteSpace($Path)) {
21+
return $false
22+
}
23+
24+
if (Test-Path -LiteralPath (Join-Path $Path '.git')) {
25+
return $true
26+
}
27+
28+
$profileScript = Join-Path $Path 'Microsoft.PowerShell_profile.ps1'
29+
$profileDir = Join-Path $Path 'profile.d'
30+
return (Test-Path -LiteralPath $profileScript) -and (Test-Path -LiteralPath $profileDir)
31+
}
32+
633
<#
734
.SYNOPSIS
835
Locates the repository root directory for the tests.
936
.DESCRIPTION
10-
Walks up from the supplied start path until it finds a .git folder and returns that directory.
37+
Prefers GITHUB_WORKSPACE / PS_PROFILE_REPO_ROOT when they point at this repo,
38+
then walks up from the supplied start path until it finds a .git entry or the
39+
profile markers (archive checkouts without .git).
1140
.PARAMETER StartPath
1241
The path to begin searching from; defaults to the calling script root.
1342
.OUTPUTS
@@ -19,9 +48,16 @@ function Get-TestRepoRoot {
1948
[string]$StartPath = $PSScriptRoot
2049
)
2150

51+
foreach ($envName in @('PS_PROFILE_REPO_ROOT', 'GITHUB_WORKSPACE')) {
52+
$candidate = [Environment]::GetEnvironmentVariable($envName)
53+
if ($candidate -and (Test-TestRepoRootMarker -Path $candidate)) {
54+
return ([System.IO.Path]::GetFullPath($candidate))
55+
}
56+
}
57+
2258
$current = Get-Item -LiteralPath $StartPath
2359
while ($null -ne $current) {
24-
if (Test-Path -LiteralPath (Join-Path $current.FullName '.git')) {
60+
if (Test-TestRepoRootMarker -Path $current.FullName) {
2561
return $current.FullName
2662
}
2763
$current = $current.Parent

0 commit comments

Comments
 (0)