Skip to content

task: harden CI testing #23

task: harden CI testing

task: harden CI testing #23

name: build-and-test
on:
push:
branches-ignore:
- 'dependabot/**'
- 'gh-pages'
tags-ignore:
- 'v*'
pull_request:
branches:
- 'main'
- 'develop'
permissions:
contents: read
checks: write
concurrency:
group: unity-build-and-test-${{ github.ref }}
cancel-in-progress: true
jobs:
unity-editmode:
name: Unity EditMode (${{ matrix.package_display_name }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- package_display_name: FixedMathSharp
package_name: com.mrdav30.fixedmathsharp
package_path: com.mrdav30.fixedmathsharp
runtime_assembly: FixedMathSharp.Runtime
artifact_suffix: standard
- package_display_name: FixedMathSharp Lean
package_name: com.mrdav30.fixedmathsharp.lean
package_path: com.mrdav30.fixedmathsharp.lean
runtime_assembly: FixedMathSharp.Lean.Runtime
artifact_suffix: lean
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: Prepare Unity test project
shell: bash
run: |
set -euo pipefail
bash .assets/ci/scripts/prepare-unity-editmode-test-project.sh \
--project-path ".ci/unity-project" \
--package-name "${{ matrix.package_name }}" \
--package-path "${{ matrix.package_path }}" \
--runtime-assembly "${{ matrix.runtime_assembly }}"
- name: Cache Unity Library
uses: actions/cache@v5
with:
path: .ci/unity-project/Library
key: unity-library-${{ runner.os }}-${{ matrix.artifact_suffix }}-${{ hashFiles('.assets/ci/scripts/prepare-unity-editmode-test-project.sh', '.assets/ci/unity-editmode-tests/**', 'Tests/EditMode/**/*.cs', 'Tests/Runtime/**/*.cs', 'com.mrdav30.fixedmathsharp/**/*.cs', 'com.mrdav30.fixedmathsharp/**/*.asmdef', 'com.mrdav30.fixedmathsharp/package.json', 'com.mrdav30.fixedmathsharp.lean/**/*.cs', 'com.mrdav30.fixedmathsharp.lean/**/*.asmdef', 'com.mrdav30.fixedmathsharp.lean/package.json') }}
restore-keys: |
unity-library-${{ runner.os }}-${{ matrix.artifact_suffix }}-
- name: Run Unity EditMode 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: .ci/unity-project
unityVersion: 6000.3.9f1
testMode: EditMode
customParameters: -assemblyNames FixedMathSharp.Unity.Tests.EditMode -runSynchronously
artifactsPath: artifacts/${{ matrix.artifact_suffix }}
githubToken: ${{ github.token }}
checkName: Unity EditMode ${{ matrix.package_display_name }}
- name: Upload Unity test artifacts
if: failure()
uses: actions/upload-artifact@v7
with:
name: unity-editmode-${{ matrix.artifact_suffix }}
path: artifacts/${{ matrix.artifact_suffix }}
unity-sample-import-smoke:
name: Unity Sample Import Smoke (${{ matrix.package_display_name }})
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- package_display_name: FixedMathSharp
package_name: com.mrdav30.fixedmathsharp
package_path: com.mrdav30.fixedmathsharp
expected_sample_asmdef: FixedMathSharp.Samples.asmdef
artifact_suffix: standard
- package_display_name: FixedMathSharp Lean
package_name: com.mrdav30.fixedmathsharp.lean
package_path: com.mrdav30.fixedmathsharp.lean
expected_sample_asmdef: FixedMathSharp.Lean.Samples.asmdef
artifact_suffix: lean
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: Prepare Unity sample import smoke project
shell: bash
run: |
set -euo pipefail
bash .assets/ci/scripts/prepare-unity-sample-import-smoke.sh \
--project-path ".ci/unity-sample-import-${{ matrix.artifact_suffix }}" \
--package-name "${{ matrix.package_name }}" \
--package-path "${{ matrix.package_path }}" \
--expected-sample-asmdef "${{ matrix.expected_sample_asmdef }}" \
--workspace-path "/github/workspace" \
--git-sha "$GITHUB_SHA"
- name: Cache Unity sample import Library
uses: actions/cache@v5
with:
path: .ci/unity-sample-import-${{ matrix.artifact_suffix }}/Library
key: unity-sample-import-library-${{ runner.os }}-${{ matrix.artifact_suffix }}-${{ hashFiles('com.mrdav30.fixedmathsharp/package.json', 'com.mrdav30.fixedmathsharp/Samples~/**', 'com.mrdav30.fixedmathsharp.lean/package.json', 'com.mrdav30.fixedmathsharp.lean/Samples~/**') }}
restore-keys: |
unity-sample-import-library-${{ runner.os }}-${{ matrix.artifact_suffix }}-
- name: Run Unity sample import smoke
id: sample-import
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: .ci/unity-sample-import-${{ matrix.artifact_suffix }}
unityVersion: 6000.5.0f1
testMode: EditMode
customParameters: -assemblyNames FixedMathSharp.SampleImportSmokeTests -runSynchronously
artifactsPath: artifacts/sample-import-${{ matrix.artifact_suffix }}
githubToken: ${{ github.token }}
checkName: Unity Sample Import ${{ matrix.package_display_name }}
- name: Scan Unity sample import log
if: always() && steps.sample-import.outcome != 'skipped'
shell: bash
run: |
set -euo pipefail
bash .assets/ci/scripts/scan-unity-sample-import-log.sh \
"artifacts/sample-import-${{ matrix.artifact_suffix }}/editmode.log"
- name: Upload Unity sample import artifacts
if: failure()
uses: actions/upload-artifact@v7
with:
name: unity-sample-import-${{ matrix.artifact_suffix }}
path: artifacts/sample-import-${{ matrix.artifact_suffix }}