Skip to content

Commit

Permalink
separate and improve workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Eyap53 committed Sep 23, 2024
1 parent 6881bbb commit ad638f9
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Actions 😎
name: Builds

on: [push, pull_request]
on:
workflow_run:
workflows: ["Tests"]
types:
- completed

jobs:
buildForAllSupportedPlatforms:
Expand All @@ -10,6 +14,8 @@ jobs:
strategy:
fail-fast: false
matrix:
projectPath:
- Unity_ExperimentLibrary
targetPlatform:
- StandaloneOSX # Build a macOS standalone (Intel 64-bit).
- StandaloneWindows # Build a Windows standalone.
Expand Down Expand Up @@ -40,38 +46,17 @@ jobs:
# Cache
- uses: actions/cache@v3
with:
path: Library
path: ${{ matrix.projectPath }}/Library
key:
Library-${{ matrix.targetPlatform }}-${{ hashFiles('Assets/**', 'Packages/**',
'ProjectSettings/**') }}
restore-keys: |
Library-${{ matrix.targetPlatform }}-
Library-
# Test
- name: Run tests
id: myTestStep
uses: game-ci/unity-test-runner@v4
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
projectPath: Unity_ExperimentLibrary
githubToken: ${{ secrets.GITHUB_TOKEN }}

- name: Upload test results
uses: actions/upload-artifact@v3
if: always()
with:
name: Test results ${{ matrix.targetPlatform }}
path: ${{ steps.myTestStep.outputs.artifactsPath }}

- uses: actions/upload-artifact@v3
if: always()
with:
name: Coverage results
path: ${{ steps.myTestStep.outputs.coveragePath }}
# Android specific : Free disk space
- if: matrix.targetPlatform == 'Android'
uses: jlumbroso/[email protected]

# Build
- name: Build project
Expand All @@ -82,8 +67,7 @@ jobs:
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
targetPlatform: ${{ matrix.targetPlatform }}
versioning: Semantic
projectPath: Unity_ExperimentLibrary
projectPath: ${{ matrix.projectPath }}

# Output
- uses: actions/upload-artifact@v3
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Tests

on: [push, pull_request]

jobs:
test:
name: Test in ${{ matrix.testMode }}
runs-on: ubuntu-latest
permissions: write-all
strategy:
fail-fast: false
matrix:
projectPath:
- Unity_ExperimentLibrary
testMode:
- playmode
- editmode
- standalone
steps:
# Checkout (without LFS)
- name: Checkout repository
uses: actions/checkout@v4

# Git LFS
- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id

- name: Restore LFS cache
uses: actions/cache@v3
id: lfs-cache
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}

- name: Git LFS Pull
run: |
git lfs pull
git add .
git reset --hard
# Cache
- uses: actions/cache@v3
with:
path: ${{ matrix.projectPath }}/Library
key:
Library-${{ matrix.projectPath }}-${{ hashFiles('Assets/**', 'Packages/**',
'ProjectSettings/**') }}
restore-keys: |
Library-
# Test
- name: Run tests
id: tests
uses: game-ci/unity-test-runner@v4
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
projectPath: ${{ matrix.projectPath }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
testMode: ${{ matrix.testMode }}
artifactsPath: ${{ matrix.testMode }}-artifacts
checkName: ${{ matrix.testMode }} Test Results
coverageOptions: "generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;assemblyFilters:+my.assembly.*"

- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
with:
name: Test results for ${{ matrix.testMode }}
path: ${{ steps.tests.outputs.artifactsPath }}

- uses: actions/upload-artifact@v3
if: always()
with:
name: Coverage results for ${{ matrix.testMode }}
path: ${{ steps.tests.outputs.coveragePath }}

0 comments on commit ad638f9

Please sign in to comment.