Skip to content
This repository was archived by the owner on Jun 14, 2024. It is now read-only.

Commit fa0cb65

Browse files
Buildenv setup
* remove test results * only build master and skip README PRs * add publish and artifacts * specify artifact in appveyor
1 parent 25fd313 commit fa0cb65

File tree

9 files changed

+358
-132
lines changed

9 files changed

+358
-132
lines changed

Diff for: .gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bin
2+
obj
3+
out
4+
TestsResults.xml

Diff for: .travis.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
language: generic
2+
3+
matrix:
4+
include:
5+
- os: osx
6+
osx_image: xcode9.1
7+
before_install:
8+
- brew update
9+
- brew tap caskroom/cask
10+
- brew cask install powershell
11+
- os: linux
12+
dist: trusty
13+
sudo: required
14+
addons:
15+
apt:
16+
sources:
17+
- sourceline: deb [arch=amd64] https://packages.microsoft.com/ubuntu/14.04/prod trusty main
18+
key_url: https://packages.microsoft.com/keys/microsoft.asc
19+
packages:
20+
- powershell
21+
22+
script:
23+
- pwsh -c 'Install-Module InvokeBuild -Force -Scope CurrentUser; Invoke-Build'

Diff for: NuGet.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="PowerShell MyGet" value="https://powershell.myget.org/F/powershell-core/api/v3/index.json" />
5+
</packageSources>
6+
</configuration>

Diff for: appveyor.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
build: off
2+
3+
# Ignore testing a commit if only the README.md file changed
4+
# Or if various strings are found in the commit message: updated readme, update readme, update docs, update version, update appveyor
5+
skip_commits:
6+
files:
7+
- README.md
8+
message: /updated readme.*|update readme.*s|update docs.*|update version.*|update appveyor.*/
9+
10+
branches:
11+
only:
12+
- master
13+
14+
test_script:
15+
- pwsh: Install-Module InvokeBuild -Force -Scope CurrentUser; Invoke-Build
16+
17+
artifacts:
18+
- path: out\PSIoT
19+
name: PSIoT

