Skip to content

Commit

Permalink
Configure CI (no. 154)
Browse files Browse the repository at this point in the history
  • Loading branch information
cafour committed Jun 11, 2021
1 parent b9c3260 commit 6e17a50
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 90 deletions.
4 changes: 3 additions & 1 deletion ci/linux/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ echo "ROOT=$ROOT"
echo "SLN=$SLN"
echo "CONFIGURATION=$CONFIGURATION"
echo "DISPLAY=$DISPLAY"
echo "SAMPLES_DIR=$SAMPLES_DIR"
echo "TEST_RESULTS_DIR=$TEST_RESULTS_DIR"
echo "SAMPLES_DIR=$SAMPLES_DIR"
echo "SAMPLES_PROFILE=$SAMPLES_PROFILE"
echo "SAMPLES_PORT=$SAMPLES_PORT"
echo "SAMPLES_PORT_API=$SAMPLES_PORT_API"
Expand Down Expand Up @@ -205,11 +205,13 @@ if [ $SLN_RESTORE -eq 1 ]; then
-v:m"
fi

# seleniumconfig.json needs to be copied before the build of the sln
if [ $UI_TESTS -eq 1 ]; then
PROFILE_PATH="$SAMPLES_DIR/Profiles/$SAMPLES_PROFILE"

if [ ! -f "$PROFILE_PATH" ]; then
echo >&2 "Profile '$PROFILE_PATH' doesn't exist."
exit 1
fi
cp -f "$PROFILE_PATH" "$SAMPLES_DIR/seleniumconfig.json"
fi
Expand Down
227 changes: 138 additions & 89 deletions ci/windows/run.ps1
Original file line number Diff line number Diff line change
@@ -1,121 +1,170 @@
param(
[switch] $noNpmBuild = $false,
[switch] $noSlnRestore = $false,
[switch] $noSlnBuild = $false,
[switch] $noUnitTests = $false,
[switch] $noUITests = $false)

$root = $env:DOTVVM_ROOT
if ($null -eq $root) {
$root = "$PWD"
[string] $Root,
[string] $Config,
[string] $SamplesProfile = "seleniumconfig.owin.chrome.json",
[string] $SamplesPort = "5407",
[string] $SamplesPortApi = "61453",
[switch] $Clean = $false,
[switch] $NoNpmBuild = $false,
[switch] $NoSlnRestore = $false,
[switch] $NoSlnBuild = $false,
[switch] $NoUnitTests = $false,
[switch] $NoJSTests = $false,
[switch] $NoUITests = $false)

# ==================
# config var setting
# ==================

$Root = $env:DOTVVM_ROOT
if ($null -eq $Root) {
$Root = "$PWD"
}
$env:DOTVVM_ROOT = $root
$env:DOTVVM_ROOT = $Root

