Skip to content

Commit

Permalink
Cross-Platform SigMint Improvements + Pk Override Fixes, PlayMode Tes…
Browse files Browse the repository at this point in the history
…ts, Better Return Types, Storage Fix (#161)

with game-ci test integration and pr-codex
  • Loading branch information
0xFirekeeper authored Mar 22, 2024
1 parent 856efc6 commit 2aa7906
Show file tree
Hide file tree
Showing 53 changed files with 2,846 additions and 177 deletions.
219 changes: 219 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
name: Unity Cross-Platform Test Workflow

on:
push:
branches: ["main"]
pull_request:
types: [opened, synchronize]

jobs:
buildAndTestForLinuxBasedPlatforms:
name: Test for ${{ matrix.targetPlatform }}
runs-on: ubuntu-latest-32
concurrency:
group: Unity-Test-${{ matrix.targetPlatform }}-${{ github.ref }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
projectPath:
- "."
unityVersion:
- 2022.3.17f1
targetPlatform:
- StandaloneLinux64 # Build a Linux 64-bit standalone.
- iOS # Build an iOS player.
- Android # Build an Android player.
- WebGL # WebGL.
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: false

- uses: actions/cache@v3
with:
path: ${{ matrix.projectPath }}/Library
key:
Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}-${{
hashFiles(matrix.projectPath) }}
restore-keys: |
Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}-
Library-${{ matrix.projectPath }}-
Library-
- name: Setup Config
env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
run: |
mkdir -p Assets/Tests/Resources
echo '{"clientId": "${{ secrets.CLIENT_ID }}"}' > Assets/Tests/Resources/config.json
shell: bash

- name: Run Tests
uses: game-ci/unity-test-runner@v4
id: testRunner
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
artifactsPath: Artifacts/${{ matrix.targetPlatform }}
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
testMode: PlayMode # Run PlayMode tests.

- name: Upload Test Results
uses: actions/upload-artifact@v3
if: always()
with:
name: TestResults-${{ matrix.targetPlatform }}-${{ github.run_number }}
path: ${{ steps.testRunner.outputs.artifactsPath }}

- name: Download Test Results
uses: actions/download-artifact@v3
if: always()
with:
name: TestResults-${{ matrix.targetPlatform }}-${{ github.run_number }}
path: ${{ matrix.projectPath }}/TestResults-${{ matrix.targetPlatform }}

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: ${{ matrix.projectPath }}/TestResults-${{ matrix.targetPlatform }}/**/*.xml
check_name: "Test Results for ${{ matrix.targetPlatform }}"
comment_title: "Test Results for ${{ matrix.targetPlatform }}"

# - uses: jlumbroso/[email protected]

# - uses: game-ci/unity-builder@v4
# env:
# UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
# UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
# UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
# with:
# projectPath: ${{ matrix.projectPath }}
# unityVersion: ${{ matrix.unityVersion }}
# targetPlatform: ${{ matrix.targetPlatform }}
# allowDirtyBuild: true

# - uses: actions/upload-artifact@v3
# with:
# name: Build-${{ matrix.targetPlatform }}-${{ github.run_number }}
# path: build

# deploy-webgl-to-gh-pages:
# needs: buildAndTestForLinuxBasedPlatforms
# runs-on: ubuntu-latest
# if: github.ref == 'refs/heads/main'
# steps:
# - name: Checkout
# uses: actions/checkout@v4

# - name: Download WebGL Build Artifact
# uses: actions/download-artifact@v3
# with:
# name: Build-WebGL-${{ github.run_number }}
# path: webgl-build

# - name: Deploy to GitHub Pages
# uses: JamesIves/[email protected]
# with:
# branch: main
# folder: webgl-build
# target-folder: docs
# clean: true
# commit-message: "Deploy WebGL build to GitHub Pages"
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# buildForWindowsBasedPlatforms:
# name: Build for ${{ matrix.targetPlatform }}
# runs-on: windows-2022
# strategy:
# fail-fast: false
# matrix:
# projectPath:
# - ""
# unityVersion:
# - 2022.3.17f1
# targetPlatform:
# - StandaloneWindows64 # Build a Windows 64-bit standalone.

# steps:
# - uses: actions/checkout@v4
# with:
# # fetch-depth: 0
# lfs: false
# - uses: actions/cache@v3
# with:
# path: ${{ matrix.projectPath }}/Library
# key:
# Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}-${{
# hashFiles(matrix.projectPath) }}
# restore-keys: |
# Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}-
# Library-${{ matrix.projectPath }}-
# Library-
# - uses: game-ci/unity-builder@v4
# env:
# UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
# UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
# UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
# with:
# projectPath: ${{ matrix.projectPath }}
# unityVersion: ${{ matrix.unityVersion }}
# targetPlatform: ${{ matrix.targetPlatform }}
# allowDirtyBuild: true
# - uses: actions/upload-artifact@v3
# with:
# name: Build-${{ matrix.targetPlatform }}-${{ github.run_number }}
# path: build

# buildForMacOSBasedPlatforms:
# name: Build for ${{ matrix.targetPlatform }}
# runs-on: macos-latest
# strategy:
# fail-fast: false
# matrix:
# projectPath:
# - ""
# unityVersion:
# - 2022.3.17f1
# targetPlatform:
# - StandaloneOSX # Build a macOS standalone.

# steps:
# - uses: actions/checkout@v4
# with:
# # fetch-depth: 0
# lfs: false

# - uses: actions/cache@v3
# with:
# path: ${{ matrix.projectPath }}/Library
# key:
# Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}-${{
# hashFiles(matrix.projectPath) }}
# restore-keys: |
# Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}-
# Library-${{ matrix.projectPath }}-
# Library-

# - uses: game-ci/unity-builder@v4
# env:
# UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
# UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
# UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
# with:
# projectPath: ${{ matrix.projectPath }}
# unityVersion: ${{ matrix.unityVersion }}
# targetPlatform: ${{ matrix.targetPlatform }}
# allowDirtyBuild: true

# - uses: actions/upload-artifact@v3
# with:
# name: Build-${{ matrix.targetPlatform }}-${{ github.run_number }}
# path: build
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,12 @@ releases/
Documentation/

!docs/**
Assets/Tests/config.json
Assets/Tests/config.json.meta
Assets/Tests/Resources.meta
Assets/Tests/Resources/config.json
Assets/Tests/Resources/config.json.meta

# Ignore temporaries from GameCI
/[Aa]rtifacts/
/[Cc]odeCoverage/
8 changes: 8 additions & 0 deletions Assets/Tests.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions Assets/Tests/ConfigManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.IO;
using UnityEngine;

public class ConfigManager
{
[System.Serializable]
private class ConfigData
{
public string clientId;
}

private ConfigData _config;

internal string GetClientId()
{
if (_config != null)
return _config.clientId;

try
{
string jsonContents = Resources.Load<TextAsset>("config").text;
_config = JsonUtility.FromJson<ConfigData>(jsonContents);
return _config?.clientId;
}
catch (System.Exception e)
{
throw new System.Exception("Failed to load config file from Resources: " + e.Message);
}
}
}
11 changes: 11 additions & 0 deletions Assets/Tests/ConfigManager.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 91 additions & 0 deletions Assets/Tests/CustomReadTests.cs

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions Assets/Tests/CustomReadTests.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2aa7906

Please sign in to comment.