-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: ensure manifests use the standard JSON format #38
Conversation
Hi @HUMORCE, could you please help me review the PR? |
GithubActions/src/Action/PR.psm1 Lines 301 to 309 in 97c0343
The PR handler of ScoopInstaller/Extras#12216 does not even execute to emm, I don't know much about this repo. |
this is veify result: ScoopInstaller/Extras#12216 (comment) |
The log output shows that it returned at L308. Try create a test repo for this. |
This improvement should be implemented in Scoop Core / CI. It already contains most of the relevant checks, but seems the JSON syntax check is not included.
|
FYI I'm disabling scoop in Repology until proper validation is implemented, as less than a week from the previous fix, it's broken again.
|
Shelling out to another process does not seem like the most efficient way to do this - is it possible to use a .NET API to do this directly (and uniformly)? |
@rashil2000 I had a go at finding a .NET API to validate the JSON. However, I couldn't find a uniform way of doing it in both Powershell 5 and 7. This is because The following code checks the Powershell version and uses the right API. However, Microsoft's docs suggest that you should use $file = Get-Content $manifest -Raw
if ($PSVersionTable.PSVersion -lt "6.0") {
Add-Type -AssemblyName System.Web.Extensions
$jsonSerializer = New-Object System.Web.Script.Serialization.JavaScriptSerializer
try {
$parsed = $jsonSerializer.DeserializeObject($file)
$object = $file | ConvertFrom-Json
# Valid JSON
}
catch [System.ArgumentException] {
$object = $null
# Bad JSON
}
}
else {
try {
$parsed = [System.Text.Json.JsonDocument]::Parse($file)
$object = $file | ConvertFrom-Json
# Valid JSON
}
catch {
$object = $null
# Bad JSON
}
} This code returns the parsed |
I'm waiting for Scoop being brought back to the Repology list, and this PR is the primary blocker from what I can see. I believe there is one easier way to achieve this by just setting up the GitHub CI to use Footnotes |
@chawyehsu Unfortunately, the CI jobs is not compatible with |
I haven't tested this repo on |
Not much work needs to be done to switch to the trigger: codebase diff: |
Latest progress, the workflow now works on pull requests opened from forks, namely we don't need to manually comment https://github.com/chawyehsu/ScoopTestBucket/pull/4 Footnotes |
The
ConvertFrom-Json
method in PowerShell 7 supports JSON with comments.The
ConvertFrom-Json
method in PowerShell 5 supports only standard JSON.See the documentation for details: ConvertFrom-Json
Formatting the manifest file again using the
ConvertFrom-Json
method in PowerShell 5 ensures that the manifest file is in standard JSON format (without extra commas, comments, etc.).Relates to ScoopInstaller/Extras#12216