Skip to content

Commit

Permalink
Test new build system
Browse files Browse the repository at this point in the history
  • Loading branch information
Pogromca-SCP committed Jan 22, 2024
1 parent c1ff558 commit ef6efcb
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build SLCommand Script

jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x

- name: Prepare for tests
shell: pwsh
run: |
${{ github.workspace }}/build_test.ps1 -pluginName SLCommandScript -workspacePath ${{ github.workspace }} -referencesVariable SL_REFERENCES -dependencies SLCommandScript.Core,SLCommandScript.FileScriptsLoader
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: SLCommand Script
path: D:/plugin/Artifacts
74 changes: 74 additions & 0 deletions build_test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
param(
[Parameter(Mandatory = $true)]
[string] $pluginName,

[Parameter(Mandatory = $true)]
[string] $workspacePath,

[Parameter(Mandatory = $false)]
[string] $referencesVariable = $null,

[Parameter(Mandatory = $false)]
[string] $depotDownloaderVersion = "2.5.0",

[Parameter(Mandatory = $false)]
[bool] $runTests = $true,

[Parameter(Mandatory = $false)]
[Int32] $initialTestRuns = 3,

[Parameter(Mandatory = $false)]
[string[]] $dependencies = @()
)

if (-not [string]::IsNullOrWhiteSpace($referencesVariable)) {
Set-Item "Env:\$referencesVariable" -Value "D:/plugin/SCPSL_REFERENCES/SCPSL_Data/Managed"
}

New-Item -ItemType Directory -Force -Path D:/plugin
New-Item -ItemType Directory -Force -Path D:/plugin/DepotDownloader
Invoke-WebRequest -Uri "https://github.com/SteamRE/DepotDownloader/releases/download/DepotDownloader_$depotDownloaderVersion/depotdownloader-$depotDownloaderVersion.zip" -OutFile "D:/plugin/depotdownloader.zip"
Expand-Archive -Path D:/plugin/depotdownloader.zip -PassThru -DestinationPath D:/plugin/DepotDownloader

New-Item -ItemType Directory -Force -Path D:/plugin/SCPSL_REFERENCES
Start-Process -NoNewWindow -Wait -FilePath "D:/plugin/DepotDownloader/DepotDownloader.exe" -WorkingDirectory "D:/plugin/DepotDownloader" -ArgumentList "-app 996560","-dir D:/plugin/SCPSL_REFERENCES"

dotnet restore
dotnet build --no-restore --configuration Release

if ($runTests -and $initialTestRuns -gt 0) {
$psi = New-Object System.Diagnostics.ProcessStartInfo
$psi.FileName = "D:/plugin/SCPSL_REFERENCES/LocalAdmin.exe"
$psi.Arguments = "7777"
$psi.WorkingDirectory = "D:/plugin/SCPSL_REFERENCES/"
$psi.UseShellExecute = $false
$psi.RedirectStandardInput = $true

$pr = [System.Diagnostics.Process]::Start($psi)
Start-Sleep -s 5
$pr.StandardInput.WriteLine("yes")
Start-Sleep -s 2
$pr.StandardInput.WriteLine("keep")
Start-Sleep -s 2
$pr.StandardInput.WriteLine("global")
Start-Sleep -s 60
$pr.StandardInput.WriteLine("exit")
Start-Sleep -s 2

for ($i = 0; $i -lt $initialTestRuns; $i++) {
dotnet test --no-build --verbosity quiet
Start-Sleep -s 2
}
}

if ($runTests) {
dotnet test --no-build --verbosity normal
}

New-Item -ItemType Directory -Force -Path D:/plugin/Artifacts
Copy-Item "$workspacePath/$pluginName/bin/Release/net48/$pluginName.dll" -Destination D:/plugin/Artifacts

if ($dependencies.Length -gt 0) {
$assemblies = $dependencies | ForEach-Object -Process { "$workspacePath/$_/bin/Release/net48/$_.dll" }
Compress-Archive $assemblies -DestinationPath D:/plugin/Artifacts/dependencies.zip
}

0 comments on commit ef6efcb

Please sign in to comment.