Skip to content

Commit f1dde84

Browse files
committed
Prepare host ripgrep for CI packaging
1 parent 323d42f commit f1dde84

1 file changed

Lines changed: 60 additions & 19 deletions

File tree

.github/workflows/build-nabla.yml

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,42 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
jobs:
17+
prepare-host-rg:
18+
name: Prepare host ripgrep
19+
runs-on: windows-2022
20+
21+
steps:
22+
- name: Restore ripgrep host tool
23+
id: cache-rg
24+
uses: actions/cache@v4
25+
with:
26+
path: ${{ runner.temp }}\ripgrep-14.1.1-x86_64-pc-windows-msvc
27+
key: ripgrep-14.1.1-x86_64-pc-windows-msvc
28+
29+
- name: Install ripgrep host tool
30+
if: steps.cache-rg.outputs.cache-hit != 'true'
31+
shell: pwsh
32+
run: |
33+
$rgVersion = '14.1.1'
34+
$archive = Join-Path $env:RUNNER_TEMP "ripgrep-$rgVersion-x86_64-pc-windows-msvc.zip"
35+
$extractRoot = $env:RUNNER_TEMP
36+
Invoke-WebRequest `
37+
-Uri "https://github.com/BurntSushi/ripgrep/releases/download/$rgVersion/ripgrep-$rgVersion-x86_64-pc-windows-msvc.zip" `
38+
-OutFile $archive
39+
Expand-Archive -Path $archive -DestinationPath $extractRoot -Force
40+
41+
- name: Verify ripgrep host tool
42+
shell: pwsh
43+
run: |
44+
$rgExe = Join-Path $env:RUNNER_TEMP 'ripgrep-14.1.1-x86_64-pc-windows-msvc\rg.exe'
45+
if (-not (Test-Path $rgExe)) {
46+
throw "ripgrep was not installed on host."
47+
}
48+
& $rgExe --version
49+
1750
build-windows:
1851
name: Nabla (${{ matrix.os }}, ${{ matrix.vendor }}-${{ matrix.tag }}, ${{ matrix.config }})
52+
needs: prepare-host-rg
1953
runs-on: ${{ matrix.os }}
2054

2155
env:
@@ -50,7 +84,7 @@ jobs:
5084
Set-MpPreference -DisableArchiveScanning $true
5185
Set-MpPreference -DisableScanningMappedNetworkDrivesForFullScan $true
5286
53-
$maxAttempts = 24
87+
$maxAttempts = 12
5488
$delaySeconds = 5
5589
$dockerReady = $false
5690
@@ -124,6 +158,24 @@ jobs:
124158
with:
125159
submodules: 'recursive'
126160

161+
- name: Restore ripgrep host tool
162+
id: cache-rg
163+
uses: actions/cache@v4
164+
with:
165+
path: ${{ runner.temp }}\ripgrep-14.1.1-x86_64-pc-windows-msvc
166+
key: ripgrep-14.1.1-x86_64-pc-windows-msvc
167+
168+
- name: Add ripgrep to PATH
169+
shell: pwsh
170+
run: |
171+
$rgDir = Join-Path $env:RUNNER_TEMP 'ripgrep-14.1.1-x86_64-pc-windows-msvc'
172+
$rgExe = Join-Path $rgDir 'rg.exe'
173+
if (-not (Test-Path $rgExe)) {
174+
throw "ripgrep was not installed on host."
175+
}
176+
$rgDir | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
177+
& $rgExe --version
178+
127179
- name: Pull Image
128180
run: |
129181
docker pull "${{ env.image }}:${{ matrix.tag }}"
@@ -299,24 +351,13 @@ jobs:
299351
tar -cvf "${{ steps.set-prefix.outputs.prefix }}-install.tar" ${{ env.install }}
300352
$sourceTar = "${{ steps.set-prefix.outputs.prefix }}-source.tar"
301353
$sourceList = "${{ steps.set-prefix.outputs.prefix }}-source-files.txt"
302-
if (Get-Command rg -ErrorAction SilentlyContinue) {
303-
$sourceFiles = @(
304-
rg --files -uu . `
305-
-g '*.c' -g '*.cc' -g '*.cpp' -g '*.cxx' `
306-
-g '*.h' -g '*.hh' -g '*.hpp' -g '*.hxx' `
307-
-g '*.inc' -g '*.inl' -g '*.ipp' -g '*.tpp' -g '*.ixx' `
308-
-g '!examples_tests/media/**' -g '!.git/**'
309-
)
310-
}
311-
else {
312-
$sourceFiles = @(
313-
git ls-files --cached --recurse-submodules |
314-
Where-Object {
315-
$_ -match '\.(c|cc|cpp|cxx|h|hh|hpp|hxx|inc|inl|ipp|tpp|ixx)$' -and
316-
$_ -notlike 'examples_tests/media/*'
317-
}
318-
)
319-
}
354+
$sourceFiles = @(
355+
rg --files -uu . `
356+
-g '*.c' -g '*.cc' -g '*.cpp' -g '*.cxx' `
357+
-g '*.h' -g '*.hh' -g '*.hpp' -g '*.hxx' `
358+
-g '*.inc' -g '*.inl' -g '*.ipp' -g '*.tpp' -g '*.ixx' `
359+
-g '!examples_tests/media/**' -g '!.git/**'
360+
)
320361
321362
if ($sourceFiles.Count -eq 0) {
322363
throw "No source-like files found for source artifact packaging."

0 commit comments

Comments
 (0)