Browse Source

synced with AU packages template

Miodrag Milic 3 years ago
parent
commit
57aa601c09
3 changed files with 75 additions and 4 deletions
  1. 18 2
      .appveyor.yml
  2. 46 0
      test_all.ps1
  3. 11 2
      update_all.ps1

+ 18 - 2
.appveyor.yml

@@ -3,7 +3,8 @@
 version: '{build}'
 max_jobs: 1
 image: WMF 5
-clone_depth: 5
+# History plugin requires complete log
+#clone_depth: 5
 branches:
   only:
   - master
@@ -14,6 +15,8 @@ environment:
   # Set au version to use or omit to use the latest. Specify branch name to use development version from Github
   au_version:
   au_push: true
+  # Force test: use 1 to test all, or N to split testing into N groups
+  au_test_groups: 1
 
   # Github token to commit pushed packages to repository
   github_user_repo: {github_user}/{repository}
@@ -34,6 +37,9 @@ environment:
   # Optional, leave empty to create anonymous gist
   gist_id:
 
+  # Force test: gist id for test results
+  gist_id_test:
+
   # Chocolatey API key - to push updated packages
   api_key:
     secure: YOUR_CHOCO_API_KEY_HERE_ENCRYPTED_STRING # https://ci.appveyor.com/tools/encrypt
@@ -51,10 +57,20 @@ install:
     git clone -q https://github.com/majkinetor/au.git $Env:TEMP/au
     . "$Env:TEMP/au/scripts/Install-AU.ps1" $Env:au_version
 
+- ps: |
+    "Build info"
+    '  {0,-20} {1}' -f 'SCHEDULED BUILD:', ($Env:APPVEYOR_SCHEDULED_BUILD -eq 'true')
+    '  {0,-20} {1}' -f 'FORCED BUILD:'   , ($Env:APPVEYOR_FORCED_BUILD    -eq 'true')
+    '  {0,-20} {1}' -f 'RE BUILD:'       , ($Env:APPVEYOR_RE_BUILD        -eq 'true')
+
 build_script:
 - ps: |
+    $ErrorActionPreference = 'Continue'
+
+    if ($Env:APPVEYOR_PROJECT_NAME  -like '*test*') { ./test_all.ps1 "random $Env:au_test_groups"; return }
+
     if ( ($Env:APPVEYOR_SCHEDULED_BUILD -ne 'true') -and ($Env:APPVEYOR_FORCED_BUILD -ne 'true') ) {
-        switch -regex ($Env:APPVEYOR_REPO_COMMIT_MESSAGE) 
+        switch -regex ($Env:APPVEYOR_REPO_COMMIT_MESSAGE)
         {
             '\[AU (.+?)\]'   { $forced = $Matches[1] }
 

+ 46 - 0
test_all.ps1

@@ -0,0 +1,46 @@
+#Name can be 'random N' to randomly force the Nth group of packages.
+
+param( [string[]] $Name, [string] $Root = "$PSScriptRoot" )
+
+if (Test-Path $PSScriptRoot/update_vars.ps1) { . $PSScriptRoot/update_vars.ps1 }
+$global:au_root = Resolve-Path $Root
+
+if (($Name.Length -gt 0) -and ($Name[0] -match '^random (.+)')) {
+    [array] $lsau = lsau
+
+    $group = [int]$Matches[1]
+    $n = (Get-Random -Maximum $group)
+    Write-Host "TESTING GROUP $($n+1) of $group"
+
+    $group_size = [int]($lsau.Count / $group) + 1
+    $Name = $lsau | select -First $group_size -Skip ($group_size*$n) | % { $_.Name }
+
+    Write-Host ($Name -join ' ')
+    Write-Host ('-'*80)
+}
+
+$options = [ordered]@{
+    Force = $true
+    Push = $false
+
+    Report = @{
+        Type = 'markdown'                                   #Report type: markdown or text
+        Path = "$PSScriptRoot\Update-Force-Test-${n}.md"      #Path where to save the report
+        Params= @{                                          #Report parameters:
+            Github_UserRepo = $Env:github_user_repo         #  Markdown: shows user info in upper right corner
+            NoAppVeyor  = $false                            #  Markdown: do not show AppVeyor build shield
+            Title       = "Update Force Test - Group ${n}"
+            UserMessage = "[Update report](https://gist.github.com/$Env:gist_id) | **USING AU NEXT VERSION**"       #  Markdown, Text: Custom user message to show
+        }
+    }
+
+    Gist = @{
+        Id     = $Env:gist_id_test                          #Your gist id; leave empty for new private or anonymous gist
+        ApiKey = $Env:github_api_key                        #Your github api key - if empty anoymous gist is created
+        Path   = "$PSScriptRoot\Update-Force-Test-${n}.md"       #List of files to add to the gist
+        Description = "Update Force Test Report #powershell #chocolatey"
+    }
+}
+
+
+$global:info = updateall -Name $Name -Options $Options

+ 11 - 2
update_all.ps1

@@ -17,14 +17,23 @@ $Options = [ordered]@{
         Params= @{                                          #Report parameters:
             Github_UserRepo = $Env:github_user_repo         #  Markdown: shows user info in upper right corner
             NoAppVeyor  = $false                            #  Markdown: do not show AppVeyor build shield
-            UserMessage = ''                                #  Markdown, Text: Custom user message to show
+            UserMessage = "[History](#update-history)"       #  Markdown, Text: Custom user message to show
+            NoIcons     = $false                            #  Markdown: don't show icon
+            IconSize    = 32                                #  Markdown: icon size
+            Title       = ''                                #  Markdown, Text: TItle of the report, by default 'Update-AUPackages'
         }
     }
 
+    History = @{
+        Lines = 30                                          #Number of lines to show
+        Github_UserRepo = $Env:github_user_repo             #User repo to be link to commits
+        Path = "$PSScriptRoot\Update-History.md"            #Path where to save history
+    }
+
     Gist = @{
         Id     = $Env:gist_id                               #Your gist id; leave empty for new private or anonymous gist
         ApiKey = $Env:github_api_key                        #Your github api key - if empty anoymous gist is created
-        Path   = "$PSScriptRoot\Update-AUPackages.md"       #List of files to add to the gist
+        Path   = "$PSScriptRoot\Update-AUPackages.md", "$PSScriptRoot\Update-History.md"       #List of files to add to the gist
     }
 
     Git = @{