Diff for: build.ps1

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/usr/bin/env pwsh
2+
param(
3+
[Parameter()]
4+
[switch]
5+
$Bootstrap,
6+
7+
[Parameter()]
8+
[switch]
9+
$Clean,
10+
11+
[Parameter()]
12+
[switch]
13+
$Test
14+
)
15+
16+
$NeededTools = @{
17+
PowerShellCore = "PowerShell Core 6.0.0 or greater"
18+
DotNetSdk = "dotnet sdk 2.0 or greater"
19+
PowerShellGet = "PowerShellGet latest"
20+
InvokeBuild = "InvokeBuild latest"
21+
}
22+
23+
function needsPowerShellCore () {
24+
try {
25+
$powershellverison = (pwsh -v)
26+
} catch {
27+
return $true
28+
}
29+
return $false
30+
}
31+
32+
function needsDotNetSdk () {
33+
try {
34+
$dotnetverison = (dotnet --version)
35+
} catch {
36+
return $true
37+
}
38+
return $false
39+
}
40+
41+
function needsPowerShellGet () {
42+
if (Get-Module -ListAvailable -Name PowerShellGet) {
43+
return $false
44+
}
45+
return $true
46+
}
47+
48+
function needsInvokeBuild () {
49+
if (Get-Module -ListAvailable -Name InvokeBuild) {
50+
return $false
51+
}
52+
return $true
53+
}
54+
55+
function getMissingTools () {
56+
$missingTools = @()
57+
58+
if (needsPowerShellCore) {
59+
$missingTools += $NeededTools.PowerShellCore
60+
}
61+
if (needsDotNetSdk) {
62+
$missingTools += $NeededTools.DotNetSdk
63+
}
64+
if (needsPowerShellGet) {
65+
$missingTools += $NeededTools.PowerShellGet
66+
}
67+
if (needsInvokeBuild) {
68+
$missingTools += $NeededTools.InvokeBuild
69+
}
70+
71+
return $missingTools
72+
}
73+
74+
function hasMissingTools () {
75+
return ((getMissingTools).Count -gt 0)
76+
}
77+
78+
if ($Bootstrap) {
79+
$string = "Here is what your environment is missing:`n"
80+
$missingTools = getMissingTools
81+
if (($missingTools).Count -eq 0) {
82+
$string += "* nothing!`n`n Run this script without a flag to build or a -Clean to clean."
83+
} else {
84+
$missingTools | ForEach-Object {$string += "* $_`n"}
85+
$string += "`nAll instructions for installing these tools can be found on PowerShell Editor Services' Github:`n" `
86+
+ "https://github.com/powershell/PowerShellEditorServices#development"
87+
}
88+
Write-Host "`n$string`n"
89+
} elseif(hasMissingTools) {
90+
Write-Host "You are missing needed tools. Run './build.ps1 -Bootstrap' to see what they are."
91+
} else {
92+
if($Clean) {
93+
Invoke-Build Clean
94+
}
95+
96+
Invoke-Build Build
97+
98+
if($Test) {
99+
Invoke-Build Test
100+
}
101+
}

Diff for: psiot.build.ps1

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
function NeedsRestore($rootPath) {
2+
# This checks to see if the number of folders under a given
3+
# path (like "src" or "test") is greater than the number of
4+
# obj\project.assets.json files found under that path, implying
5+
# that those folders have not yet been restored.
6+
$projectAssets = (Get-ChildItem "$rootPath\*\obj\project.assets.json")
7+
return ($projectAssets -eq $null) -or ((Get-ChildItem $rootPath).Length -gt $projectAssets.Length)
8+
}
9+
10+
task Restore -If { "Restore" -in $BuildTask -or (NeedsRestore(".\src")) } {
11+
Push-Location $PSScriptRoot\src
12+
exec { dotnet restore }
13+
Pop-Location
14+
}
15+
16+
task Clean Restore, {
17+
Push-Location $PSScriptRoot\src
18+
exec { dotnet clean }
19+
Pop-Location
20+
}
21+
22+
task Build Restore, {
23+
Push-Location $PSScriptRoot\src
24+
exec { dotnet build }
25+
Pop-Location
26+
}
27+
28+
task Test {
29+
Install-Module Pester -Force -Scope CurrentUser
30+
Push-Location $PSScriptRoot\test
31+
$res = Invoke-Pester -OutputFormat NUnitXml -OutputFile TestsResults.xml -PassThru;
32+
if ($env:APPVEYOR) {
33+
(New-Object System.Net.WebClient).UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\TestsResults.xml));
34+
}
35+
if ($res.FailedCount -gt 0) { throw "$($res.FailedCount) tests failed."}
36+
Pop-Location
37+
}
38+
39+
task Package Build, {
40+
if ((Test-Path "$PSScriptRoot\out")) {
41+
Remove-Item -Path $PSScriptRoot\out -Recurse
42+
}
43+
New-Item -ItemType directory -Path $PSScriptRoot\out
44+
New-Item -ItemType directory -Path $PSScriptRoot\out\PSIoT
45+
46+
Copy-Item -Path "$PSScriptRoot\src\psiot\PSIoT.psd1" -Destination "$PSScriptRoot\out\PSIoT\" -Force
47+
Copy-Item -Path "$PSScriptRoot\src\psiot\bin\Debug\netcoreapp2.0\psiot.dll" -Destination "$PSScriptRoot\out\PSIoT\" -Force
48+
}
49+
50+
# The default task is to run the entire CI build
51+
task . Clean, Build, Test, Package

Diff for: src/psiot/PSIoT.psd1

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@{
2+
GUID="eb74e8da-9ae2-482a-a648-e96550fb8745"
3+
Author="Microsoft Corporation"
4+
CompanyName="Microsoft Corporation"
5+
Copyright="© Microsoft Corporation. All rights reserved."
6+
Description='PowerShell IoT'
7+
ModuleVersion="0.0.1"
8+
PowerShellVersion="3.0"
9+
FunctionsToExport = '*'
10+
DotNetFrameworkVersion = 4.5
11+
CmdletsToExport = '*'
12+
AliasesToExport = @()
13+
NestedModules=@('psiot.dll')
14+
HelpInfoURI = 'https://go.microsoft.com/fwlink/?LinkId=393254'
15+
}

0 commit comments

Comments
 (0)