-
-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (97 loc) · 4.34 KB
/
test_unity_plugin.yml
File metadata and controls
108 lines (97 loc) · 4.34 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
name: test-unity-plugin
##############################################################################
# 1. Triggers
##############################################################################
on:
workflow_dispatch:
workflow_call:
inputs:
projectPath: { required: true, type: string }
unityVersion: { required: true, type: string }
testMode: { required: true, type: string }
secrets:
UNITY_LICENSE: { required: true }
UNITY_EMAIL: { required: true }
UNITY_PASSWORD: { required: true }
##############################################################################
# 2. Job – runs only after a maintainer applies the `ci-ok` label
##############################################################################
jobs:
test:
if: |
github.event_name != 'pull_request_target' ||
contains(github.event.pull_request.labels.*.name,'ci-ok')
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
platform: [base, windows-mono]
name: ${{ inputs.unityVersion }} ${{ inputs.testMode }} on ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
# permissions: # minimize the default token
# contents: write
# pull-requests: write
steps:
# --------------------------------------------------------------------- #
# 2-a. (PR only) abort if the contributor also changed workflow files
# --------------------------------------------------------------------- #
- name: Abort if workflow files modified
if: ${{ github.event_name == 'pull_request_target' }}
run: |
git fetch --depth=1 origin "${{ github.base_ref }}"
if git diff --name-only HEAD origin/${{ github.base_ref }} | grep -q '^\.github/workflows/'; then
echo "::error::This PR edits workflow files – refusing to run with secrets"; exit 1;
fi
# --------------------------------------------------------------------- #
# 2-b. Checkout the contributor’s commit safely
# --------------------------------------------------------------------- #
- uses: actions/checkout@v6
with:
lfs: false
# --------------------------------------------------------------------- #
# 2-c. Free disk space
# --------------------------------------------------------------------- #
- name: Free disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
swap-storage: true
# --------------------------------------------------------------------- #
# 2-d. Cache & run the Unity test-runner
# --------------------------------------------------------------------- #
- uses: actions/cache@v4
with:
path: |
${{ inputs.projectPath }}/Library
~/.cache/unity3d
key: ${{ inputs.unityVersion }} ${{ inputs.testMode }} on ${{ 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
- uses: game-ci/unity-test-runner@v4
id: tests
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
projectPath: ${{ inputs.projectPath }}
unityVersion: ${{ inputs.unityVersion }}
testMode: ${{ inputs.testMode }}
customImage: ${{ steps.custom_image.outputs.image }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
checkName: ${{ inputs.unityVersion }} ${{ inputs.testMode }} ${{ matrix.platform }} Test Results
artifactsPath: artifacts-${{ inputs.unityVersion }}-${{ inputs.testMode }}-${{ matrix.platform }}
customParameters: -CI true -GITHUB_ACTIONS true
# --------------------------------------------------------------------- #
- uses: actions/upload-artifact@v4
if: always()
with:
name: Test results for ${{ inputs.unityVersion }} ${{ inputs.testMode }} on ${{ matrix.platform }}
path: ${{ steps.tests.outputs.artifactsPath }}