Skip to content

chore: release v0.23.1 #37

chore: release v0.23.1

chore: release v0.23.1 #37

Workflow file for this run

name: Unity Tests
# Path-filtered on purpose. This matrix is five game-ci jobs; before the monorepo
# it lived in a repo that only held C#, so firing on every push was harmless. Now
# a renderer or docs commit would light up all five for nothing.
#
# `push` is main-only, deliberately. It used to be `['**']` alongside the
# pull_request trigger, and the concurrency group is keyed on github.ref -- which is
# refs/heads/<branch> for a push but refs/pull/N/merge for a pull request, so the two
# runs landed in different groups and neither cancelled the other. Every push to a
# branch with an open PR ran the whole matrix twice. The cost of main-only is that a
# branch with no PR gets no run; open a draft PR to get one.
on:
push:
branches: [main]
paths:
- 'unity/**'
- 'tests/**'
- '.github/workflows/unity-tests.yml'
pull_request:
branches: [main]
paths:
- 'unity/**'
- 'tests/**'
- '.github/workflows/unity-tests.yml'
workflow_dispatch:
inputs:
overwrite-snapshots:
type: boolean
description: Overwrite snapshots
# The old workflow also had `repository_dispatch: [run-tests]`, fired by a
# trigger-tests.yml living on the orphan `tests` branch of another repo. Both
# sides are in this repo now, so the whole round trip is deleted.
concurrency:
group: unity-tests-${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
name: ${{ matrix.suite.name }} - Unity ${{ matrix.unity.version }}
permissions:
contents: write
checks: write
pull-requests: write
# An explicit job list, not an axis product, because the whole list is swapped per
# event: a pull request runs only the job marked `main`, and everything else runs all
# three versions. Each job is ~18 minutes and they are parallel, so dropping to one on
# PRs cuts machine time to a third and leaves the ~19 minute wall clock alone.
#
# The cost is that a break in one version only -- as the :enter/:leave transition
# timing was, on 6000.x alone -- surfaces after merge rather than in the PR. Run the
# workflow by hand on a branch, or push to main, to get the full matrix.
#
# `main` marks the one job that owns the side effects: committing snapshots and
# pushing the badge gist. It stays on the newest version so a PR is checked against
# the one most people are on.
#
# 2021.3, 2022.3 and 2023.2 were dropped. 2021.3 had stopped contributing anything: its
# PlayMode run produced a 0-test result file, so the job only ever reported the
# EditMode suite. unity/core/package.json still declares `"unity": "2021.3"` --
# dropping a job is not the same as dropping support, so lower that separately if
# that is the intent.
#
# 2023.2 went because tests/Packages/manifest.json pins com.unity.inputsystem 1.14.2,
# which references BuildTarget.VisionOS -- absent in 2023.2, so InputSystemPluginControl
# fails to compile with CS0117 and no test runs at all. The pin is deliberate (the newer
# input system is what the project develops against), so the job could only have been
# kept by downgrading it, and older versions use the TreeView API that 6000.5 treats as
# obsolete-as-error locally. Trading a CI failure for a local one is not a trade.
#
# Worth knowing how long that was invisible: the job kept passing for a day after the
# pin landed in 555c206e, because its Library cache still held the pre-pin resolution.
# The cache key had no content hash, so the stale entry was restored on every run. It
# now hashes the manifests (see the cache step), which is what surfaced this.
#
# `platform` and `unity.license` are absent from every entry on purpose; the two
# places that read them fall back to 'ubuntu-latest' and 'UNITY_LICENSE'.
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(github.event_name == 'pull_request'
&& '[{"main":true,"unity":{"version":"6000.1.9f1"},"suite":{"name":"Unit Tests","assemblies":"ReactUnity.Tests;ReactUnity.Tests.Editor"}}]'
|| '[{"main":true,"unity":{"version":"6000.1.9f1"},"suite":{"name":"Unit Tests","assemblies":"ReactUnity.Tests;ReactUnity.Tests.Editor"}},{"unity":{"version":"6000.0.51f1"},"suite":{"name":"Unit Tests","assemblies":"ReactUnity.Tests;ReactUnity.Tests.Editor"}}]') }}
runs-on: ${{ matrix.platform || 'ubuntu-latest' }}
steps:
# One checkout. This replaced five (core, tests@tests branch, jint, quickjs,
# clearscript) plus the jq manifest rewriting that wired them together --
# tests/Packages/manifest.json now commits the correct file:../../unity/*
# paths, so there is nothing to patch at runtime.
- uses: actions/checkout@v7
with:
fetch-depth: 0
# The key carries the package manifests because tests/Library holds PackageCache, and a
# Library resolved for one set of packages has no business being restored for another.
#
# It is worth being clear about what this does NOT fix. The 2023.2 job wedged on a cache
# whose PackageCache was simply incomplete -- `CS0006: Metadata file
# codecoverage@1.2.5/.../ReportGeneratorMerged.dll could not be found`, and CS2001 for a
# dozen test-framework sources. Nothing in a key detects a corrupt entry, and with a key
# that never varied, that one was restored on every run until it was deleted by hand
# (`gh cache delete <id>`, still the fix for that). What the hash buys is that the wedge
# can no longer outlive a package change, and that a manifest edit cannot be served a
# Library built for the previous one.
#
# No restore-keys, deliberately: a prefix fallback would restore the newest older entry
# on a miss, which is precisely the poisoned one you are trying to get away from. A key
# change pays a cold import instead, which is the point.
- name: Cache Unity Library
uses: actions/cache@v6
with:
path: tests/Library
key: Library-${{ matrix.unity.version }}-${{ matrix.platform || 'ubuntu-latest' }}-${{ hashFiles('tests/Packages/manifest.json', 'tests/Packages/packages-lock.json') }}
# NOTE for tests/Packages/manifest.json, which is JSON and cannot hold this
# comment: `com.unity.test-framework.performance` was removed from `testables`.
# On Unity 6000.x, Unity upgrades that package 2.8.1-preview -> 3.1.0, and a
# package listed in `testables` makes Unity resolve its *related* test package
# too -- com.unity.test-framework.performance.tests@3.1.0, which does not exist.
# Resolution then failed for the whole project and the PlayMode run produced no
# results at all, so the 662-test UGUI suite silently did not run on 6000.0 or
# 6000.1 while the job still reported the 325 EditMode tests.
#
# The package stays a dependency (unity/core/Tests/Performance needs
# Unity.PerformanceTesting to compile) and this repo's own perf tests still run:
# they live in com.reactunity.core, which is still testable. Only Unity's own
# tests for that package are no longer requested.
- name: Run Unity Tests
uses: game-ci/unity-test-runner@v4
id: testRunner
continue-on-error: true
env:
UNITY_LICENSE: ${{ secrets[matrix.unity.license || 'UNITY_LICENSE'] }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
projectPath: tests
githubToken: ${{ secrets.GITHUB_TOKEN }}
checkName: ${{ matrix.suite.name }} ${{ matrix.unity.version }}
unityVersion: ${{ matrix.unity.version }}
testMode: ${{ contains(matrix.suite.assemblies, 'Editor') && 'All' || 'PlayMode' }}
# Code coverage instrumentation is gone along with Codecov. It cost
# -debugCodeOptimization on the slowest job and nothing consumed the
# result any more.
customParameters: >-
-assemblyNames ${{ matrix.suite.assemblies }}
${{ (contains(github.event.head_commit.message, '[snapshots]') || github.event.inputs.overwrite-snapshots == 'true') && '-reactOverwriteSnapshots' || '' }}
# Never on a pull request: checkout leaves a detached merge commit there, so there is
# no branch to push to. Overwrite mode cannot switch on for that event anyway -- it
# reads head_commit.message and the dispatch input, both null -- so no lockfile is
# written and this was already inert. Stated rather than relied on.
- name: Commit Snapshots
if: >
github.event_name != 'pull_request' && matrix.main &&
hashFiles('unity/core/Tests/.snapshots/snapshots.lock') != ''
uses: EndBug/add-and-commit@v10
with:
add: 'unity/core/Tests/.snapshots'
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@v2
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@v7
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@v9
with:
script: core.setFailed('Tests failed!')