Build the game! #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build & test the Unity project | |
run-name: Build the game! | |
on: | |
push: | |
branches: ["main"] | |
paths-ignore: | |
- '.github/**' | |
- 'README.md' | |
- '.gitattributes' | |
- '.gitignore' | |
- '.vscode/**' | |
- 'packages.json' | |
pull_request: | |
branches: ["main"] | |
paths-ignore: | |
- '.github/**' | |
- 'README.md' | |
- '.gitattributes' | |
- '.gitignore' | |
- '.vscode/**' | |
- 'packages.json' | |
workflow_dispatch: | |
permissions: | |
actions: write | |
contents: write | |
jobs: | |
test: | |
name: Test in ${{ matrix.testMode }} for ${{ matrix.os }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
projectPath: | |
- 'dist' | |
testMode: | |
- playmode | |
- editmode | |
- standalone | |
os: | |
- StandaloneWindows | |
- StandaloneWindows64 | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
lfs: true | |
- name: Cache Library Folder | |
uses: actions/cache@v3 | |
with: | |
path: ${{ matrix.projectPath }}/Library | |
key: Library-${{ matrix.projectPath }} | |
restore-keys: | | |
Library- | |
- name: Debug Project Directory | |
run: | | |
echo "Current directory: $(pwd)" | |
echo "Contents of project path:" | |
ls ${{ matrix.projectPath }} | |
- name: Run Unity Tests | |
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: ${{ matrix.projectPath }} | |
testMode: ${{ matrix.testMode }} | |
artifactsPath: ${{ matrix.testMode }}-artifacts | |
githubToken: ${{ secrets.GITHUB_TOKEN }} | |
checkName: ${{ matrix.testMode }} Test Results | |
coverageOptions: 'generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;assemblyFilters:+my.assembly.*' | |
- name: Debug Artifacts Directory | |
if: always() | |
run: | | |
echo "${{ matrix.os }} Artifacts Path: ${{ matrix.testMode }}-artifacts" | |
ls ${{ matrix.testMode }}-artifacts || echo "No artifacts found" | |
- name: Upload Test Results | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: Test results for ${{ matrix.testMode }} in ${{ matrix.os }} | |
path: ${{ matrix.testMode }}-artifacts | |
- name: Upload Coverage Results | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: Coverage results for ${{ matrix.testMode }} in ${{ matrix.os }} | |
path: ${{ steps.tests.outputs.coveragePath }} | |
- name: Debug Step Outputs | |
if: always() | |
run: | | |
echo "${{ matrix.os }} Artifacts Path: ${{ matrix.testMode }}-artifacts" | |
echo "Coverage Path: ${{ steps.tests.outputs.coveragePath }}" | |
build: | |
name: Build Unity project | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
lfs: true | |
- name: Cache Library Folder | |
uses: actions/cache@v3 | |
with: | |
path: ./dist/Library | |
key: Library-MyProjectName-TargetPlatform | |
restore-keys: | | |
Library-MyProjectName- | |
Library- | |
- name: Build Unity project | |
uses: game-ci/unity-builder@v4 | |
env: | |
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
with: | |
projectPath: dist | |
targetPlatform: ${{ matrix.os }} | |
- name: Debug Build Directory | |
run: | | |
echo "Build Path: ${{ matrix.projectPath }}" | |
ls ${{ matrix.projectPath }} || echo "No build artifacts found" | |
- name: Upload Build Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-${{ matrix.os }} | |
path: dist/Builds |