chore(release): v0.1.2 + tests WASM (Windows), script runner, doc

This commit is contained in:
Your Name 2025-08-26 08:19:33 +02:00
parent c12dc5fe17
commit c9bf58bc35
4 changed files with 90 additions and 20 deletions

View File

@ -14,6 +14,15 @@ et ce projet adhère au [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Guide de contribution et code de conduite
- Scripts de maintenance et nettoyage automatique
## [0.1.2] - 2025-08-26
### Changed
- Testing: renforcement de la procédure WASM (Windows) dans `docs/TESTING.md` (LLVM/Clang, variables denvironnement, runner wasm-bindgen, script `scripts/run-wasm-tests.ps1`).
- Build: version `sdk_client` bump à 0.1.2.
### Fixed
- Stabilisation de lexécution `wasm-pack test` via script (gestion cache `.wasm-pack`, téléchargement runner, fallback Node).
### Changed
- Documentation `sdk_client` alignée au code: API, Architecture, Usage, Testing, Security Audit, README, INDEX
- Réorganisation complète de la structure des tests

View File

@ -1,6 +1,6 @@
[package]
name = "sdk_client"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
[lib]

View File

@ -23,14 +23,27 @@ Répertoires fournis:
Exécution standard: unité, intégration, puis front WASM. Les seuils et critères sont définis cidessous.
### Prérequis tests WASM (headless)
### Prérequis tests WASM (Windows)
- Outil: `wasm-pack` installé (via `cargo install wasm-pack`).
- Navigateurs: Chrome et/ou Firefox installés en local (mode headless supporté).
- Windows: installer LLVM/Clang et définir le compilateur C pour la cible WASM:
- Installer LLVM (ex. via `winget install -e --id LLVM.LLVM --accept-package-agreements --accept-source-agreements --silent`).
- Définir le compilateur dans la session: `CC="C:\\Program Files\\LLVM\\bin\\clang.exe"` et `CC_wasm32_unknown_unknown` identique.
- Lancer ensuite: `wasm-pack test --headless --chrome` et/ou `--firefox`.
- Outils: `wasm-pack` et LLVM/Clang installés.
- LLVM via `winget install -e --id LLVM.LLVM --accept-package-agreements --accept-source-agreements --silent`.
- Variables denvironnement (utilisateur) à définir une seule fois, puis ouvrir un nouveau PowerShell:
- `CC = C:\\Program Files\\LLVM\\bin\\clang.exe`
- `TARGET_CC = C:\\Program Files\\LLVM\\bin\\clang.exe`
- `CC_wasm32-unknown-unknown = C:\\Program Files\\LLVM\\bin\\clang.exe`
- `AR_wasm32-unknown-unknown = C:\\Program Files\\LLVM\\bin\\llvm-ar.exe`
- `NM_wasm32-unknown-unknown = C:\\Program Files\\LLVM\\bin\\llvm-nm.exe`
- Runner wasm-bindgen:
- Le script `scripts/run-wasm-tests.ps1` télécharge automatiquement `wasm-bindgen` (0.2.100) si absent et exporte `WASM_BINDGEN_TEST_RUNNER`.
- En cas déchec de téléchargement automatique, placer manuellement le binaire `wasm-bindgen-test-runner.exe` dans `C:\\Users\\<USER>\\AppData\\Local\\.wasm-pack\\wasm-bindgen-<hash>\\`.
### Exécution des tests WASM
- Automatisé: `./scripts/run-wasm-tests.ps1`
- Tente Node en priorité, puis navigateurs si nécessaire.
- Purge/recale le cache `.wasm-pack` si requis.
- Manuel: `wasm-pack test --node` (ou `--headless --chrome`, `--headless --firefox`).
Options disponibles :
- `--verbose` : Mode verbose avec affichage détaillé

View File

@ -42,17 +42,65 @@ function Invoke-WasmPackTests {
$runnerSet = $false
function Ensure-WasmBindgenRunner {
param()
$runner = Join-Path "$env:USERPROFILE\.cargo\bin" "wasm-bindgen-test-runner.exe"
if (-not (Test-Path $runner)) {
Write-Host "Installing wasm-bindgen-test-cli..." -ForegroundColor Yellow
cargo install wasm-bindgen-test-cli --locked --force | Out-Null
# Cherche un runner dans le cache wasm-pack
$localWp = Join-Path $env:LOCALAPPDATA ".wasm-pack"
$cachedRunner = $null
if (Test-Path $localWp) {
$candidates = Get-ChildItem -Path $localWp -Recurse -Filter "wasm-bindgen-test-runner.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
if ($candidates) { $cachedRunner = $candidates.FullName }
}
if (Test-Path $runner) {
if (-not $cachedRunner) {
Write-Host "Aucun runner trouvé. Téléchargement de larchive officielle (tar.gz) pour Windows..." -ForegroundColor Yellow
$wbgVersion = "0.2.100"
$arch = "x86_64-pc-windows-msvc"
$tarName = "wasm-bindgen-$wbgVersion-$arch.tar.gz"
$downloadUrl = "https://github.com/rustwasm/wasm-bindgen/releases/download/$wbgVersion/$tarName"
$destParent = $localWp
$tarPath = Join-Path $env:TEMP $tarName
try {
if (-not (Test-Path $destParent)) { New-Item -ItemType Directory -Force -Path $destParent | Out-Null }
Invoke-WebRequest -Uri $downloadUrl -OutFile $tarPath -UseBasicParsing -ErrorAction Stop
Push-Location $destParent
tar -xzf $tarPath
Pop-Location
} catch {
Write-Warning "Échec du téléchargement/extraction du runner: $($_.Exception.Message)"
} finally {
if (Test-Path $tarPath) { Remove-Item -Force $tarPath }
}
# Recherche récursive du binaire extrait
$found = Get-ChildItem -Path (Join-Path $destParent "wasm-bindgen-$wbgVersion-$arch") -Recurse -Filter "wasm-bindgen-test-runner.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
if ($found) { $cachedRunner = $found.FullName }
}
if ($cachedRunner -and (Test-Path $cachedRunner)) {
$script:runnerSet = $true
$env:WASM_BINDGEN_TEST_RUNNER = $runner
} else {
Write-Warning "wasm-bindgen-test-runner introuvable après installation. PATH: $env:PATH"
$env:WASM_BINDGEN_TEST_RUNNER = $cachedRunner
$runnerDir = Split-Path $cachedRunner -Parent
if ($env:PATH -notlike "*$runnerDir*") { $env:PATH = "$runnerDir;$env:PATH" }
# Force cargo/wasm-pack à utiliser ce runner pour wasm32-unknown-unknown
[System.Environment]::SetEnvironmentVariable('CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER', $cachedRunner, 'Process')
# Copie de secours dans les dossiers cache wasm-pack attendus (hashés)
try {
$wpDirs = Get-ChildItem -Path $localWp -Directory -Filter "wasm-bindgen-*" -ErrorAction SilentlyContinue
foreach ($d in $wpDirs) {
$destRunner = Join-Path $d.FullName "wasm-bindgen-test-runner.exe"
if (-not (Test-Path $destRunner)) {
Copy-Item -Force $cachedRunner $destRunner -ErrorAction SilentlyContinue
}
$wbExeSrc = Join-Path $runnerDir "wasm-bindgen.exe"
$wbExeDst = Join-Path $d.FullName "wasm-bindgen.exe"
if ((Test-Path $wbExeSrc) -and -not (Test-Path $wbExeDst)) {
Copy-Item -Force $wbExeSrc $wbExeDst -ErrorAction SilentlyContinue
}
}
} catch {}
Write-Host "WASM_BINDGEN_TEST_RUNNER défini vers: $cachedRunner" -ForegroundColor Green
return
}
Write-Warning "wasm-bindgen-test-runner introuvable. wasm-pack tentera de le télécharger lors de l'exécution des tests."
}
$scriptsDir = Split-Path -Parent $MyInvocation.MyCommand.Path
@ -61,12 +109,12 @@ Push-Location $repoRoot
try {
Set-WasmToolchainEnv
Ensure-WasmBindgenRunner
cargo clean --target wasm32-unknown-unknown | Out-Null
try {
Invoke-WasmPackTests -Chrome -Firefox
} catch {
Write-Warning "Tests headless navigateur échoués, tentative avec Node."
# D'abord Node (plus robuste sur Windows)
Invoke-WasmPackTests -Node
} catch {
Write-Warning "Tests Node échoués, tentative avec navigateurs headless."
Invoke-WasmPackTests -Chrome -Firefox
}
} finally {
Pop-Location