Skip to content

Commit

Permalink
(chocolatey-community#39) Update scripts based on majkinetor template
Browse files Browse the repository at this point in the history
Co-Authored-By: Miodrag Milić <[email protected]>
  • Loading branch information
TheCakeIsNaOH and majkinetor committed Jul 13, 2024
1 parent e758ab1 commit e3cd954
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 18 deletions.
14 changes: 10 additions & 4 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
version: '{build}'
max_jobs: 1
image: WMF 5
# History plugin requires complete log
#clone_depth: 5
branches:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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'
Expand All @@ -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
}
Expand All @@ -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'))
1 change: 1 addition & 0 deletions setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
42 changes: 36 additions & 6 deletions test_all.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
52 changes: 44 additions & 8 deletions update_all.ps1
Original file line number Diff line number Diff line change
@@ -1,29 +1,55 @@
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
Path = "$PSScriptRoot\Update-AUPackages.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
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'
}
}

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
}
Expand All @@ -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
Expand All @@ -61,16 +93,20 @@ $Options = [ordered]@{
ForcedPackages = $ForcedPackages -split ' '
BeforeEach = {
param($PackageName, $Options )
$p = $Options.ForcedPackages | ? { $_ -match "^${PackageName}(?:\:(.+))*$" }

$pattern = "^${PackageName}(?:\\(?<stream>[^:]+))?(?:\:(?<version>.+))?$"
$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
Expand Down
14 changes: 14 additions & 0 deletions update_vars_default.ps1
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e3cd954

Please sign in to comment.