Skip to content

Commit

Permalink
Migrate Redpoint.CloudFramework to UET mono-repo (#122)
Browse files Browse the repository at this point in the history
* Migrate Redpoint.CloudFramework to UET mono-repo

We're not using this yet in UET.

* Fix package version conflict, update DSN, add privacy policy notice on UEFS install

* Fix .NET install steps

* Fix CI detection for Cloud Framework tests

* Break cache with incorrectly cached data

* Fix environment variables for Cloud Framework tests

* Try to fix test result output path on Linux tests
  • Loading branch information
hach-que authored Jan 15, 2025
1 parent 7d7de65 commit 996679c
Show file tree
Hide file tree
Showing 353 changed files with 32,457 additions and 63 deletions.
88 changes: 55 additions & 33 deletions .github/actions/dotnet-sdk/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,74 +12,96 @@ runs:
id: cache-sdk-win
uses: actions/cache@v4
with:
key: dotnet-sdk-windows-${{ inputs.UET_FRAMEWORK_TARGET }}
restore-keys: dotnet-sdk-windows-${{ inputs.UET_FRAMEWORK_TARGET }}
path: .dotnet-${{ inputs.UET_FRAMEWORK_TARGET }}
key: dotnet-sdk-windows-${{ inputs.UET_FRAMEWORK_TARGET }}-v2
restore-keys: dotnet-sdk-windows-${{ inputs.UET_FRAMEWORK_TARGET }}-v2
path: .dotnet
- name: Cache .NET SDK (macOS)
if: ${{ runner.os == 'macOS' }}
id: cache-sdk-mac
uses: actions/cache@v4
with:
key: dotnet-sdk-mac-${{ inputs.UET_FRAMEWORK_TARGET }}
restore-keys: dotnet-sdk-mac-${{ inputs.UET_FRAMEWORK_TARGET }}
path: .dotnet-${{ inputs.UET_FRAMEWORK_TARGET }}
key: dotnet-sdk-mac-${{ inputs.UET_FRAMEWORK_TARGET }}-v2
restore-keys: dotnet-sdk-mac-${{ inputs.UET_FRAMEWORK_TARGET }}-v2
path: .dotnet
- name: Cache .NET SDK (Linux)
if: ${{ runner.os == 'Linux' }}
id: cache-sdk-linux
uses: actions/cache@v4
with:
key: dotnet-sdk-linux-${{ inputs.UET_FRAMEWORK_TARGET }}-v2
restore-keys: dotnet-sdk-linux-${{ inputs.UET_FRAMEWORK_TARGET }}-v2
path: .dotnet
- name: Download .NET SDK (Windows)
if: ${{ runner.os == 'Windows' && steps.cache-sdk-win.outputs.cache-hit != 'true' }}
shell: pwsh
env:
UET_FRAMEWORK_TARGET: ${{ inputs.UET_FRAMEWORK_TARGET }}
UET_DOTNET_WIN_DL: https://download.visualstudio.microsoft.com/download/pr/6902745c-34bd-4d66-8e84-d5b61a17dfb7/e61732b00f7e144e162d7e6914291f16/dotnet-sdk-8.0.101-win-x64.zip
run: |
if (!(Test-Path .dotnet-${env:UET_FRAMEWORK_TARGET}\dotnet\dotnet-extracted)) {
if (Test-Path ".dotnet-${env:UET_FRAMEWORK_TARGET}") {
Remove-Item -Recurse -Force ".dotnet-${env:UET_FRAMEWORK_TARGET}"
if (!(Test-Path .dotnet\dotnet\dotnet-extracted)) {
if (Test-Path ".dotnet") {
Remove-Item -Recurse -Force ".dotnet"
}
Write-Host "Setting up .NET SDK..."
New-Item -ItemType Directory ".dotnet-${env:UET_FRAMEWORK_TARGET}" | Out-Null
curl.exe -L -o ".dotnet-${env:UET_FRAMEWORK_TARGET}\dotnet.zip" "${env:UET_DOTNET_WIN_DL}"
New-Item -ItemType Directory ".dotnet" | Out-Null
Invoke-WebRequest https://dot.net/v1/dotnet-install.ps1 -UseBasicParsing -OutFile ".dotnet\dotnet-install.ps1"
.\.dotnet\dotnet-install.ps1 -Channel "$($env:UET_FRAMEWORK_TARGET.Substring(3))" -InstallDir ".dotnet\dotnet"
if ($LastExitCode -ne 0) {
exit $LastExitCode
}
Expand-Archive -Path ".dotnet-${env:UET_FRAMEWORK_TARGET}\dotnet.zip" -DestinationPath ".dotnet-${env:UET_FRAMEWORK_TARGET}\dotnet" -Force | Out-Null
Set-Content -Path .dotnet-${env:UET_FRAMEWORK_TARGET}\dotnet\dotnet-extracted -Value "done"
Set-Content -Path .dotnet\dotnet\dotnet-extracted -Value "done"
}
- name: Download .NET SDK (macOS)
if: ${{ runner.os == 'macOS' && steps.cache-sdk-mac.outputs.cache-hit != 'true' }}
shell: pwsh
env:
UET_FRAMEWORK_TARGET: ${{ inputs.UET_FRAMEWORK_TARGET }}
UET_DOTNET_MAC_DL: https://download.visualstudio.microsoft.com/download/pr/ef083c06-7aee-4a4f-b18b-50c9a8990753/e206864e7910e81bbd9cb7e674ff1b4c/dotnet-sdk-8.0.101-osx-arm64.tar.gz
run: |
if (!(Test-Path .dotnet-${env:UET_FRAMEWORK_TARGET}/dotnet/dotnet-extracted)) {
if (Test-Path ".dotnet-${env:UET_FRAMEWORK_TARGET}") {
Remove-Item -Recurse -Force ".dotnet-${env:UET_FRAMEWORK_TARGET}"
if (!(Test-Path .dotnet/dotnet/dotnet-extracted)) {
if (Test-Path ".dotnet") {
Remove-Item -Recurse -Force ".dotnet"
}
Write-Host "Setting up .NET SDK..."
New-Item -ItemType Directory ".dotnet-${env:UET_FRAMEWORK_TARGET}" | Out-Null
curl -L -o ".dotnet-${env:UET_FRAMEWORK_TARGET}/dotnet.tar.gz" "${env:UET_DOTNET_MAC_DL}"
New-Item -ItemType Directory ".dotnet" | Out-Null
Invoke-WebRequest https://dot.net/v1/dotnet-install.sh -UseBasicParsing -OutFile ".dotnet/dotnet-install.sh"
chmod a+x .dotnet/dotnet-install.sh
./.dotnet/dotnet-install.sh --channel "$($env:UET_FRAMEWORK_TARGET.Substring(3))" --install-dir ".dotnet/dotnet"
if ($LastExitCode -ne 0) {
exit $LastExitCode
}
New-Item -ItemType Directory ".dotnet-${env:UET_FRAMEWORK_TARGET}/dotnet" | Out-Null
Push-Location ".dotnet-${env:UET_FRAMEWORK_TARGET}/dotnet"
try {
tar -xvf "../dotnet.tar.gz"
} finally {
Pop-Location
Set-Content -Path .dotnet/dotnet/dotnet-extracted -Value "done"
}
- name: Download .NET SDK (Linux)
if: ${{ runner.os == 'Linux' && steps.cache-sdk-linux.outputs.cache-hit != 'true' }}
shell: pwsh
env:
UET_FRAMEWORK_TARGET: ${{ inputs.UET_FRAMEWORK_TARGET }}
run: |
if (!(Test-Path .dotnet/dotnet/dotnet-extracted)) {
if (Test-Path ".dotnet") {
Remove-Item -Recurse -Force ".dotnet"
}
Set-Content -Path .dotnet-${env:UET_FRAMEWORK_TARGET}/dotnet/dotnet-extracted -Value "done"
Write-Host "Setting up .NET SDK..."
New-Item -ItemType Directory ".dotnet" | Out-Null
Invoke-WebRequest https://dot.net/v1/dotnet-install.sh -UseBasicParsing -OutFile ".dotnet/dotnet-install.sh"
chmod a+x .dotnet/dotnet-install.sh
./.dotnet/dotnet-install.sh --channel "$($env:UET_FRAMEWORK_TARGET.Substring(3))" --install-dir ".dotnet/dotnet"
if ($LastExitCode -ne 0) {
exit $LastExitCode
}
Set-Content -Path .dotnet/dotnet/dotnet-extracted -Value "done"
}
- name: Add .NET SDK to PATH (Windows)
if: ${{ runner.os == 'Windows' }}
shell: pwsh
env:
UET_FRAMEWORK_TARGET: ${{ inputs.UET_FRAMEWORK_TARGET }}
run: |
Add-Content -Path "${env:GITHUB_PATH}" -Value ".dotnet-${env:UET_FRAMEWORK_TARGET}\dotnet"
Add-Content -Path "${env:GITHUB_PATH}" -Value ".dotnet\dotnet"
- name: Add .NET SDK to PATH (macOS)
if: ${{ runner.os == 'macOS' }}
shell: pwsh
env:
UET_FRAMEWORK_TARGET: ${{ inputs.UET_FRAMEWORK_TARGET }}
run: |
Add-Content -Path "${env:GITHUB_PATH}" -Value ".dotnet-${env:UET_FRAMEWORK_TARGET}/dotnet"
Add-Content -Path "${env:GITHUB_PATH}" -Value ".dotnet/dotnet"
- name: Add .NET SDK to PATH (Linux)
if: ${{ runner.os == 'Linux' }}
shell: pwsh
run: |
Add-Content -Path "${env:GITHUB_PATH}" -Value ".dotnet/dotnet"
23 changes: 19 additions & 4 deletions .github/actions/upload-artifact/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,27 @@ runs:
path: |
**/*.nupkg
- name: Upload Test Results
if: ${{ inputs.UET_ARTIFACT_NAME == 'test-results' }}
- name: Upload Windows Test Results
if: ${{ inputs.UET_ARTIFACT_NAME == 'test-results-win' }}
uses: actions/upload-artifact@v4
with:
name: test-results
name: test-results-win
if-no-files-found: error
path: |
TestResults/*.test-result.trx
- name: Upload Linux Test Results
if: ${{ inputs.UET_ARTIFACT_NAME == 'test-results-linux' }}
uses: actions/upload-artifact@v4
with:
name: test-results-linux
if-no-files-found: error
path: |
TestResults/*.test-result.trx
- name: Upload Cloud Framework Test Results
if: ${{ inputs.UET_ARTIFACT_NAME == 'test-results-cf' }}
uses: actions/upload-artifact@v4
with:
name: test-results-cf
if-no-files-found: error
path: |
TestResults/*.test-result.trx
16 changes: 15 additions & 1 deletion .github/workflows/test-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,21 @@ jobs:
- name: Report Test Results
uses: dorny/test-reporter@v1
with:
artifact: test-results
artifact: test-results-win
name: Windows Test Results
path: '*.test-result.trx'
reporter: dotnet-trx
- name: Report Test Results
uses: dorny/test-reporter@v1
with:
artifact: test-results-linux
name: Linux Test Results
path: '*.test-result.trx'
reporter: dotnet-trx
- name: Report Test Results
uses: dorny/test-reporter@v1
with:
artifact: test-results-cf
name: Cloud Framework Test Results
path: '*.test-result.trx'
reporter: dotnet-trx
113 changes: 111 additions & 2 deletions .github/workflows/uet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ jobs:
exit $LastExitCode
}
foreach ($Item in (Get-ChildItem UET -Filter *.Tests)) {
if (Test-Path "$($Item.FullName)/$($Item.Name).csproj") {
if ((Test-Path "$($Item.FullName)/$($Item.Name).csproj") -and ($Item.Name -ne "Redpoint.CloudFramework.Tests")) {
Write-Host "============ STARTING: $($Item.Name) ============"
dotnet test --logger:"console" --logger:"trx;LogFileName=$($Item.Name).test-result.trx" --results-directory "$((Get-Location).Path)\TestResults" "$($Item.FullName)/bin/Release/${{ env.UET_FRAMEWORK_TARGET }}/$($Item.Name).dll"
if ($LastExitCode -ne 0) {
Expand All @@ -425,7 +425,7 @@ jobs:
- name: Upload Test Results
uses: ./.github/actions/upload-artifact
with:
UET_ARTIFACT_NAME: test-results
UET_ARTIFACT_NAME: test-results-win
UET_FRAMEWORK_TARGET: ${{ env.UET_FRAMEWORK_TARGET }}
- name: Upload Packages
uses: ./.github/actions/upload-artifact
Expand Down Expand Up @@ -457,6 +457,47 @@ jobs:
echo "Package version: $UET_PACKAGE_VERSION"
dotnet build -c Release /p:PackageVersion=$UET_PACKAGE_VERSION UET/UET.sln
libs-linux:
name: "Build and Test Libraries on Linux"
runs-on: ubuntu-latest
needs:
- timestamp
env:
UET_PACKAGE_VERSION: ${{ needs.timestamp.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install .NET SDK
uses: ./.github/actions/dotnet-sdk
with:
UET_FRAMEWORK_TARGET: ${{ env.UET_FRAMEWORK_TARGET }}
- name: Build and Test Libraries on Linux
shell: pwsh
run: |
dotnet build -c Release "/p:PackageVersion=${env:UET_PACKAGE_VERSION}" UET/UET.sln
if ($LastExitCode -ne 0) {
Write-Host "dotnet build (UET.sln) failed with exit code $LastExitCode"
exit $LastExitCode
}
foreach ($Item in (Get-ChildItem UET -Filter *.Tests)) {
if ((Test-Path "$($Item.FullName)/$($Item.Name).csproj") -and ($Item.Name -ne "Redpoint.CloudFramework.Tests")) {
Write-Host "============ STARTING: $($Item.Name) ============"
dotnet test --logger:"console" --logger:"trx;LogFileName=$($Item.Name).test-result.trx" --results-directory "$((Get-Location).Path)/TestResults" "$($Item.FullName)/bin/Release/${{ env.UET_FRAMEWORK_TARGET }}/$($Item.Name).dll"
if ($LastExitCode -ne 0) {
Write-Host "============ FAILED: $($Item.Name) ============"
exit $LastExitCode
}
Write-Host "============ PASSED: $($Item.Name) ============"
}
}
- name: Upload Test Results
uses: ./.github/actions/upload-artifact
with:
UET_ARTIFACT_NAME: test-results-linux
UET_FRAMEWORK_TARGET: ${{ env.UET_FRAMEWORK_TARGET }}

pass-2-win:
name: "Build Windows Pass 2"
runs-on: windows-latest
Expand Down Expand Up @@ -667,6 +708,7 @@ jobs:
- timestamp
- libs-win
- libs-mac
- libs-linux
- uefs-win
- uefs-mac
- shim-win
Expand All @@ -675,6 +717,7 @@ jobs:
- pass-2-win
- pass-2-mac
- pass-2-linux
- cf-linux-tests
env:
UET_PACKAGE_VERSION: ${{ needs.timestamp.outputs.version }}
steps:
Expand Down Expand Up @@ -715,6 +758,7 @@ jobs:
- timestamp
- libs-win
- libs-mac
- libs-linux
- uefs-win
- uefs-mac
- shim-win
Expand All @@ -723,6 +767,7 @@ jobs:
- pass-2-win
- pass-2-mac
- pass-2-linux
- cf-linux-tests
env:
UET_PACKAGE_VERSION: ${{ needs.timestamp.outputs.version }}
steps:
Expand Down Expand Up @@ -808,6 +853,7 @@ jobs:
- timestamp
- libs-win
- libs-mac
- libs-linux
- uefs-win
- uefs-mac
- shim-win
Expand All @@ -816,6 +862,7 @@ jobs:
- pass-2-win
- pass-2-mac
- pass-2-linux
- cf-linux-tests
env:
UET_PACKAGE_VERSION: ${{ needs.timestamp.outputs.version }}
steps:
Expand Down Expand Up @@ -853,6 +900,7 @@ jobs:
- timestamp
- libs-win
- libs-mac
- libs-linux
- uefs-win
- uefs-mac
- shim-win
Expand All @@ -861,6 +909,7 @@ jobs:
- pass-2-win
- pass-2-mac
- pass-2-linux
- cf-linux-tests
env:
UET_PACKAGE_VERSION: ${{ needs.timestamp.outputs.version }}
steps:
Expand Down Expand Up @@ -907,6 +956,7 @@ jobs:
- timestamp
- libs-win
- libs-mac
- libs-linux
- uefs-win
- uefs-mac
- shim-win
Expand All @@ -915,6 +965,7 @@ jobs:
- pass-2-win
- pass-2-mac
- pass-2-linux
- cf-linux-tests
env:
UET_PACKAGE_VERSION: ${{ needs.timestamp.outputs.version }}
steps:
Expand Down Expand Up @@ -948,3 +999,61 @@ jobs:
docker buildx create --name img-builder-linux --use --platform linux/amd64
docker buildx build --platform linux/amd64 --output=type=registry -f UET/Lib/Container/linux-wine.Dockerfile -t "ghcr.io/redpointgames/uet/uet:${env:UET_PACKAGE_VERSION}-wine" --build-arg UET_TARGET_FRAMEWORK=${{ env.UET_FRAMEWORK_TARGET }} .
docker buildx build --platform linux/amd64 --output=type=registry -f UET/Lib/Container/linux-wine.Dockerfile -t "ghcr.io/redpointgames/uet/uet:latest-wine" --build-arg UET_TARGET_FRAMEWORK=${{ env.UET_FRAMEWORK_TARGET }} .
cf-linux-tests:
name: "Test Cloud Framework"
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/dotnet/sdk:latest
services:
redis:
image: redis:6.0.10
ports:
- 6379:6379
pubsub:
image: ghcr.io/redpointgames/uet/pubsub-emulator:latest
ports:
- 9000:9000
datastore:
image: ghcr.io/redpointgames/uet/datastore-emulator:latest
ports:
- 9001:9001
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install .NET SDK
uses: ./.github/actions/dotnet-sdk
with:
UET_FRAMEWORK_TARGET: ${{ env.UET_FRAMEWORK_TARGET }}
- name: Build and Test Cloud Framework
shell: pwsh
env:
IS_RUNNING_UNDER_CI: "true"
REDIS_SERVER: "redis:6379"
PUBSUB_SERVER: "pubsub:9000"
DATASTORE_SERVER: "datastore:9001"
run: |
foreach ($Item in (Get-ChildItem UET -Filter Redpoint.CloudFramework.Tests)) {
if (Test-Path "$($Item.FullName)/$($Item.Name).csproj") {
dotnet build -c Release "$($Item.FullName)/$($Item.Name).csproj"
if ($LastExitCode -ne 0) {
Write-Host "dotnet build ($($Item.FullName)/$($Item.Name).csproj) failed with exit code $LastExitCode"
exit $LastExitCode
}
Write-Host "============ STARTING: $($Item.Name) ============"
dotnet test --logger:"console" --logger:"trx;LogFileName=$($Item.Name).test-result.trx" --results-directory "$((Get-Location).Path)/TestResults" "$($Item.FullName)/bin/Release/${{ env.UET_FRAMEWORK_TARGET }}/$($Item.Name).dll"
if ($LastExitCode -ne 0) {
Write-Host "============ FAILED: $($Item.Name) ============"
exit $LastExitCode
}
Write-Host "============ PASSED: $($Item.Name) ============"
}
}
- name: Upload Test Results
uses: ./.github/actions/upload-artifact
with:
UET_ARTIFACT_NAME: test-results-cf
UET_FRAMEWORK_TARGET: ${{ env.UET_FRAMEWORK_TARGET }}
Loading

0 comments on commit 996679c

Please sign in to comment.