Skip to content

update min unity version #545

update min unity version

update min unity version #545

Workflow file for this run

name: Tests
on:
push:
branches:
- "**"
paths-ignore:
- "docs/**"
- "**.md"
- ".vscode/**"
pull_request:
branches: [main]
repository_dispatch:
types: [run-tests]
workflow_dispatch:
inputs:
overwrite-snapshots:
type: boolean
description: Overwrite snapshots
jobs:
tests:
name: ${{ matrix.suite.name }} - Unity ${{ matrix.unity.version }}
permissions:
contents: write
pages: write
id-token: write
checks: write
pull-requests: write
strategy:
fail-fast: false
matrix:
platform:
- ubuntu-latest
unity:
- { version: "2021.3.28f1" }
- { version: "2021.1.28f1" }
- { version: "2020.3.43f1" }
suite:
- {
name: "Unit Tests",
assemblies: "ReactUnity.Tests;ReactUnity.Tests.Editor",
}
include:
- main: true
coverage: true
unity: { version: "2022.3.4f1" }
suite:
{
name: "Unit Tests",
assemblies: "ReactUnity.Tests;ReactUnity.Tests.Editor",
}
- performance: true
unity: { version: "2022.3.4f1" }
suite:
{
name: "Performance Tests",
assemblies: "ReactUnity.Tests.Performance",
}
runs-on: ${{ matrix.platform || 'ubuntu-20.04' }}
steps:
- name: Checkout core library
uses: actions/checkout@v3
with:
fetch-depth: 0
path: core
- name: Checkout test project
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ matrix.suite.testBranch || 'tests' }}
path: tests
- name: Checkout Jint plugin
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
path: jint
repository: ReactUnity/jint
- name: Checkout QuickJS plugin
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
path: quickjs
repository: ReactUnity/quickjs
- name: Checkout ClearScript plugin
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
path: clearscript
repository: ReactUnity/clearscript
- name: Cache Unity Library
uses: actions/cache@v3
with:
path: tests/Library
key: Library-${{ matrix.unity.version }}-${{ matrix.platform || 'ubuntu-20.04' }}
- name: Clear React Unity package lock
run: |
echo $(cat tests/Packages/packages-lock.json | jq 'del(.dependencies["com.reactunity.core"])') > tests/Packages/packages-lock.json
echo $(cat tests/Packages/packages-lock.json | jq 'del(.dependencies["com.reactunity.jint"])') > tests/Packages/packages-lock.json
echo $(cat tests/Packages/packages-lock.json | jq 'del(.dependencies["com.reactunity.quickjs"])') > tests/Packages/packages-lock.json
echo $(cat tests/Packages/packages-lock.json | jq 'del(.dependencies["com.reactunity.clearscript"])') > tests/Packages/packages-lock.json
- name: Install local React Unity package
run: |
echo $(cat tests/Packages/manifest.json | jq '.dependencies["com.reactunity.core"]="file:../../core"') > tests/Packages/manifest.json
echo $(cat tests/Packages/manifest.json | jq '.dependencies["com.reactunity.jint"]="file:../../jint"') > tests/Packages/manifest.json
echo $(cat tests/Packages/manifest.json | jq '.dependencies["com.reactunity.quickjs"]="file:../../quickjs"') > tests/Packages/manifest.json
echo $(cat tests/Packages/manifest.json | jq '.dependencies["com.reactunity.clearscript"]="file:../../clearscript"') > tests/Packages/manifest.json
- name: Run Unity Tests
uses: game-ci/unity-test-runner@v2
id: testRunner
continue-on-error: true
env:
UNITY_LICENSE: ${{ secrets[matrix.unity.license || 'UNITY_LICENSE'] }}
with:
projectPath: tests
checkName: ${{ matrix.suite.name }} ${{ matrix.unity.version }}
unityVersion: ${{ matrix.unity.version }}
testMode: ${{ contains(matrix.suite.assemblies, 'Editor') && 'All' || 'PlayMode' }}
customParameters: >-
${{ matrix.coverage && '-enableCodeCoverage -debugCodeOptimization -coverageOptions assemblyFilters:+ReactUnity,+ReactUnity.*' || '' }}
-assemblyNames ${{ matrix.suite.assemblies }}
${{ matrix.performance && '-profiler-enable' || '' }}
${{ (contains(github.event.head_commit.message, '[snapshots]') || github.event.inputs.overwrite-snapshots == 'true') && '-reactOverwriteSnapshots' || '' }}
- name: Cache Performance Test Results
if: matrix.performance
uses: actions/cache@v3
with:
path: tests/PerformanceTestResults
key: performance-results-${{ github.sha }}
restore-keys: |
performance-results-
- name: Copy Test Results to Performance Test Results
if: matrix.performance
working-directory: ./tests
run: |
mkdir -p PerformanceTestResults
cd "${{ github.workspace }}/${{ steps.testRunner.outputs.artifactsPath }}"
find . -name \*.xml -exec bash -c 'cp $0 "${{ github.workspace }}/tests/PerformanceTestResults/$(date +%s)-$(basename ""$0"")"' {} \;
- name: Keep only last 10 files
if: matrix.performance
working-directory: tests/PerformanceTestResults
continue-on-error: true
run: ls -A1t | tail -n +11 | xargs rm
- uses: actions/setup-dotnet@v4
if: matrix.performance
with:
dotnet-version: '3.1.x'
cache: true
- name: Generate Performance Report
if: matrix.performance
working-directory: ./tests
run: dotnet PerformanceReporter/UnityPerformanceBenchmarkReporter.dll --results="${{ github.workspace }}/tests/PerformanceTestResults" --reportdirpath=PerformanceReport
- name: Rename Performance Report
working-directory: ./tests/PerformanceReport/UnityPerformanceBenchmark
if: matrix.performance
run: |
find . -name '*.html' -exec bash -c 'mv $0 index.html' {} \;
cd ..
mv UnityPerformanceBenchmark Performance
- name: Commit Snapshots
if: hashFiles('core/Tests/.snapshots/snapshots.lock') != '' && matrix.main
uses: EndBug/add-and-commit@v9
with:
add: "Tests/.snapshots"
cwd: "./core"
default_author: github_actions
message: "Update snapshots"
- name: Set artifacts folder ownership to current user
run: sudo chown -R $(id -u):$(id -g) "${{ github.workspace }}/${{ steps.testRunner.outputs.artifactsPath }}"
- uses: EnricoMi/publish-unit-test-result-action@v2
id: test-results
with:
check_name: "${{ matrix.suite.name }} ${{ matrix.unity.version }}"
nunit_files: "${{ github.workspace }}/${{ steps.testRunner.outputs.artifactsPath }}/*.xml"
- name: Set badge color
shell: bash
run: |
case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in
success)
echo "BADGE_COLOR=31c653" >> $GITHUB_ENV
;;
failure)
echo "BADGE_COLOR=800000" >> $GITHUB_ENV
;;
neutral)
echo "BADGE_COLOR=696969" >> $GITHUB_ENV
;;
esac
- name: Create badge
uses: emibcn/badge-action@v1
with:
label: Tests
status: "${{ fromJSON( steps.test-results.outputs.json ).stats.tests_succ }}/${{ fromJSON( steps.test-results.outputs.json ).stats.tests }}"
color: ${{ env.BADGE_COLOR }}
path: ReactUnityTestBadge.svg
style: flat
scale: 1.4
- name: Upload badge to Gist
if: github.ref == 'refs/heads/main' && always() && matrix.main
uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d
with:
token: ${{ secrets.GIST_TOKEN }}
gistURL: https://gist.githubusercontent.com/KurtGokhan/f744e86dd53cd0159d4f1d56ae9aae19
file: ReactUnityTestBadge.svg
- name: Upload Test Result Artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: "${{ matrix.suite.name }} ${{ matrix.unity.version }}"
path: ${{ steps.testRunner.outputs.artifactsPath }}
- name: Fail workflow if tests failed
if: steps.testRunner.outcome == 'failure' && (fromJSON(steps.test-results.outputs.json).conclusion == 'failure' || fromJSON(steps.test-results.outputs.json).stats.tests == 0)
uses: actions/github-script@v3
with:
script: |
core.setFailed('Tests failed!')
- name: Upload Coverage to codecov
if: matrix.coverage && matrix.main
uses: codecov/codecov-action@v3
with:
working-directory: ./core
files: ../CodeCoverage/tests-opencov/PlayMode/TestCoverageResults_0000.xml,../CodeCoverage/tests-opencov/PlayMode/TestCoverageResults_0001.xml,../CodeCoverage/tests-opencov/EditMode/TestCoverageResults_0000.xml,../CodeCoverage/tests-opencov/EditMode/TestCoverageResults_0001.xml
path_to_write_report: ../CodeCoverage/codecov_report.txt
flags: unittests
- name: Upload Code Coverage Artifacts
uses: actions/upload-artifact@v3
if: always() && matrix.main && matrix.coverage && contains(github.event.head_commit.message, '[coverage]')
with:
name: "${{ matrix.suite.name }} ${{ matrix.unity.version }} Code Coverage"
path: CodeCoverage
- name: Setup Github Pages
if: github.ref == 'refs/heads/main' && matrix.performance && always()
uses: actions/configure-pages@v2
- name: Upload Pages Artifact
if: github.ref == 'refs/heads/main' && matrix.performance && always()
uses: actions/upload-pages-artifact@v1
with:
path: "./tests/PerformanceReport/Performance"
- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/main' && matrix.performance && always()
id: deployment
uses: actions/deploy-pages@v1