Skip to content

Commit

Permalink
!build updated build process and Authentication function replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
scrthq committed Oct 18, 2018
1 parent 8cc0fb0 commit 72783c5
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 43 deletions.
14 changes: 3 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,11 @@ notifications:
on_failure: always
on_start: always
before_install:
- chmod +x ci/download.sh
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew install openssl; brew
install python3; mkdir -p /usr/local/lib; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
/usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/;
fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get -y install python3; nvm
install v6.0.0; fi
- chmod +x pwsh_download.sh
install:
- pushd ci
- "./download.sh"
- popd
- ./pwsh_download.sh
before_script:
- export PATH=~/.local/bin:$PATH
script:
- ulimit -n 4096
- pwsh -File ci/init.ps1
- pwsh -File build.ps1
4 changes: 2 additions & 2 deletions DebugMode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

# Enable Debug Mode to export the New-GoogleService function during module import
# by setting the environment variable '$env:EnablePSGSuiteDebug' to $true
$env:EnablePSGSuiteDebug = $true
$env:EnablePSGSuiteDebug = $false

Get-Module PSGSuite | Remove-Module -Force

. ([System.IO.Path]::Combine("$PSScriptRoot","ci","init.ps1")) -Task Compile
. .\build.ps1 -Task Compile

# Force import the module in the repo path so that updated functions are reloaded
$modulePath = [System.IO.Path]::Combine("$PSScriptRoot","out","PSGSuite")
Expand Down
File renamed without changes.
File renamed without changes.
19 changes: 10 additions & 9 deletions Tests/Module Tests/PSGSuite.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
$PSVersion = $PSVersionTable.PSVersion.Major
$ModuleName = "PSGSuite"
$projectRoot = Resolve-Path "$PSScriptRoot\..\.."
$ModulePath = Resolve-Path "$projectRoot\out\$ModuleName"
$decompiledModulePath = Resolve-Path "$projectRoot\$ModuleName"
$ModulePath = Resolve-Path "$projectRoot\out\$($env:BHProjectName)"
$decompiledModulePath = Resolve-Path "$projectRoot\$($env:BHProjectName)"
$env:EnablePSGSuiteDebug = $true

# Verbose output for non-master builds on appveyor
Expand All @@ -17,12 +16,7 @@ $moduleRoot = Split-Path (Resolve-Path "$ModulePath\*\*.psd1")

Import-Module $ModulePath -Force -Verbose:$false

Describe "Module tests: $ModuleName" {
Context "Confirm private functions are not exported on module import" {
It "Should throw when checking for New-MimeMessage in the exported commands" {
{Get-Command -Name New-MimeMessage -Module PSGSuite -ErrorAction Stop} | Should -Throw "The term 'New-MimeMessage' is not recognized as the name of a cmdlet, function, script file, or operable program."
}
}
Describe "Module tests: $($env:BHProjectName)" {
Context "Confirm files are valid Powershell syntax" {
$scripts = Get-ChildItem $decompiledModulePath -Include *.ps1,*.psm1,*.psd1 -Recurse

Expand All @@ -38,6 +32,13 @@ Describe "Module tests: $ModuleName" {
$errors.Count | Should Be 0
}
}
Context "Confirm private functions are not exported on module import" {
$testCase = Get-ChildItem "$decompiledModulePath\Private" -Recurse -Include *.ps1 | Foreach-Object {@{item = $_.BaseName}}
It "Should throw when checking for '<item>' in the module commands" -TestCases $testCase {
param($item)
{Get-Command -Name $item -Module $env:BHProjectName -ErrorAction Stop} | Should -Throw "The term '$item' is not recognized as the name of a cmdlet, function, script file, or operable program."
}
}
Context "Confirm all aliases are created" {
$aliasHash = . "$decompiledModulePath\Aliases\PSGSuite.Aliases.ps1"

Expand Down
20 changes: 2 additions & 18 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,5 @@ only_commits:
build: false

test_script:
- pwsh: >-
if ($env:PSVersion -eq 'Core') {
$string = "Running PowerShell $($PSVersionTable.PSVersion.ToString()) tests on image '$env:APPVEYOR_BUILD_WORKER_IMAGE'";
Write-Host -ForegroundColor Magenta $string;
. .\ci\init.ps1;
} else {
$string = "Skipping PowerShell $($PSVersionTable.PSVersion.ToString()) tests on image '$env:APPVEYOR_BUILD_WORKER_IMAGE'";
Write-Warning $string;
}
- ps: >-
if ($env:PSVersion -eq 'Windows') {
$string = "Running PowerShell $($PSVersionTable.PSVersion.ToString()) tests on image '$env:APPVEYOR_BUILD_WORKER_IMAGE'";
Write-Host -ForegroundColor Magenta $string;
. .\ci\init.ps1;
} else {
$string = "Skipping PowerShell $($PSVersionTable.PSVersion.ToString()) tests on image '$env:APPVEYOR_BUILD_WORKER_IMAGE'";
Write-Warning $string;
}
- pwsh: if ($env:PSVersion -eq 'Core') {. .\build.ps1}
- ps: if ($env:PSVersion -eq 'Windows') {. .\build.ps1}
File renamed without changes.
6 changes: 3 additions & 3 deletions ci/psake.ps1 → psake.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ task Clean -depends Init {

task Compile -depends Clean {
# Create module output directory
$functionsToExport = @('Get-GSToken','New-GoogleService')
$functionsToExport = @()
$aliasesToExport = (. $sut\Aliases\PSGSuite.Aliases.ps1).Keys
$modDir = New-Item -Path $outputModDir -ItemType Directory -ErrorAction SilentlyContinue
New-Item -Path $outputModVerDir -ItemType Directory -ErrorAction SilentlyContinue > $null
Expand All @@ -75,7 +75,6 @@ task Compile -depends Clean {
Get-ChildItem -Path (Join-Path -Path $sut -ChildPath 'Private') -Recurse -File | ForEach-Object {
"$(Get-Content $_.FullName -Raw)`n" | Add-Content -Path $psm1 -Encoding UTF8
}
"if (`$env:EnablePSGSuiteDebug) {Export-ModuleMember -Function @('Get-GSToken','New-GoogleService')}`n" | Add-Content -Path $psm1 -Encoding UTF8
Get-ChildItem -Path (Join-Path -Path $sut -ChildPath 'Public') -Recurse -File | ForEach-Object {
"$(Get-Content $_.FullName -Raw)`nExport-ModuleMember -Function '$($_.BaseName)'`n" | Add-Content -Path $psm1 -Encoding UTF8
$functionsToExport += $_.BaseName
Expand Down Expand Up @@ -188,7 +187,8 @@ catch {
# Update FunctionsToExport on manifest
Update-ModuleManifest -Path (Join-Path $outputModVerDir "$($env:BHProjectName).psd1") -FunctionsToExport ($functionsToExport | Sort-Object) -AliasesToExport ($aliasesToExport | Sort-Object)

if ((Get-Item (Join-Path $outputModVerDir "$($env:BHProjectName).psd1")).BaseName -cne $env:BHProjectName) {
if ((Get-ChildItem $outputModVerDir | Where-Object {$_.Name -eq "$($env:BHProjectName).psd1"}).BaseName -cne $env:BHProjectName) {
" Renaming manifest to correct casing"
Rename-Item (Join-Path $outputModVerDir "$($env:BHProjectName).psd1") -NewName "$($env:BHProjectName).psd1" -Force
}
" Created compiled module at [$outputModDir]"
Expand Down
File renamed without changes.

0 comments on commit 72783c5

Please sign in to comment.