Fix : windows verify crash 1
Some checks failed
release / build (push) Successful in 24s
release / verify-windows (push) Failing after 1m3s

This commit is contained in:
jeanotx32
2026-08-11 17:25:28 +02:00
parent dc63c2b39d
commit 6f6e829ad5
3 changed files with 18 additions and 6 deletions

View File

@@ -164,8 +164,11 @@ jobs:
# Le script d'installation Windows n'est exécutable que sur Windows : # Le script d'installation Windows n'est exécutable que sur Windows :
# ce contrôle de syntaxe est la seule barrière avant qu'il n'atterrisse # ce contrôle de syntaxe est la seule barrière avant qu'il n'atterrisse
# sur une VM de production. # sur une VM de production.
# shell: powershell (Windows PowerShell 5.1) et non pwsh : PowerShell 7
# n'est pas garanti sur un runner Windows, alors que 5.1 est toujours là.
# C'est aussi la version que les VM d'enregistrement exécuteront.
- name: Valider la syntaxe du script d'installation - name: Valider la syntaxe du script d'installation
shell: pwsh shell: powershell
run: | run: |
$errors = $null $errors = $null
[System.Management.Automation.Language.Parser]::ParseFile( [System.Management.Automation.Language.Parser]::ParseFile(
@@ -177,17 +180,20 @@ jobs:
Write-Host 'install-agent.ps1 : syntaxe valide.' Write-Host 'install-agent.ps1 : syntaxe valide.'
- name: Récupérer le bundle publié - name: Récupérer le bundle publié
shell: pwsh shell: powershell
run: | run: |
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
# PowerShell 5.1 ne négocie pas TLS 1.2 par défaut sur toutes les éditions.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$url = "$env:GITHUB_SERVER_URL/api/packages/${{ github.repository_owner }}/generic/$env:PACKAGE_NAME/${{ needs.build.outputs.version }}/agent.cjs" $url = "$env:GITHUB_SERVER_URL/api/packages/${{ github.repository_owner }}/generic/$env:PACKAGE_NAME/${{ needs.build.outputs.version }}/agent.cjs"
$pair = "${{ github.repository_owner }}:${{ secrets.REGISTERYKEY }}" $pair = "${{ github.repository_owner }}:${{ secrets.REGISTERYKEY }}"
$auth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes($pair)) $auth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes($pair))
Invoke-WebRequest -Uri $url -Headers @{ Authorization = "Basic $auth" } -OutFile agent.cjs Invoke-WebRequest -Uri $url -Headers @{ Authorization = "Basic $auth" } `
-OutFile agent.cjs -UseBasicParsing
Write-Host "Bundle récupéré : $((Get-Item agent.cjs).Length) octets" Write-Host "Bundle récupéré : $((Get-Item agent.cjs).Length) octets"
- name: Exécuter le diagnostic - name: Exécuter le diagnostic
shell: pwsh shell: powershell
env: env:
AGENT_TOKEN: ci-smoke-test AGENT_TOKEN: ci-smoke-test
SERVER_URL: ws://127.0.0.1:1/ws/agent SERVER_URL: ws://127.0.0.1:1/ws/agent

View File

@@ -114,7 +114,10 @@ if ($isUpgrade) {
name = $Name name = $Name
obs = [ordered]@{ host = $ObsHost; port = $ObsPort; password = $ObsPassword } obs = [ordered]@{ host = $ObsHost; port = $ObsPort; password = $ObsPassword }
} }
$config | ConvertTo-Json -Depth 5 | Set-Content -Path $configFile -Encoding UTF8 # Surtout pas Set-Content -Encoding UTF8 : sous PowerShell 5.1 il préfixe un
# BOM, et JSON.parse côté Node refuse le fichier.
$json = $config | ConvertTo-Json -Depth 5
[System.IO.File]::WriteAllText($configFile, $json, (New-Object System.Text.UTF8Encoding($false)))
Info "Configuration écrite dans $configFile" Info "Configuration écrite dans $configFile"
} }

View File

@@ -26,7 +26,10 @@ const CONFIG_PATH = path.resolve(
function readFile(): Partial<AgentConfig> { function readFile(): Partial<AgentConfig> {
if (!fs.existsSync(CONFIG_PATH)) return {}; if (!fs.existsSync(CONFIG_PATH)) return {};
try { try {
return JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf8')) as Partial<AgentConfig>; // Les éditeurs Windows (et Set-Content -Encoding UTF8) préfixent un BOM que
// JSON.parse rejette.
const raw = fs.readFileSync(CONFIG_PATH, 'utf8').replace(/^\uFEFF/, '');
return JSON.parse(raw) as Partial<AgentConfig>;
} catch (err) { } catch (err) {
console.error(`Configuration illisible (${CONFIG_PATH}) :`, err); console.error(`Configuration illisible (${CONFIG_PATH}) :`, err);
return {}; return {};