Skip to content

Commit cf8582c

Browse files
chore: Merge pull request #8 from Mateo-Jimenez76/Mateo-Jimenez76-patch-2
chore: Refactor Unity test workflow to check changed files
2 parents dbe8176 + 5301705 commit cf8582c

1 file changed

Lines changed: 43 additions & 23 deletions

File tree

.github/workflows/unity-tests.yml

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,67 @@ on:
66
pull_request:
77
branches:
88
- main
9-
paths:
10-
- '**.cs'
11-
- '.github/workflows/unity-tests.yml'
129

1310
jobs:
14-
runTests:
15-
name: Run Runtime Tests
11+
checkChangedFiles:
1612
runs-on: ubuntu-latest
17-
env:
18-
PROJECT_PATH: 'my-package'
19-
UNITY_VERSION: '6000.2.8f1'
2013

2114
steps:
2215
- name: Checkout code
2316
uses: actions/checkout@v4
2417
with:
2518
path: ${{ env.PROJECT_PATH }}
2619

20+
- name: Get all changed csharp files
21+
id: changed-csharp-files
22+
uses: tj-actions/changed-files@24d32ffd492484c1d75e0c0b894501ddb9d30d62
23+
with:
24+
files: |
25+
**.cs
26+
.github/workflows/unity-tests.yml
27+
28+
- name: List all changed files
29+
if: steps.changed-csharp-files.outputs.any_changed == 'true'
30+
env:
31+
ALL_CHANGED_FILES: ${{ steps.changed-markdown-files.outputs.all_changed_files }}
32+
run: |
33+
for file in ${ALL_CHANGED_FILES}; do
34+
echo "$file was changed"
35+
done
36+
37+
runTests:
38+
name: Run Runtime Tests
39+
runs-on: ubuntu-latest
40+
needs: [checkChangedFiles]
41+
if: steps.changed-csharp-files.outputs.any_changed == 'true'
42+
env:
43+
PROJECT_PATH: 'my-package'
44+
UNITY_VERSION: '6000.2.8f1'
45+
46+
steps:
2747
- name: Cache Unity Library
2848
uses: actions/cache@v4
2949
with:
30-
path: TempProject/Library
31-
key: lib-${{ runner.os }}-${{ env.UNITY_VERSION }}-${{ hashFiles(format('{0}/**', env.PROJECT_PATH)) }}
32-
restore-keys: |
33-
lib-${{ runner.os }}-${{ env.UNITY_VERSION }}-
34-
50+
path: TempProject/Library
51+
key: lib-${{ runner.os }}-${{ env.UNITY_VERSION }}-${{ hashFiles(format('{0}/**', env.PROJECT_PATH)) }}
52+
restore-keys: |
53+
lib-${{ runner.os }}-${{ env.UNITY_VERSION }}-
54+
3555
- name: Run Unity tests
3656
uses: game-ci/unity-test-runner@v4.3.1
3757
env:
38-
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
39-
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
40-
UNITY_LICENSE: ${{secrets.UNITY_LICENSE}}
58+
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
59+
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
60+
UNITY_LICENSE: ${{secrets.UNITY_LICENSE}}
4161
with:
42-
packageMode: true
43-
unityVersion: ${{ env.UNITY_VERSION }}
44-
projectPath: ${{ env.PROJECT_PATH }}
45-
coverageOptions: generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;dontClear;assembliesToInclude=HealthSystem.Runtime,HealthSystem.Editor
46-
62+
packageMode: true
63+
unityVersion: ${{ env.UNITY_VERSION }}
64+
projectPath: ${{ env.PROJECT_PATH }}
65+
coverageOptions: generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;dontClear;assembliesToInclude=HealthSystem.Runtime,HealthSystem.Editor
66+
4767
- name: Upload test results
4868
uses: actions/upload-artifact@v4
4969
if: always() # 'always()' ensures this runs even if tests fail
5070
with:
51-
name: test-playmode-results
52-
path: artifacts # game-ci/unity-tester outputs results to 'artifacts'
71+
name: test-playmode-results
72+
path: artifacts # game-ci/unity-tester outputs results to 'artifacts'

0 commit comments

Comments
 (0)