Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/unity-config.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Unity CI Configuration
# =====================
# Centralized configuration for all Unity-related GitHub Actions workflows.
# Update these values here to change them across all workflows.

UNITY_VERSION=2022.3.55f1
UNITY_PROJECT_PATH=UnityProject
UNITY_TARGET_PLATFORM=StandaloneLinux64
43 changes: 38 additions & 5 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches: [master]
paths:
# Only run when JEngine code changes
- 'UnityProject/Packages/com.jasonxudeveloper.jengine.core/**'
- 'UnityProject/Packages/com.jasonxudeveloper.jengine.util/**'
- 'UnityProject/Assets/HotUpdate/Code/**'
Expand All @@ -19,7 +18,6 @@ on:
- '.github/codeql/**'
- '.github/workflows/codeql.yml'
schedule:
# Run weekly on Sunday at 00:00 UTC
- cron: '0 0 * * 0'
workflow_dispatch:

Expand All @@ -35,16 +33,51 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: true

# Load centralized Unity configuration
- name: Load Unity config
id: unity-config
run: |
source .github/unity-config.env
echo "version=$UNITY_VERSION" >> $GITHUB_OUTPUT
echo "project_path=$UNITY_PROJECT_PATH" >> $GITHUB_OUTPUT
echo "target_platform=$UNITY_TARGET_PLATFORM" >> $GITHUB_OUTPUT

- name: Cache Unity Library
uses: actions/cache@v4
with:
path: ${{ steps.unity-config.outputs.project_path }}/Library
key: Library-CodeQL-${{ steps.unity-config.outputs.version }}-${{ hashFiles(format('{0}/Packages/packages-lock.json', steps.unity-config.outputs.project_path)) }}
restore-keys: |
Library-CodeQL-${{ steps.unity-config.outputs.version }}-
Library-CodeQL-

- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: csharp
config-file: ./.github/codeql/codeql-config.yml
# Use security-and-quality queries for comprehensive analysis
queries: security-and-quality
# Use buildless mode for Unity projects (no standard .NET build)
build-mode: none
build-mode: manual

- name: Compile Unity Scripts
uses: game-ci/unity-builder@v4
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
projectPath: ${{ steps.unity-config.outputs.project_path }}
unityVersion: ${{ steps.unity-config.outputs.version }}
targetPlatform: ${{ steps.unity-config.outputs.target_platform }}
buildName: CodeQL
customParameters: -nographics -quit

- name: Return Unity license
uses: game-ci/unity-return-license@v2
if: always()

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
Expand Down
56 changes: 33 additions & 23 deletions .github/workflows/unity-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ on:
workflow_call:
inputs:
unity_version:
description: 'Unity version to use for testing'
description: 'Unity version (leave empty to use .github/unity-config.env)'
required: false
type: string
default: '2022.3.55f1'
default: ''
test_mode:
description: 'Test mode to run (All, EditMode, PlayMode)'
required: false
type: string
default: 'All'
project_path:
description: 'Path to Unity project directory'
description: 'Path to Unity project (leave empty to use .github/unity-config.env)'
required: false
type: string
default: 'UnityProject'
default: ''
outputs:
test_results:
description: 'Test results summary'
Expand All @@ -38,23 +38,37 @@ jobs:
results: ${{ steps.test-summary.outputs.summary }}

steps:
# Checkout repository
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: true

# Cache Unity Library folder for faster builds
# Load centralized Unity configuration
- name: Load Unity config
id: config
run: |
source .github/unity-config.env
# Use input if provided, otherwise use config file value
if [ -n "${{ inputs.unity_version }}" ]; then
echo "version=${{ inputs.unity_version }}" >> $GITHUB_OUTPUT
else
echo "version=$UNITY_VERSION" >> $GITHUB_OUTPUT
fi
if [ -n "${{ inputs.project_path }}" ]; then
echo "project_path=${{ inputs.project_path }}" >> $GITHUB_OUTPUT
else
echo "project_path=$UNITY_PROJECT_PATH" >> $GITHUB_OUTPUT
fi

