diff --git a/.github/workflows/ahk-lint-format-compile.yml b/.github/workflows/ahk-lint-format-compile.yml index 95e17c5..ac2e046 100644 --- a/.github/workflows/ahk-lint-format-compile.yml +++ b/.github/workflows/ahk-lint-format-compile.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/checkout@v6 - name: Install AutoHotkey v1.1 (Portable) - run: choco install autohotkey.portable --version=1.1.37.02 -y + run: choco install autohotkey.portable --version=1.1.36.01 -y shell: pwsh - name: Install AutoHotkey v2 @@ -40,8 +40,8 @@ jobs: - name: Syntax Check & Format Validation run: | - $compilerV1 = "C:\ProgramData\chocolatey\lib\autohotkey.portable\tools\Compiler\Ahk2Exe.exe" - $compilerV2 = "$env:ProgramFiles\AutoHotkey\Compiler\Ahk2Exe.exe" + $ahk2Exe = "C:\ProgramData\chocolatey\lib\autohotkey.portable\tools\Compiler\Ahk2Exe.exe" + $ahkV2 = "$env:ProgramFiles\AutoHotkey\v2\AutoHotkey64.exe" $tempDir = New-Item -Type Directory -Force "$env:TEMP\ahk-$(Get-Random)" $syntaxErrors = @() $formatIssues = @() @@ -51,27 +51,32 @@ jobs: Get-ChildItem -Recurse -Filter *.ahk | % { $checked++ - $rel = $_.FullName -replace [regex]::Escape("$(Get-Location)\"), '' + $rel = $_.FullName -replace [regex]::Escape("$(Get-Location)\"), "" # Detect AHK version $content = Get-Content $_.FullName -Raw -Encoding UTF8 $isV2 = $false # Check for #Requires AutoHotkey v2 directive - if ($content -match '(?m)^#Requires\s+AutoHotkey\s+v2') { + if ($content -match "(?m)^#Requires\s+AutoHotkey\s+v2") { $isV2 = $true } # Check for v2 directory paths (Lib/v2, ahk/, Other/**/v2/) - elseif ($rel -match '(Lib[\\/]v2[\\/]|ahk[\\/]|Other.*[\\/]v2[\\/])') { + elseif ($rel -match "(Lib[\\/]v2[\\/]|ahk[\\/]|Other.*[\\/]v2[\\/])") { $isV2 = $true } - $compiler = if ($isV2) { $compilerV2; $v2Count++ } else { $compilerV1; $v1Count++ } $version = if ($isV2) { "v2" } else { "v1" } + if ($isV2) { $v2Count++ } else { $v1Count++ } # Syntax check $tempExe = Join-Path $tempDir "$([IO.Path]::GetRandomFileName()).exe" - & $compiler /in $_.FullName /out $tempExe 2>&1 | Out-Null + + if ($isV2) { + & $ahk2Exe /in $_.FullName /out $tempExe /base $ahkV2 2>&1 | Out-Null + } else { + & $ahk2Exe /in $_.FullName /out $tempExe 2>&1 | Out-Null + } if ($LASTEXITCODE -eq 0 -and (Test-Path $tempExe)) { Write-Host "✓ $rel ($version)" -ForegroundColor Green @@ -84,12 +89,12 @@ jobs: # Format check $content = Get-Content $_.FullName -Raw $problems = @() - if (($content -match '(?m)^\t') -and ($content -match '(?m)^ ')) { $problems += 'mixed indent' } - if ($content -match '[ \t]+`r?`n') { $problems += 'trailing space' } - if (($content -match '`r`n') -and ($content -match '(?