Skip to content

onverted to windows runner #242

onverted to windows runner

onverted to windows runner #242

Workflow file for this run

name: "CI: Build and Test"
on:
push:
branches: [main, feat/github-actions-pipeline]
paths:
- "**.cs"
- "**.cshtml"
- "**.tsx"
- "**.js"
- "**.json"
- "**.csproj"
- "**.props"
- "**.targets"
- "**.sln"
- "**.yml"
pull_request:
branches: [main]
paths:
- "**.cs"
- "**.cshtml"
- "**.tsx"
- "**.js"
- "**.json"
- "**.csproj"
- "**.props"
- "**.targets"
- "**.sln"
env:
XBK_DIR: "${{ github.workspace }}\\..\\xbk"
SA_PASSWORD: "asdfg12345!@#$%"
XBK_ADMIN_PASSWORD: "administrator"
LICENCE_FILE: "licence.txt"
jobs:
build:
runs-on: windows-latest
steps:
# UMT setup
- name: Checkout code
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Install dependencies and build
run: |
dotnet restore --locked-mode
dotnet tool restore
- name: <DB> Install SQL Server
uses: Particular/[email protected]
with:
connection-string-env-var: SQL_SERVER_CONNECTION_STRING
catalog: kentico-boilerplate
- name: Install SQL Server Management Studio
run: |
choco install sql-server-management-studio -y
- name: <DB> Create Kentico DB user
run: |
sqlcmd -Q "CREATE LOGIN kentico WITH PASSWORD = '${{ env.SA_PASSWORD }}';
CREATE USER kentico FOR LOGIN kentico;
GO"
- name: <DB> Add kentico user to sysadmin role
run: |
sqlcmd -Q "sp_addsrvrolemember 'kentico', 'sysadmin';
GO"
- name: <DB> Enable SQL authentication
run: |
Write-Output "SQL Server: Setting Mixed Mode Authentication."
New-ItemProperty 'HKLM:\Software\Microsoft\Microsoft SQL Server\MSSQL16.SQLEXPRESS\MSSQLServer\' -Name 'LoginMode' -Value 2 -Force
Write-Output "SQL Server: Forcing Restart of Instance."
Restart-Service -Force 'MSSQL$SQLEXPRESS'
- name: <DB> Test SQL Server login as admin
run: |
sqlcmd -S ".\SQLEXPRESS" -U 'kentico' -P '${{ env.SA_PASSWORD }}' -Q "SELECT 'Login successful' AS Message"
# Xperience by Kentico setup
- name: <XbK> Install kentico templates
run: |
$XBK_CORE_VERSION = Select-String -Path "Directory.Packages.props" -Pattern '<PackageVersion Include="Kentico.Xperience.Core" Version="([^"]*)"' | ForEach-Object { $_.Matches.Groups[1].Value }
mkdir $env:XBK_DIR
cd $env:XBK_DIR
dotnet new install Kentico.Xperience.Templates::$XBK_CORE_VERSION
- name: <XbK> Create Kentico Xperience project
working-directory: ${{ env.XBK_DIR }}
run: |
echo "y" | dotnet new kentico-xperience-mvc -n kentico-boilerplate
- name: <XbK> Run kentico dbmanager with license
working-directory: ${{ env.XBK_DIR }}
run: |
echo ${{ secrets.XPERIENCE_BY_KENTICO_LICENSE }} > $env:LICENCE_FILE
Write-Output "SQL_SERVER_CONNECTION_STRING: $env:SQL_SERVER_CONNECTION_STRING"
dotnet kentico-xperience-dbmanager -- -s ".\SQLEXPRESS" -d "pwtest" -u "kentico" -p "$env:SA_PASSWORD" -a "$env:XBK_ADMIN_PASSWORD" --recreate-existing-database --hash-string-salt "<hash_string_salt>" --license-file "$LICENCE_FILE"
rm $env:LICENCE_FILE
- name: <XbK> Run kentico boilerplate
run: |
Start-Job -ScriptBlock { dotnet run --project "${{ env.XBK_DIR }}\.csproj" } -Name "XbK"
Start-Sleep -Seconds 10
Get-Job -Name "XbK"
Receive-Job -Name "XbK"
# Run example migration
- name: Prepare appsettings.json for migration
run: |
$EXAMPLE_APPSETTINGS = "examples/Kentico.Xperience.UMT.Example.Console/appsettings.json"
$CMS_CONNECTION_STRING = (Get-Content "$env:XBK_DIR/appsettings.json" | ConvertFrom-Json).ConnectionStrings.CMSConnectionString
$appsettings = Get-Content $EXAMPLE_APPSETTINGS | ConvertFrom-Json
$appsettings.ConnectionStrings.CMSConnectionString = $CMS_CONNECTION_STRING
$appsettings.WebApplicationPhysicalPath = "$env:XBK_DIR"
$appsettings | ConvertTo-Json -Compress | Set-Content $EXAMPLE_APPSETTINGS
Get-Content $EXAMPLE_APPSETTINGS
- name: Run example migration
working-directory: ${{ github.workspace }}/examples/Kentico.Xperience.UMT.Example.Console
run: |
dotnet run
- name: Print XbK output
run: |
Get-Job -Name "XbK"
Receive-Job -Name "XbK"
# Playwright
- name: Install Playwright
working-directory: ${{ github.workspace }}/tests/Kentico.Xperience.UMT.Tests
run: |
dotnet build
bin/Debug/net8.0/playwright.ps1 install --with-deps
- name: Replace BASE_URL in test.runsettings
run: |
Get-Content "$env:XBK_DIR/Properties/launchSettings.json"
$BASE_URL = (Get-Content "$env:XBK_DIR/Properties/launchSettings.json" | ConvertFrom-Json).profiles.kentico_boilerplate.applicationUrl
(Get-Content test.runsettings) -replace "<BASE_URL>([^<]*)</BASE_URL>", "<BASE_URL>$BASE_URL</BASE_URL>" | Set-Content test.runsettings
# - name: Print xbk output
# run: |
# Receive-Job -Name "XbK"
- name: run tests
run: |
dotnet test --settings:test.runsettings
- name: Stop XbK
run: |
Stop-Job -Name "XbK" -Force