- name: Cache Unity Library
uses: actions/cache@v4
with:
path: ${{ inputs.project_path }}/Library
key: Library-${{ inputs.project_path }}-${{ inputs.unity_version }}-${{ hashFiles(format('{0}/Packages/packages-lock.json', inputs.project_path)) }}
path: ${{ steps.config.outputs.project_path }}/Library
key: Library-${{ steps.config.outputs.project_path }}-${{ steps.config.outputs.version }}-${{ hashFiles(format('{0}/Packages/packages-lock.json', steps.config.outputs.project_path)) }}
restore-keys: |
Library-${{ inputs.project_path }}-${{ inputs.unity_version }}-
Library-${{ inputs.project_path }}-
Library-${{ steps.config.outputs.project_path }}-${{ steps.config.outputs.version }}-
Library-${{ steps.config.outputs.project_path }}-

# Run EditMode tests
- name: Run EditMode tests
if: inputs.test_mode == 'All' || inputs.test_mode == 'EditMode'
uses: game-ci/unity-test-runner@v4
Expand All @@ -64,14 +78,13 @@ jobs:
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
projectPath: ${{ inputs.project_path }}
unityVersion: ${{ inputs.unity_version }}
projectPath: ${{ steps.config.outputs.project_path }}
unityVersion: ${{ steps.config.outputs.version }}
testMode: EditMode
artifactsPath: artifacts/EditMode
githubToken: ${{ secrets.GITHUB_TOKEN }}
checkName: EditMode Test Results

# Run PlayMode tests
- name: Run PlayMode tests
if: inputs.test_mode == 'All' || inputs.test_mode == 'PlayMode'
uses: game-ci/unity-test-runner@v4
Expand All @@ -81,19 +94,18 @@ jobs:
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
projectPath: ${{ inputs.project_path }}
unityVersion: ${{ inputs.unity_version }}
projectPath: ${{ steps.config.outputs.project_path }}
unityVersion: ${{ steps.config.outputs.version }}
testMode: PlayMode
artifactsPath: artifacts/PlayMode
githubToken: ${{ secrets.GITHUB_TOKEN }}
checkName: PlayMode Test Results

# Upload test results as artifacts
- name: Upload EditMode test results
if: always() && (inputs.test_mode == 'All' || inputs.test_mode == 'EditMode')
uses: actions/upload-artifact@v4
with:
name: EditMode-results-${{ inputs.unity_version }}
name: EditMode-results-${{ steps.config.outputs.version }}
path: artifacts/EditMode
if-no-files-found: warn
retention-days: 14
Expand All @@ -102,12 +114,11 @@ jobs:
if: always() && (inputs.test_mode == 'All' || inputs.test_mode == 'PlayMode')
uses: actions/upload-artifact@v4
with:
name: PlayMode-results-${{ inputs.unity_version }}
name: PlayMode-results-${{ steps.config.outputs.version }}
path: artifacts/PlayMode
if-no-files-found: warn
retention-days: 14

# Generate test summary
- name: Generate test summary
id: test-summary
if: always()
Expand All @@ -132,14 +143,13 @@ jobs:
fi
fi

SUMMARY="${SUMMARY}\n**Unity Version**: ${{ inputs.unity_version }}\n"
SUMMARY="${SUMMARY}**Project Path**: ${{ inputs.project_path }}"
SUMMARY="${SUMMARY}\n**Unity Version**: ${{ steps.config.outputs.version }}\n"
SUMMARY="${SUMMARY}**Project Path**: ${{ steps.config.outputs.project_path }}"

echo "summary<<EOF" >> $GITHUB_OUTPUT
echo -e "$SUMMARY" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

# Return Unity license
- name: Return Unity license
uses: game-ci/unity-return-license@v2
if: always()
Loading