|
6 | 6 | pull_request: |
7 | 7 | branches: |
8 | 8 | - main |
9 | | - paths: |
10 | | - - '**.cs' |
11 | | - - '.github/workflows/unity-tests.yml' |
12 | 9 |
|
13 | 10 | jobs: |
14 | | - runTests: |
15 | | - name: Run Runtime Tests |
| 11 | + checkChangedFiles: |
16 | 12 | runs-on: ubuntu-latest |
17 | | - env: |
18 | | - PROJECT_PATH: 'my-package' |
19 | | - UNITY_VERSION: '6000.2.8f1' |
20 | 13 |
|
21 | 14 | steps: |
22 | 15 | - name: Checkout code |
23 | 16 | uses: actions/checkout@v4 |
24 | 17 | with: |
25 | 18 | path: ${{ env.PROJECT_PATH }} |
26 | 19 |
|
| 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: |
27 | 47 | - name: Cache Unity Library |
28 | 48 | uses: actions/cache@v4 |
29 | 49 | 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 | + |
35 | 55 | - name: Run Unity tests |
36 | 56 | uses: game-ci/unity-test-runner@v4.3.1 |
37 | 57 | 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}} |
41 | 61 | 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 | + |
47 | 67 | - name: Upload test results |
48 | 68 | uses: actions/upload-artifact@v4 |
49 | 69 | if: always() # 'always()' ensures this runs even if tests fail |
50 | 70 | 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