Fix : windows verify crash 1
This commit is contained in:
@@ -164,8 +164,11 @@ jobs:
|
||||
# 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
|
||||
# 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
|
||||
shell: pwsh
|
||||
shell: powershell
|
||||
run: |
|
||||
$errors = $null
|
||||
[System.Management.Automation.Language.Parser]::ParseFile(
|
||||
@@ -177,17 +180,20 @@ jobs:
|
||||
Write-Host 'install-agent.ps1 : syntaxe valide.'
|
||||
|
||||
- name: Récupérer le bundle publié
|
||||
shell: pwsh
|
||||
shell: powershell
|
||||
run: |
|
||||
$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"
|
||||
$pair = "${{ github.repository_owner }}:${{ secrets.REGISTERYKEY }}"
|
||||
$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"
|
||||
|
||||
- name: Exécuter le diagnostic
|
||||
shell: pwsh
|
||||
shell: powershell
|
||||
env:
|
||||
AGENT_TOKEN: ci-smoke-test
|
||||
SERVER_URL: ws://127.0.0.1:1/ws/agent
|
||||
|
||||
@@ -114,7 +114,10 @@ if ($isUpgrade) {
|
||||
name = $Name
|
||||
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"
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,10 @@ const CONFIG_PATH = path.resolve(
|
||||
function readFile(): Partial<AgentConfig> {
|
||||
if (!fs.existsSync(CONFIG_PATH)) return {};
|
||||
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) {
|
||||
console.error(`Configuration illisible (${CONFIG_PATH}) :`, err);
|
||||
return {};
|
||||
|
||||
Reference in New Issue
Block a user