Skip to content

chore(release): 0.4.14 #83

chore(release): 0.4.14

chore(release): 0.4.14 #83

Workflow file for this run

name: Run CI
on:
push:
branches:
- main
pull_request:
env:
REQUIRED_ELECTRON_VERSION: 40.8.0
NATIVE_DEPS_CACHE_VERSION: v1
OMP_THREAD_LIMIT: "1"
OMP_NUM_THREADS: "1"
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ windows-latest ]
node: [ "20" ]
runs-on: ${{matrix.os}}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{matrix.node}}
cache: npm
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Setup Windows compiler tools
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Install dependencies (skip scripts)
run: npm ci --ignore-scripts
- name: Restore native dependencies cache
id: native-deps-cache
if: runner.os == 'Windows'
uses: actions/cache@v4
with:
path: |
tesseract/build
leptonica/build
libtiff/build
libpng/build
libjpeg/build
zlib/build
key: native-deps-${{ runner.os }}-${{ runner.arch }}-node${{ matrix.node }}-${{ env.NATIVE_DEPS_CACHE_VERSION }}-${{ hashFiles('scripts/build-tesseract.js', 'scripts/clean-tesseract.js', 'patches/**') }}
- name: Build native dependencies
if: runner.os != 'Windows' || steps.native-deps-cache.outputs.cache-hit != 'true'
env:
BUILD_FOR_ARCH: ${{ runner.arch == 'X64' && 'x64' || 'arm64' }}
run: |
npm run clean-tesseract
npm run build-tesseract
- name: Native dependencies cache status
if: runner.os == 'Windows'
shell: pwsh
run: |
if ("${{ steps.native-deps-cache.outputs.cache-hit }}" -eq "true") {
Write-Host "Using cached native dependencies build outputs."
} else {
Write-Host "Native dependencies cache miss; rebuilt native dependencies."
}
- name: Build native addon
run: npm run build-cc
- name: Verify required Electron target compatibility
if: runner.os == 'Windows'
run: node ./scripts/verify-electron-target.js "${{ env.REQUIRED_ELECTRON_VERSION }}"
- name: Add Windows native runtime paths
if: runner.os == 'Windows'
shell: pwsh
run: |
"$env:GITHUB_WORKSPACE\\tesseract\\build\\bin\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
"$env:GITHUB_WORKSPACE\\leptonica\\build\\bin\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
"$env:GITHUB_WORKSPACE\\libtiff\\build\\bin\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
"$env:GITHUB_WORKSPACE\\libpng\\build\\bin\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
"$env:GITHUB_WORKSPACE\\libjpeg\\build\\bin\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
"$env:GITHUB_WORKSPACE\\zlib\\build\\bin\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Provision bundled Windows OCR runtime for tests
if: runner.os == 'Windows'
shell: pwsh
run: |
choco install tesseract --no-progress -y
$runtimeDir = "$env:GITHUB_WORKSPACE\runtime\win32-x64"
New-Item -ItemType Directory -Path $runtimeDir -Force | Out-Null
Get-ChildItem -Path $runtimeDir -File | Remove-Item -Force
$externalDir = "$env:ProgramFiles\Tesseract-OCR"
$externalExe = Join-Path $externalDir 'tesseract.exe'
if (!(Test-Path $externalExe)) {
throw "Known-good tesseract executable not found: $externalExe"
}
Copy-Item $externalExe -Destination (Join-Path $runtimeDir 'tesseract.exe') -Force
Get-ChildItem -Path $externalDir -Filter *.dll | ForEach-Object {
Copy-Item $_.FullName -Destination (Join-Path $runtimeDir $_.Name) -Force
}
"$runtimeDir" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
$bundledExe = Join-Path $runtimeDir 'tesseract.exe'
Write-Host "Selected Windows test tesseract source: runtime-win32-x64"
Write-Host "Selected Windows test tesseract executable: $bundledExe"
"WINDOWS_TEST_TESSERACT_SOURCE=runtime-win32-x64" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"WINDOWS_TEST_TESSERACT_EXE=$bundledExe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Set short Windows temp path
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Path C:\t -Force | Out-Null
"TMP=C:\t" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"TEMP=C:\t" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Windows native dependency diagnostics
if: runner.os == 'Windows'
shell: pwsh
run: |
$addonPath = "$env:GITHUB_WORKSPACE\build\Release\node-native-ocr.node"
if (Test-Path $addonPath) {
Write-Host "Addon exists: $addonPath"
dumpbin /dependents $addonPath
} else {
Write-Host "Addon not found at: $addonPath"
}
Write-Host "\nExecutable resolution:"
where.exe tesseract
where.exe node
$nativeDirs = @(
"$env:GITHUB_WORKSPACE\tesseract\build\bin\bin",
"$env:GITHUB_WORKSPACE\leptonica\build\bin\bin",
"$env:GITHUB_WORKSPACE\libtiff\build\bin\bin",
"$env:GITHUB_WORKSPACE\libpng\build\bin\bin",
"$env:GITHUB_WORKSPACE\libjpeg\build\bin\bin",
"$env:GITHUB_WORKSPACE\zlib\build\bin\bin"
)
foreach ($dir in $nativeDirs) {
if (Test-Path $dir) {
Write-Host "\nDLL snapshot from $dir"
Get-ChildItem -Path $dir -Filter *.dll | Select-Object -ExpandProperty Name
}
}
- name: Tesseract self-check
if: runner.os == 'Windows'
shell: pwsh
run: |
$tesseractExe = "$env:WINDOWS_TEST_TESSERACT_EXE"
$fixture = "$env:GITHUB_WORKSPACE\test\fixtures\test.jpg"
$tessdata = "$env:GITHUB_WORKSPACE\tessdata"
$selfCheckDir = Join-Path $env:RUNNER_TEMP "tesseract-selfcheck"
$selfCheckOut = Join-Path $selfCheckDir "ocr-selfcheck"
Write-Host "Self-check tesseract source: $env:WINDOWS_TEST_TESSERACT_SOURCE"
Write-Host "Self-check tesseract executable: $tesseractExe"
New-Item -ItemType Directory -Path $selfCheckDir -Force | Out-Null
& $tesseractExe --version
& $tesseractExe --list-langs --tessdata-dir $tessdata
$listLangsExit = $LASTEXITCODE
if ($listLangsExit -ne 0) {
Write-Warning "tesseract --list-langs failed with exit code $listLangsExit"
}
& $tesseractExe $fixture $selfCheckOut --tessdata-dir $tessdata -l eng
$selfCheckExit = $LASTEXITCODE
if ($selfCheckExit -ne 0) {
Write-Warning "tesseract self-check OCR command failed with exit code $selfCheckExit"
}
$selfCheckTxt = "$selfCheckOut.txt"
if (!(Test-Path $selfCheckTxt)) {
Write-Warning "Self-check output not found: $selfCheckTxt"
exit 0
}
$outSize = (Get-Item $selfCheckTxt).Length
Write-Host "Self-check output bytes: $outSize"
if ($outSize -le 0) {
Write-Warning "Self-check output is empty: $selfCheckTxt"
}
$global:LASTEXITCODE = 0
- name: Run tests
run: |
npm test
- name: Run Electron smoke tests
if: runner.os == 'Windows'
shell: pwsh
run: |
$env:NODE_NATIVE_OCR_TESSERACT_BINARY = $env:WINDOWS_TEST_TESSERACT_EXE
npm run test-electron -- "${{ env.REQUIRED_ELECTRON_VERSION }}"