$configuration = $env:CONFIGURATION
if ($null -eq $configuration) {
$configuration = "Release"
$Config = $env:CONFIGURATION
if ($null -eq $Config) {
$Config = "Release"
}

$sln = "$root\ci\windows\Windows.sln"
$packagesDir = "$root\src\packages\"
$testResultsDir = "$root\artifacts\test\"
$sln = "$Root\ci\windows\Windows.sln"
$packagesDir = "$Root\src\packages\"
$testResultsDir = "$Root\artifacts\test\"
$samplesDir = "$root\src\DotVVM.Samples.Tests"

Write-Host "ROOT=$Root"
Write-Host "SLN=$sln"
Write-Host "CONFIGURATION=$Config"
Write-Host "TEST_RESULTS_DIR=$testResultsDir"
Write-Host "SAMPLES_DIR=$samplesDir"
Write-Host "SAMPLES_PROFILE=$SamplesProfile"
Write-Host "SAMPLES_PORT=$SamplesPort"
Write-Host "SAMPLES_PORT_API=$SamplesPortApi"

# ================
# helper functions
# ================

function Write-Header {
param (
[string][parameter(Position=0)]$Text
)
Write-Host -ForegroundColor Yellow "--------------------------------"
Write-Host -BackgroundColor Yellow $Text
Write-Host -ForegroundColor Yellow "--------------------------------"
}

Write-Host "ROOT=$ROOT"
Write-Host "CONFIGURATION=$CONFIGURATION"
function Run-Command {
param (
[string][parameter(Position=0)]$Name,
[scriptblock][parameter(Position=1)]$Command
)
Write-Header $Name
Write-Host -ForegroundColor Blue "$Command"
$Command.Invoke()
}

if ($noNpmBuild -ne $true) {
Write-Host "--------------------------------"
Write-Host "npm build"
Write-Host "--------------------------------"
Set-Location $root\src\DotVVM.Framework
npm ci --cache $root\.npm --prefer-offline
npm run build
function Ensure-Command {
param (
[string][parameter(Position=0)]$Name,
[scriptblock][parameter(Position=1)]$Command
)
Run-Command $Name $Command
if ($LASTEXITCODE -ne 0) {
Write-Host "npm build failed"
Write-Host -ForegroundColor Red "$Name failed"
exit 1
}
}

function Clean-UITest {
Stop-Process -Force -Name chrome -ErrorAction SilentlyContinue
Stop-Process -Force -Name chromedriver -ErrorAction SilentlyContinue
Remove-IISSite -Confirm:$false -Name dotvvm.owin
Remove-IISSite -Confirm:$false -Name dotvvm.owin.api
}

if ($noSlnRestore -ne $true) {
Write-Host "--------------------------------"
Write-Host "sln restore"
Write-Host "--------------------------------"
Set-Location $root
& "$root\src\Tools\NuGet.exe" restore $sln -PackagesDirectory $packagesDir
dotnet restore $sln --packages $packagesDir
if ($LASTEXITCODE -ne 0) {
Write-Host "nuget restore failed"
exit 1
# =============================
# actual continuous integration
# =============================

if ($Clean -eq $true) {
Ensure-Command "clean" {
git clean -dfx
}
}

if ($noSlnBuild -ne $true) {
Write-Host "--------------------------------"
Write-Host "sln build"
Write-Host "--------------------------------"
msbuild $sln -v:m `
-p:PublishProfile=$root\ci\windows\GenericPublish.pubxml `
-p:DeployOnBuild=true `
-p:Configuration=$configuration `
-p:SourceLinkCreate=true
if ($LASTEXITCODE -ne 0) {
Write-Host "dotnet build failed"
exit 1
if ($NoNpmBuild -ne $true) {
Ensure-Command "npm build" {
Set-Location $Root\src\DotVVM.Framework
npm ci --cache $Root\.npm --prefer-offline
npm run build
}
}

if ($noUnitTests -ne $true) {
Write-Host "--------------------------------"
Write-Host "unit tests"
Write-Host "--------------------------------"
dotnet test src/DotVVM.Framework.Tests `
--no-build `
--configuration $configuration `
--logger trx `
--results-directory $testResultsDir `
--collect "Code Coverage"
if ($NoSlnRestore -ne $true) {
Ensure-Command "sln restore" {
Set-Location $Root
& "$Root\src\Tools\NuGet.exe" restore $sln -PackagesDirectory $packagesDir
dotnet restore $sln --packages $packagesDir
}
}

function Clean-UITest {
Stop-Process -Force -Name chrome -ErrorAction SilentlyContinue
Stop-Process -Force -Name chromedriver -ErrorAction SilentlyContinue
Remove-IISSite -Confirm:$false -Name dotvvm.owin
Remove-IISSite -Confirm:$false -Name dotvvm.owin.api
}
# seleniumconfig.json needs to be copied before the build of the sln
if ($UI_TESTS -eq $true) {
$profilePath="$samplesDir\Profiles\$SamplesProfile"

if ($noUITests -ne $true) {
Write-Host "--------------------------------"
Write-Host "UI tests"
Write-Host "--------------------------------"
if (Test-Path -PathType Leaf -Path $profilePath) {
Write-Host -ForegroundColor Red "Profile '$PROFILE_PATH' doesn't exist."
exit 1
}
Copy-Item -Force "$profilePath" "$samplesDir\seleniumconfig.json"
}

Import-Module IISAdministration
Clean-UITest
if ($NoSlnBuild -ne $true) {
Ensure-Command "sln build" {
msbuild $sln -v:m `
-p:PublishProfile=$Root\ci\windows\GenericPublish.pubxml `
-p:DeployOnBuild=true `
-p:Configuration=$Config `
-p:SourceLinkCreate=true
}
}

icacls $root\artifacts\ /grant "IIS_IUSRS:(OI)(CI)F"
if ($NoUnitTests -ne $true) {
Run-Command "unit tests" {
dotnet test src/DotVVM.Framework.Tests `
--no-build `
--configuration $Config `
--logger trx `
--results-directory $testResultsDir `
--collect "Code Coverage"
}
}

New-IISSite -Name dotvvm.owin `
-PhysicalPath $root\artifacts\DotVVM.Samples.BasicSamples.Owin `
-BindingInformation "*:5407:"
if ($noUITests -ne $true) {
Run-Command "UI tests" {
Import-Module IISAdministration
Clean-UITest

New-IISSite -Name dotvvm.owin.api `
-PhysicalPath $root\artifacts\DotVVM.Samples.BasicSamples.Api.Owin `
-BindingInformation "*:61453:"
icacls $Root\artifacts\ /grant "IIS_IUSRS:(OI)(CI)F"

Copy-Item -Force -Recurse `
$root\src\DotVVM.Samples.Common `
$root\artifacts
New-IISSite -Name dotvvm.owin `
-PhysicalPath $Root\artifacts\DotVVM.Samples.BasicSamples.Owin `
-BindingInformation "*:5407:"

Copy-Item -Force `
$root\src\DotVVM.Samples.Tests\Profiles\seleniumconfig.owin.chrome.json `
$root\src\DotVVM.Samples.Tests\seleniumconfig.json
New-IISSite -Name dotvvm.owin.api `
-PhysicalPath $Root\artifacts\DotVVM.Samples.BasicSamples.Api.Owin `
-BindingInformation "*:61453:"

dotnet test $root\src\DotVVM.Samples.Tests `
--configuration $configuration `
--logger trx `
--results-directory $testResultsDir
Copy-Item -Force -Recurse `
$Root\src\DotVVM.Samples.Common `
$Root\artifacts

Clean-UITest
dotnet test $Root\src\DotVVM.Samples.Tests `
--configuration $Config `
--logger trx `
--results-directory $testResultsDir

Get-Process
Clean-UITest
}
}
1 change: 1 addition & 0 deletions ci/windows/test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker run --rm -it --mount "type=bind,src=${PWD},dst=C:\s" docker-reg.riganti.cz/docker-agent:latest-windows powershell

0 comments on commit 6e17a50

Please sign in to comment.