Merge pull request #14032 from meteor/cache-windows-ci-check

Windows CI check optimizations
This commit is contained in:
Nacho Codoñer
2025-12-09 16:10:07 +01:00
committed by GitHub
2 changed files with 59 additions and 32 deletions

View File

@@ -1,4 +1,4 @@
name: Meteor Selftest Windows
name: Windows Selftest
on:
pull_request:
@@ -6,10 +6,20 @@ on:
- opened
- reopened
- synchronize
paths:
- 'meteor'
- 'meteor.bat'
- 'tools/**'
- 'packages/babel-compiler/**'
- 'packages/dynamic-import/**'
- 'packages/meteor/**'
- 'packages/meteor-tool/**'
- '.github/workflows/windows-selftest.yml'
push:
branches:
- devel
- 2.x.x
- release-**
env:
METEOR_PRETTY_OUTPUT: 0
@@ -28,10 +38,6 @@ jobs:
cancel-in-progress: true
steps:
- name: cleanup
shell: powershell
run: Remove-Item -Recurse -Force ${{ github.workspace }}\*
- name: Checkout code
uses: actions/checkout@v4
@@ -40,23 +46,37 @@ jobs:
with:
node-version: 22.x
- name: Cache dependencies
id: meteor-cache
uses: actions/cache@v4
with:
path: |
dev_bundle/
.babel-cache/
.meteor/
~/.npm
node_modules/
packages/**/.npm
key: ${{ runner.os }}-meteor-${{ hashFiles('**/package-lock.json', 'meteor', 'meteor.bat') }}
restore-keys: |
${{ runner.os }}-meteor-
- name: Install dependencies
shell: pwsh
run: |
$env:PATH = "C:\Program Files\7-Zip;$env:PATH"
.\scripts\windows\ci\install.ps1
# Run ONLY when the cache was NOT restored
- name: Prepare Meteor (cache miss)
if: steps.meteor-cache.outputs.cache-hit != 'true'
shell: pwsh
run: |
$env:PATH = "C:\Program Files\7-Zip;$env:PATH"
.\meteor.bat --get-ready
- name: Run tests
shell: pwsh
run: |
$env:PATH = "C:\Program Files\7-Zip;$env:PATH"
.\scripts\windows\ci\test.ps1
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
.\dev_bundle
.\.babel-cache
.\.meteor
key: ${{ runner.os }}-meteor-${{ hashFiles('**/package-lock.json') }}

View File

@@ -4,6 +4,9 @@ If ($env:PLATFORM -Match '^x86|x64$') {
$env:PLATFORM = "windows_${env:PLATFORM}"
}
# Check if we're running in a CI environment
$isCI = $env:GITHUB_ACTIONS -eq "true"
$dirCheckout = (Get-Item $PSScriptRoot).parent.parent.parent.FullName
$meteorBat = Join-Path $dirCheckout 'meteor.bat'
@@ -15,7 +18,8 @@ Write-Host "Updating submodules recursively..." -ForegroundColor Magenta
# Appveyor suggests -q flag for 'git submodule...' https://goo.gl/4TFAHm
& git.exe -C "$dirCheckout" submodule -q update --init --recursive
If ($LASTEXITCODE -ne 0) {
# Only throw locally
If ($LASTEXITCODE -ne 0 -and -not $isCI) {
throw "Updating submodules failed."
}
@@ -25,25 +29,28 @@ If ($LASTEXITCODE -ne 0) {
throw "'meteor npm install' failed."
}
# Only `meteor --get-ready` get-ready locally to have better control on CI
# The `meteor --get-ready` command is susceptible to EPERM errors, so
# we attempt it three times.
$attempt = 3
$success = $false
while ($attempt -gt 0 -and -not $success) {
If (-not $isCI) {
$attempt = 3
$success = $false
while ($attempt -gt 0 -and -not $success) {
Write-Host "Running 'meteor --get-ready'..." -ForegroundColor Magenta
# By redirecting error to host, we avoid a shocking/false error color,
# since --get-ready and --version can print (anything) to STDERR and
# PowerShell will interpret that as something being terribly wrong.
& "$meteorBat" --get-ready
Write-Host "Running 'meteor --get-ready'..." -ForegroundColor Magenta
# By redirecting error to host, we avoid a shocking/false error color,
# since --get-ready and --version can print (anything) to STDERR and
# PowerShell will interpret that as something being terribly wrong.
& "$meteorBat" --get-ready
If ($LASTEXITCODE -eq 0) {
$success = $true
} else {
$attempt--
If ($LASTEXITCODE -eq 0) {
$success = $true
} else {
$attempt--
}
}
If ($LASTEXITCODE -ne 0) {
throw "Running .\meteor --get-ready failed three times."
}
}
If ($LASTEXITCODE -ne 0) {
throw "Running .\meteor --get-ready failed three times."
}