From b2bf1d3deb3439729e1e4e22e49eb6e9b4b73128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8C=C3=A1bera?= Date: Thu, 4 Jul 2019 21:22:17 +0200 Subject: [PATCH] Skip updated manifest support for Excavator (#28) * Log files from PR * Add rooster for forked repositories * typo * comment * Readme * Reorganize events * Backbone * Comments and logs * Support SKIP_UPDATED for excavator This will reduce log output * No need for [bool] cast --- Entrypoint.ps1 | 28 +++++++++++++++---- README.md | 15 ++++++---- .../Fork.opened.json} | 0 events/{PRs.opened.json => PRs/Opened.json} | 0 4 files changed, 33 insertions(+), 10 deletions(-) rename events/{PR.fork.opened.json => PRs/Fork.opened.json} (100%) rename events/{PRs.opened.json => PRs/Opened.json} (100%) diff --git a/Entrypoint.ps1 b/Entrypoint.ps1 index ac061a1..9b09f13 100644 --- a/Entrypoint.ps1 +++ b/Entrypoint.ps1 @@ -359,6 +359,7 @@ function Initialize-Scheduled { 'Push' = $true } if ($env:SPECIAL_SNOWFLAKES) { $params.Add('SpecialSnowflakes', ($env:SPECIAL_SNOWFLAKES -split ',')) } + if ($env:SKIP_UPDATED) { $params.Add('SkipUpdated', $true) } & "$env:SCOOP_HOME\bin\auto-pr.ps1" @params # TODO: Post some comment?? @@ -378,27 +379,41 @@ function Initialize-PR { exit 0 } + <#TODO: Handle cloning of forked repository + $head = $EVENT.pull_request.head + if ($head.repo.fork) { $REPOSITORY_forked = "$($head.repo.full_name):$($head.ref)" } + + $cloneLocation = '/github/forked_workspace' + git clone --branch $head.ref $head.repo.clone_url $cloneLocation + $BUCKET_ROOT = $cloneLocation + Push-Location $cloneLocation + $MANIFESTS_LOCATION = if (Test-Path (Join-Path $BUCKET_ROOT 'bucket')) { Join-Path $BUCKET_ROOT 'bucket' } else { $BUCKET_ROOT } + #> + + Get-Location + Write-log 'Files in PR:' + Get-ChildItem $BUCKET_ROOT Get-ChildItem $MANIFESTS_LOCATION + $checks = @() $prID = $EVENT.number # Do not run on removed files $files = Get-AllChangedFilesInPR $prID -Filter - # $message = @() - $checks = @() + Write-Log $files foreach ($file in $files) { Write-Log "Starting $($file.filename) checks" # Convert path into gci item to hold all needed information - # TODO: Resolve root of PR $manifest = Get-ChildItem $BUCKET_ROOT $file.filename $object = Get-Content $manifest -Raw | ConvertFrom-Json $statuses = [Ordered] @{ } #region Property checks $statuses.Add('Description', ([bool] $object.description)) + # TODO: More advanced license checks $statuses.Add('License', ([bool] $object.license)) #endregion Property checks @@ -416,7 +431,6 @@ function Initialize-PR { #region Checkver Write-Log 'Checkver' - # TODO: Autoupdate $outputV = @(& "$env:SCOOP_HOME\bin\checkver.ps1" -App $manifest.Basename -Dir $MANIFESTS_LOCATION -Force *>&1) Write-log $outputV @@ -429,7 +443,11 @@ function Initialize-PR { #region formatjson Write-Log 'Format' - # TODO: + # TODO: implement format check using array compare if possible (or just strings with raws) + # TODO: I am not sure if this will handle tabs and everything what could go wrong. + #$raw = Get-Content $manifest.Fullname -Raw + #$new_raw = $object | ConvertToPrettyJson + #$statuses.Add('Format', ($raw -eq $new_raw)) Write-Log 'Format done' #endregion formatjson diff --git a/README.md b/README.md index 9d7bb5d..80d18c5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ -❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗ DO NOT USE YET. Wait for 1.0 tag releae ❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗ +

+❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗ DO NOT USE YET. Wait for 1.0.0 tag release ❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗ +

+ +You could participate in testing using `@stable` version or any of already released tags from release page. # Github actions for scoop buckets @@ -66,7 +70,7 @@ workflow "Excavator" { } action "IssueHandler" { - uses = "Ash258/Scoop-GithubActions@master" + uses = "Ash258/Scoop-GithubActions@stable" args = "Issue" env = { "GITH_EMAIL" = "youremail@email.com" # Email is needed for pushing to repository within action container @@ -75,7 +79,7 @@ action "IssueHandler" { } action "PullRequestHandler" { - uses = "Ash258/Scoop-GithubActions@master" + uses = "Ash258/Scoop-GithubActions@stable" args = "PR" env = { "GITH_EMAIL" = "youremail@email.com" @@ -84,10 +88,11 @@ action "PullRequestHandler" { } action "Excavate" { - uses = "Ash258/Scoop-GithubActions@master" + uses = "Ash258/Scoop-GithubActions@stable" args = "Scheduled" env = { - "SPECIAL_SNOWFLAKES" = "curl,brotli,jx" # Optional parameter, + "SPECIAL_SNOWFLAKES" = "curl,brotli,jx" # Optional parameter + "SKIP_UPDATED" = "1" # Optional parameter, Could be anything as value "GITH_EMAIL" = "youremail@email.com" } secrets = ["GITHUB_TOKEN"] diff --git a/events/PR.fork.opened.json b/events/PRs/Fork.opened.json similarity index 100% rename from events/PR.fork.opened.json rename to events/PRs/Fork.opened.json diff --git a/events/PRs.opened.json b/events/PRs/Opened.json similarity index 100% rename from events/PRs.opened.json rename to events/PRs/Opened.json