diff --git a/.appveyor.yml b/.appveyor.yml index 9e4bb01204..72be229553 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,6 +1,5 @@ version: '{build}' max_jobs: 1 -image: WMF 5 # History plugin requires complete log #clone_depth: 5 branches: @@ -11,7 +10,7 @@ branches: environment: # Set au version to use or omit to use the latest. Specify branch name to use development version from Github - au_version: + au_version: master au_push: true # Force test: use 1 to test all, or N to split testing into N groups au_test_groups: 1 @@ -51,6 +50,7 @@ install: - ps: 'Get-CimInstance win32_operatingsystem -Property Caption, OSArchitecture, Version | fl Caption, OSArchitecture, Version' - ps: $PSVersionTable - git --version +- choco --version - ps: | git clone -q https://github.com/chocolatey-community/chocolatey-au.git $Env:TEMP/au . "$Env:TEMP/au/scripts/Install-AU.ps1" $Env:au_version @@ -61,6 +61,9 @@ install: ' {0,-20} {1}' -f 'FORCED BUILD:' , ($Env:APPVEYOR_FORCED_BUILD -eq 'true') ' {0,-20} {1}' -f 'RE BUILD:' , ($Env:APPVEYOR_RE_BUILD -eq 'true') +# Uncomment the below line if you are using any of the functions from chocolatey-core.extension - https://chocolatey.org/packages/chocolatey-core.extension. Ensure you also have it listed in your package's dependencies +# - cinst chocolatey-core.extension + build_script: - ps: | $ErrorActionPreference = 'Continue' @@ -79,7 +82,10 @@ build_script: Write-Host ("{0}`n{1}`n" -f ('-'*60), "PACKAGE: $package") $package_dir = ls -recurse | ? { $_.Name -eq "$package.nuspec"} | select -First 1 | % Directory if (!$package_dir) { Write-Warning "Can't find package '$package'"; continue } - pushd $package_dir; choco pack; Push-Package; popd + pushd $package_dir + if (Test-Path update.ps1 -ea 0) { ./update.ps1 } + choco pack; Push-Package; + popd } return } @@ -102,4 +108,4 @@ notifications: on_build_status_changed: true #on_finish: -#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) +#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) \ No newline at end of file diff --git a/setup/README.md b/setup/README.md index 94e7f924f2..cd6bec430c 100644 --- a/setup/README.md +++ b/setup/README.md @@ -4,6 +4,7 @@ * Open `au_setup.ps1` in an editor and review it. * Run PowerShell `5.x` as Administrator (chocolatey-au framework supports PowerShell 6+ but this setup does not). * Run `au_setup.ps1`. +* For local automatic packaging, copy `update_vars_default.ps1` to `update_default.ps1` and fill it in. * Configure chocolatey-au [plugins](https://github.com/chocolatey-community/chocolatey-au/blob/master/Plugins.md). * Configure [AppVeyor](https://github.com/chocolatey-community/chocolatey-au/wiki/AppVeyor). * Configure [local run](https://github.com/chocolatey-community/chocolatey-au/wiki#local-run). diff --git a/test_all.ps1 b/test_all.ps1 index d43057e7e5..dc34f3935c 100644 --- a/test_all.ps1 +++ b/test_all.ps1 @@ -20,27 +20,57 @@ if (($Name.Length -gt 0) -and ($Name[0] -match '^random (.+)')) { } $options = [ordered]@{ - Force = $true - Push = $false + Force = $true + Push = $false + Threads = 10 + + IgnoreOn = @( #Error message parts to set the package ignore status + 'Could not create SSL/TLS secure channel' + 'Could not establish trust relationship' + 'The operation has timed out' + 'Internal Server Error' + 'Service Temporarily Unavailable' + 'Choco pack failed with exit code 1' + ) + + RepeatOn = @( #Error message parts on which to repeat package updater + 'Could not create SSL/TLS secure channel' # https://github.com/chocolatey/chocolatey-coreteampackages/issues/718 + 'Could not establish trust relationship' # -||- + 'Unable to connect' + 'The remote name could not be resolved' + 'Choco pack failed with exit code 1' # https://github.com/chocolatey/chocolatey-coreteampackages/issues/721 + 'The operation has timed out' + 'Internal Server Error' + 'An exception occurred during a WebClient request' + 'Job returned no object, Vector smash ?' + ) + RepeatSleep = 60 #How much to sleep between repeats in seconds, by default 0 + RepeatCount = 2 #How many times to repeat on errors, by default 1 Report = @{ Type = 'markdown' #Report type: markdown or text - Path = "$PSScriptRoot\Update-Force-Test-${n}.md" #Path where to save the report + 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 + NoAppVeyor = $true # 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 + UserMessage = "[Ignored](#ignored) | [Update report](https://gist.github.com/$Env:gist_id)" # 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 + 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 + +$au_errors = $global:info | ? { $_.Error } | select -ExpandProperty Error + +if ($ThrowOnErrors -and $au_errors.Count -gt 0) { + throw 'Errors during update' +} \ No newline at end of file diff --git a/update_all.ps1 b/update_all.ps1 index 840f9c5dc8..6bd6e278c8 100644 --- a/update_all.ps1 +++ b/update_all.ps1 @@ -1,13 +1,39 @@ -param([string] $Name, [string] $ForcedPackages, [string] $Root = "$PSScriptRoot\automatic") +param([string[]] $Name, [string] $ForcedPackages, $Root = "$PSScriptRoot\automatic") if (Test-Path $PSScriptRoot/update_vars.ps1) { . $PSScriptRoot/update_vars.ps1 } $Options = [ordered]@{ + WhatIf = $au_WhatIf #Whatif all packages + Force = $false #Force all packages Timeout = 100 #Connection timeout in seconds UpdateTimeout = 1200 #Update timeout in seconds Threads = 10 #Number of background jobs to use Push = $Env:au_Push -eq 'true' #Push to chocolatey + PushAll = $true #Allow to push multiple packages at once PluginPath = '' #Path to user plugins + IgnoreOn = @( #Error message parts to set the package ignore status + 'Could not create SSL/TLS secure channel' + 'Could not establish trust relationship' + 'The operation has timed out' + 'Internal Server Error' + 'Service Temporarily Unavailable' + ) + RepeatOn = @( #Error message parts on which to repeat package updater + 'Could not create SSL/TLS secure channel' # https://github.com/chocolatey/chocolatey-coreteampackages/issues/718 + 'Could not establish trust relationship' + 'Unable to connect' + 'The remote name could not be resolved' + 'Choco pack failed with exit code 1' # https://github.com/chocolatey/chocolatey-coreteampackages/issues/721 + 'The operation has timed out' + 'Internal Server Error' + 'An exception occurred during a WebClient request' + 'remote session failed with an unexpected state' + ) + #RepeatSleep = 250 #How much to sleep between repeats in seconds, by default 0 + #RepeatCount = 2 #How many times to repeat on errors, by default 1 + + #NoCheckChocoVersion = $true #Turn on this switch for all packages + Report = @{ Type = 'markdown' #Report type: markdown or text @@ -15,7 +41,7 @@ $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 = "[History](#update-history)" # Markdown, Text: Custom user message to show + UserMessage = "[Ignored](#ignored) | [History](#update-history) | [Force Test](https://gist.github.com/$Env:gist_id_test) | [Releases](https://github.com/$Env:github_user_repo/tags)" # 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' @@ -23,7 +49,7 @@ $Options = [ordered]@{ } History = @{ - Lines = 30 #Number of lines to show + Lines = 120 #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 } @@ -39,14 +65,20 @@ $Options = [ordered]@{ Password = $Env:github_api_key #Password if username is not empty, otherwise api key } + GitReleases = @{ + ApiToken = $Env:github_api_key #Your github api key + ReleaseType = 'package' #Either 1 release per date, or 1 release per package + } + RunInfo = @{ - Exclude = 'password', 'apikey' #Option keys which contain those words will be removed + Exclude = 'password', 'apikey', 'apitoken' #Option keys which contain those words will be removed Path = "$PSScriptRoot\update_info.xml" #Path where to save the run info } Mail = if ($Env:mail_user) { @{ To = $Env:mail_user + From = $Env:mail_from Server = $Env:mail_server UserName = $Env:mail_user Password = $Env:mail_pass @@ -61,16 +93,20 @@ $Options = [ordered]@{ ForcedPackages = $ForcedPackages -split ' ' BeforeEach = { param($PackageName, $Options ) - $p = $Options.ForcedPackages | ? { $_ -match "^${PackageName}(?:\:(.+))*$" } + + $pattern = "^${PackageName}(?:\\(?[^:]+))?(?:\:(?.+))?$" + $p = $Options.ForcedPackages | ? { $_ -match $pattern } if (!$p) { return } - $global:au_Force = $true - $global:au_Version = ($p -split ':')[1] + $global:au_Force = $true + $global:au_IncludeStream = $Matches['stream'] + $global:au_Version = $Matches['version'] } } if ($ForcedPackages) { Write-Host "FORCED PACKAGES: $ForcedPackages" } -$global:au_Root = $Root #Path to the AU packages +$global:au_Root = $Root #Path to the AU packages +$global:au_GalleryUrl = '' #URL to package gallery, leave empty for Chocolatey Gallery $global:info = updateall -Name $Name -Options $Options #Uncomment to fail the build on AppVeyor on any package error diff --git a/update_vars_default.ps1 b/update_vars_default.ps1 new file mode 100644 index 0000000000..91d04fc670 --- /dev/null +++ b/update_vars_default.ps1 @@ -0,0 +1,14 @@ +# Copy this file to update_vars.ps1 and set the variables there. Do not include it in the repository. + +$Env:mail_user = '' +$Env:mail_pass = '' +$Env:mail_server = 'smtp.gmail.com' +$Env:mail_port = '587' +$Env:mail_enablessl = 'true' + +$Env:api_key = '' #Chocolatey api key +$Env:gist_id = '' #Specify your gist id or leave empty for anonymous gist +$Env:gist_id_test = '' #Specify your gist id for test runs or leave empty for anonymous gist +$Env:github_user_repo = '' #{github_user}/{repo} +$Env:github_api_key = '' #Github personal access token +$Env:au_Push = 'false' #Push to chocolatey \ No newline at end of file