Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Init automated testing: #23

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
174 changes: 174 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,19 @@ jobs:

env:
ASPNETCORE_ENVIRONMENT: CI
XBK_DATABASE_BACKUP_FILENAME: ""
K13_DATABASE_BACKUP_FILENAME: ""
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: 1
XBK_PROJECT_NAME: DancingGoat
K13_PROJECT_NAME: Kentico13_DancingGoat
XBK_URL: https://localhost:14066
K13_URL: https://localhost:65375
XBK_STATUS_CHECK_URL: https://localhost:14066/status
K13_STATUS_CHECK_URL: https://localhost:65375/status
XPERIENCE_BY_KENTICO_LICENSE: ${{ secrets.XPERIENCE_BY_KENTICO_LICENSE }}
KENTICO_XPERIENCE_13_LICENSE: ${{ secrets.KENTICO_XPERIENCE_13_LICENSE }}

steps:
- uses: actions/checkout@v4
Expand All @@ -60,10 +70,174 @@ jobs:
--configuration Release `
--no-restore

- name: Get Database Backup Name
run: |
$latestBackups = Get-Content -Path "./database/backups.txt" -TotalCount 2
"K13_DATABASE_BACKUP_FILENAME=$($latestBackups[0])" >> $env:GITHUB_ENV
"XBK_DATABASE_BACKUP_FILENAME=$($latestBackups[1])" >> $env:GITHUB_ENV

- name: Extract Database Backup
run: |
Expand-Archive `
-Path "./database/${{ env.K13_DATABASE_BACKUP_FILENAME }}.zip" `
-DestinationPath "./database"
Expand-Archive `
-Path "./database/${{ env.XBK_DATABASE_BACKUP_FILENAME }}.zip" `
-DestinationPath "./database"

- name: Install a SQL Server suite of tools (SQLEngine, SQLPackage)
uses: potatoqualitee/mssqlsuite@9a0136e208df60b8ecb62909f076bc34854fa55a # set as a commit hash for security - v1.7
with:
install: sqlpackage, sqlengine
sa-password: Pass@12345
version: 2022

- name: Restore Database .bak
run: |
docker exec sql mkdir /var/opt/mssql/backup
docker cp "./database/${{ env.K13_DATABASE_BACKUP_FILENAME }}" sql:/var/opt/mssql/backup
sqlcmd `
-S localhost `
-d master `
-U "sa" `
-P "Pass@12345" `
-Q "RESTORE DATABASE [Kentico13_DancingGoat] FROM DISK='/var/opt/mssql/backup/${{ env.K13_DATABASE_BACKUP_FILENAME }}' WITH MOVE 'Kentico13_DancingGoat' TO '/var/opt/mssql/data/Kentico13_DancingGoat.mdf', MOVE 'Kentico13_DancingGoat_log' TO '/var/opt/mssql/data/Kentico13_DancingGoat_log.ldf'"
docker cp "./database/${{ env.XBK_DATABASE_BACKUP_FILENAME }}" sql:/var/opt/mssql/backup
sqlcmd `
-S localhost `
-d master `
-U "sa" `
-P "Pass@12345" `
-Q "RESTORE DATABASE [XByK_DancingGoat_K13Ecommerce] FROM DISK='/var/opt/mssql/backup/${{ env.XBK_DATABASE_BACKUP_FILENAME }}' WITH MOVE 'XByK_DancingGoat_K13Ecommerce' TO '/var/opt/mssql/data/XByK_DancingGoat_K13Ecommerce.mdf', MOVE 'XByK_DancingGoat_K13Ecommerce_log' TO '/var/opt/mssql/data/XByK_DancingGoat_K13Ecommerce_log.ldf'"

- name: Imports license key to DB
run: |
sqlcmd `
-S localhost `
-d Kentico13_DancingGoat `
-U "sa" `
-P "Pass@12345" `
-Q "INSERT INTO [dbo].[CMS_LicenseKey] VALUES ('localhost', '${{ env.KENTICO_XPERIENCE_13_LICENSE }}', 'X', '10/20/2025', 1);"
sqlcmd `
-S localhost `
-d XByK_DancingGoat_K13Ecommerce `
-U "sa" `
-P "Pass@12345" `
-Q "UPDATE CMS_SettingsKey SET KeyValue='${{ env.XPERIENCE_BY_KENTICO_LICENSE }}' WHERE KeyName='CMSLicenseKey'"

- name: Restore CI Repository
working-directory: "./scripts"
run: |
./Restore-CI.ps1

- name: Publish Application
run: |
dotnet publish `
./examples/Kentico13_DancingGoatStore `
-c Release `
-o ./publish/K13 `
--no-build `
--no-restore
dotnet publish `
./examples/DancingGoat-K13Ecommerce `
-c Release `
-o ./publish/XbK `
--no-build `
--no-restore

#- name: Install Playwright Dependencies
# TODO: to je blbost
#run: |
# ./test/Kentico.Community.Portal.Web.E2E.Tests/bin/Release/net8.0/playwright.ps1 install

- name: Install Azurite
id: azuright
uses: potatoqualitee/azuright@e56d2754eb15218d507961493bc83ca037216887 # set as a commit hash for security - v1.1

- name: Test Solution
run: |
dotnet test `
--filter TestCategory!~Integration `
--configuration Release `
--no-build `
--no-restore

# - name: Run K13 Store
# run: |
# # Run the ASP.NET Core app as a background job
# cd ./publish/K13
# "ASPNETCORE_URLS=${{ env.K13_URL }}" >> $env:GITHUB_ENV
# Start-Job -ScriptBlock { dotnet ./${{ env.K13_PROJECT_NAME }}.dll } -Name ${{ env.K13_PROJECT_NAME }}
# Receive-Job -Name ${{ env.K13_PROJECT_NAME }}
# cd ../../

# # The ASP.NET Core app can take a few seconds to start, so we delay running tests
# # until it is ready, and fail if we go over a maximum wait time
# $limit = 10
# $attempts = 0
# $success = $false

# while ($attempts -lt $limit -and -not $success) {
# Start-Sleep -Seconds 1
# try {
# $response = Invoke-WebRequest -Uri ${{ env.K13_STATUS_CHECK_URL }} -Method Get -SkipCertificateCheck
# if ($response.StatusCode -eq 200) {
# Write-Output "K13 store: Application is ready."
# $success = $true
# }
# }
# catch {
# Write-Output "Attempt $attempts - Application not ready yet."
# }
# $attempts++
# }

# if (-not $success) {
# Write-Output "K13 store: Application did not respond in time."
# exit 1
# }

- name: Run Application and E2E Tests
run: |
# Run the ASP.NET Core app as a background job
cd ./publish/XbK
"ASPNETCORE_URLS=${{ env.XBK_URL }}" >> $env:GITHUB_ENV
Start-Job -ScriptBlock { dotnet ./${{ env.XBK_PROJECT_NAME }}.dll } -Name ${{ env.XBK_PROJECT_NAME }}
Receive-Job -Name ${{ env.XBK_PROJECT_NAME }}
cd ../../

# The ASP.NET Core app can take a few seconds to start, so we delay running tests
# until it is ready, and fail if we go over a maximum wait time
$limit = 10
$attempts = 0
$success = $false

while ($attempts -lt $limit -and -not $success) {
Start-Sleep -Seconds 1
try {
$response = Invoke-WebRequest -Uri ${{ env.XBK_STATUS_CHECK_URL }} -Method Get -SkipCertificateCheck
if ($response.StatusCode -eq 200) {
Write-Output "XbK Application is ready."
$success = $true
}
}
catch {
Write-Output "Attempt $attempts - Application not ready yet."
}
$attempts++
}

if (-not $success) {
Write-Output "XbK Application did not respond in time."
exit 1
}

# TODO: Run the E2E tests

# Stop the background ASP.NET Core application
Receive-Job -Name ${{ env.K13_PROJECT_NAME }}
Stop-Job -Name ${{ env.K13_PROJECT_NAME }}
Remove-Job -Name ${{ env.K13_PROJECT_NAME }}
Receive-Job -Name ${{ env.XBK_PROJECT_NAME }}
Stop-Job -Name ${{ env.XBK_PROJECT_NAME }}
Remove-Job -Name ${{ env.XBK_PROJECT_NAME }}
11 changes: 6 additions & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
<CentralPackageVersionOverrideEnabled>false</CentralPackageVersionOverrideEnabled>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
<CentralPackageFloatingVersionsEnabled>true</CentralPackageFloatingVersionsEnabled>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Duende.AccessTokenManagement.OpenIdConnect" Version="3.0.0" />
<PackageVersion Include="Kentico.Xperience.Admin" Version="29.3.3" />
<PackageVersion Include="Kentico.Xperience.WebApp" Version="29.3.3" />
<PackageVersion Include="kentico.xperience.azurestorage" Version="29.3.3" />
<PackageVersion Include="kentico.xperience.imageprocessing" Version="29.3.3" />
<PackageVersion Include="Kentico.Xperience.Core" Version="29.3.3" />
<PackageVersion Include="Kentico.Xperience.Admin" Version="29.5.3" />
<PackageVersion Include="Kentico.Xperience.WebApp" Version="29.5.3" />
<PackageVersion Include="kentico.xperience.azurestorage" Version="29.5.3" />
<PackageVersion Include="kentico.xperience.imageprocessing" Version="29.5.3" />
<PackageVersion Include="Kentico.Xperience.Core" Version="29.5.3" />
<PackageVersion Include="Scrutor" Version="4.2.2" />
<PackageVersion Include="Microsoft.Extensions.ApiDescription.Client" Version="8.0.8" />
<PackageVersion Include="NSwag.ApiDescription.Client" Version="14.1.0" />
Expand Down
Binary file added database/2024_10_21_Kentico13_DancingGoat.bak.zip
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions database/backups.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
2024_10_21_Kentico13_DancingGoat.bak
2024_10_21_XByK_DancingGoat_K13Ecommerce.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<cms.alternativeform>
<FormClassID>
<CodeName>cms.AlternativeForm</CodeName>
<GUID>7d7cbe11-e101-469f-a4a3-ee452f3982df</GUID>
<ObjectType>cms.class</ObjectType>
</FormClassID>
<FormDefinition>
<form>
<field column="FormID" guid="d65b8a4f-95fb-4a35-9f98-04c2a746f6de" isunique="true" />
<field column="FormDisplayName" columnprecision="0" enabled="true" guid="0be5e0a7-1704-47dc-b063-5e6fb3e91c46" visible="true">
<settings>
<controlname>Kentico.Administration.TextInput</controlname>
</settings>
<properties>
<explanationtextashtml>False</explanationtextashtml>
<fieldcaption>{$base.uiforms.FormDisplayName$}</fieldcaption>
<fielddescriptionashtml>False</fielddescriptionashtml>
</properties>
</field>
<field column="FormName" columnprecision="0" enabled="true" guid="4c90ce6a-e202-4035-a51d-f27469743148" visible="true">
<settings>
<controlname>Kentico.Administration.CodeName</controlname>
<HasAutomaticCodeNameGenerationOption>False</HasAutomaticCodeNameGenerationOption>
<IsCollapsed>True</IsCollapsed>
</settings>
<properties>
<explanationtextashtml>False</explanationtextashtml>
<fieldcaption>{$base.uiforms.FormName$}</fieldcaption>
<fielddescriptionashtml>False</fielddescriptionashtml>
</properties>
</field>
<field column="FormClassID" guid="5a4749e1-d4b8-4753-9b2e-298433d675c6" />
<field column="FormDefinition" guid="a1307cae-635b-48b5-a291-e992f746fc9e" />
<field column="FormGUID" guid="b1ff5048-0f5d-462f-818a-b6c582e45db1" />
<field column="FormLastModified" columnprecision="7" guid="12a04abb-af1c-493c-9350-c8c08f5736ff" />
<field column="FormCoupledClassID" guid="b9cb787e-87b6-4ebe-86ba-71470ae3e698" />
<field column="FormCustomizedColumns" guid="f2d242dd-c4ea-40f3-96f0-cd5ba27c13ce" />
<field column="FormIsCustom" guid="c587b0d7-34e7-4608-8e5e-de0cc240f898" />
</form>
</FormDefinition>
<FormDisplayName>FormEdit</FormDisplayName>
<FormGUID>0a4c1c76-35e4-431d-86a9-bc1ed1f310f8</FormGUID>
<FormIsCustom>False</FormIsCustom>
<FormName>FormEdit</FormName>
</cms.alternativeform>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<cms.alternativeform>
<FormClassID>
<CodeName>CMS.Channel</CodeName>
<GUID>4c9def5a-eaa9-4193-94e6-5fdcae2a4bd9</GUID>
<ObjectType>cms.class</ObjectType>
</FormClassID>
<FormDefinition>
<form>
<field column="ChannelID" guid="33aa7dc4-e6c8-4453-a459-423f92b0e606" enabled="" />
<field column="ChannelDisplayName" enabled="true" guid="81347e19-7cd9-4aa3-9045-73c9b9478783" visible="true">
<settings>
<controlname>Kentico.Administration.TextInput</controlname>
</settings>
<properties>
<explanationtextashtml>False</explanationtextashtml>
<fieldcaption>{$base.channels.channel.displayname$}</fieldcaption>
<fielddescriptionashtml>False</fielddescriptionashtml>
</properties>
</field>
<field column="ChannelName" enabled="true" guid="fc533407-2fa5-4530-a5e2-7f972e0db992" visible="true">
<settings>
<controlname>Kentico.Administration.CodeName</controlname>
<HasAutomaticCodeNameGenerationOption>True</HasAutomaticCodeNameGenerationOption>
<IsCollapsed>True</IsCollapsed>
</settings>
<properties>
<explanationtextashtml>False</explanationtextashtml>
<fieldcaption>{$base.channels.channel.codename$}</fieldcaption>
<fielddescriptionashtml>False</fielddescriptionashtml>
</properties>
</field>
<field column="ChannelType" enabled="true" guid="d4aa1a02-2270-47f0-a44c-e84f8c011591" visible="true">
<settings>
<controlname>Kentico.Administration.DropDownSelector</controlname>
<Options>
<![CDATA[
Website;{$base.channels.channel.website.caption$}
Email;{$base.channels.channel.email.caption$}
Headless;{$base.channels.channel.headless.caption$}
]]>
</Options>
</settings>
<properties>
<explanationtextashtml>False</explanationtextashtml>
<fieldcaption>{$base.channels.channel.type$}</fieldcaption>
<fielddescriptionashtml>False</fielddescriptionashtml>
</properties>
</field>
<field column="ChannelGUID" guid="1e802beb-f06d-4575-b5d0-f66c365fa1e1" enabled="" />
<field column="ChannelSize" enabled="true" guid="cd7665d1-05f5-40e9-a140-da05df9abd83" visible="true">
<settings>
<controlname>Kentico.Administration.DropDownSelector</controlname>
<OptionsValueSeparator>;</OptionsValueSeparator>
</settings>
<properties>
<explanationtextashtml>False</explanationtextashtml>
<fieldcaption>{$base.channels.channel.size.label$}</fieldcaption>
<fielddescription>{$base.channels.channel.size.tooltip$}</fielddescription>
<fielddescriptionashtml>True</fielddescriptionashtml>
<defaultvalue />
</properties>
</field>
</form>
</FormDefinition>
<FormDisplayName>Create channel</FormDisplayName>
<FormGUID>9f2f4a51-77ef-4180-b57d-92167b83aadb</FormGUID>
<FormIsCustom>False</FormIsCustom>
<FormName>ChannelCreate</FormName>
</cms.alternativeform>
Loading
Loading