forked from IvanMurzak/Unity-MCP
-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (98 loc) · 4.82 KB
/
test_unity_plugin.yml
File metadata and controls
111 lines (98 loc) · 4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# ┌──────────────────────────────────────────────────────────────────┐
# │ Author: Ivan Murzak (https://github.com/IvanMurzak) │
# │ Repository: GitHub (https://github.com/IvanMurzak/Unity-MCP) │
# │ Copyright (c) 2025 Ivan Murzak │
# │ Licensed under the Apache License, Version 2.0. │
# │ See the LICENSE file in the project root for more information. │
# └──────────────────────────────────────────────────────────────────┘
name: test-unity-plugin
##############################################################################
# 1. Triggers
##############################################################################
on:
workflow_call:
inputs:
projectPath: { required: true, type: string }
unityVersion: { required: true, type: string }
testMode: { required: true, type: string }
secrets:
UNITY_EMAIL: { required: false }
UNITY_PASSWORD: { required: false }
##############################################################################
# 2. Job
##############################################################################
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
platform: [base, windows-mono]
name: ${{ inputs.unityVersion }} ${{ inputs.testMode }} on ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
steps:
# --------------------------------------------------------------------- #
# 2-a. Checkout repository
# --------------------------------------------------------------------- #
- uses: actions/checkout@v6
with:
lfs: false
# --------------------------------------------------------------------- #
# 2-b. Activate Unity license
# --------------------------------------------------------------------- #
- name: Activate Unity license
id: activate
uses: ./.github/actions/unity/activate-license
with:
unityVersion: ${{ inputs.unityVersion }}
unity-email: ${{ secrets.UNITY_EMAIL || 'UnityEngineTester@gmail.com' }}
unity-password: ${{ secrets.UNITY_PASSWORD || 'ZUq3YR6qM1' }}
# --------------------------------------------------------------------- #
# 2-c. Cache & run the Unity test-runner
# --------------------------------------------------------------------- #
- name: Generate cache key
id: cache_key
run: |
# Sanitize projectPath: replace /, \, :, and spaces with underscores
sanitized_path=$(echo "${{ inputs.projectPath }}" | sed 's/[\/\\: ]/_/g')
echo "project_path_sanitized=$sanitized_path" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/cache@v5
with:
path: |
${{ inputs.projectPath }}/Library
~/.cache/unity3d
key: ${{ steps.cache_key.outputs.project_path_sanitized }}-${{ inputs.testMode }}-${{ matrix.platform }}
# --------------------------------------------------------------------- #
- name: Generate custom image name
id: custom_image
run: echo "image=unityci/editor:ubuntu-${{ inputs.unityVersion }}-${{ matrix.platform }}-3" >> $GITHUB_OUTPUT
shell: bash
- name: Decode Unity license
run: |
echo "$LICENSE_B64" | base64 -d > /tmp/unity_license.ulf
DELIM="UNITY_LIC_EOF_$(openssl rand -hex 16)"
echo "UNITY_LICENSE<<$DELIM" >> "$GITHUB_ENV"
cat /tmp/unity_license.ulf >> "$GITHUB_ENV"
printf '\n%s\n' "$DELIM" >> "$GITHUB_ENV"
env:
LICENSE_B64: ${{ steps.activate.outputs.license }}
shell: bash
- uses: game-ci/unity-test-runner@v4
id: tests
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL || 'UnityEngineTester@gmail.com' }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD || 'ZUq3YR6qM1' }}
with:
projectPath: ${{ inputs.projectPath }}
unityVersion: ${{ inputs.unityVersion }}
testMode: ${{ inputs.testMode }}
customImage: ${{ steps.custom_image.outputs.image }}
artifactsPath: artifacts-${{ inputs.unityVersion }}-${{ inputs.testMode }}-${{ matrix.platform }}
customParameters: -CI true -GITHUB_ACTIONS true
# --------------------------------------------------------------------- #
- uses: actions/upload-artifact@v6
if: always()
with:
name: Test results for ${{ inputs.unityVersion }} ${{ inputs.testMode }} on ${{ matrix.platform }}
path: ${{ steps.tests.outputs.artifactsPath }}