Add run tests on standalone player #190
Workflow file for this run
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
# Copyright (c) 2021-2023 Koji Hasegawa. | |
# This software is released under the MIT License. | |
name: Test | |
on: | |
push: | |
branches: | |
- master | |
paths-ignore: | |
- '**.md' | |
- '.github/**' | |
- '!.github/workflows/test.yml' | |
pull_request: | |
types: [ opened, synchronize, reopened ] # Same as default | |
paths-ignore: | |
- '**.md' | |
- '.github/**' | |
- '!.github/workflows/test.yml' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
if: github.event.pull_request.head.repo.fork == false # Skip on public fork, because can not read secrets. | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
permissions: | |
contents: read | |
checks: write | |
pull-requests: write | |
strategy: | |
fail-fast: false | |
matrix: | |
unityVersion: # Available versions see: https://game.ci/docs/docker/versions | |
- 2019.4.40f1 | |
- 2020.3.48f1 | |
- 2021.3.42f1 | |
- 2022.3.42f1 | |
- 2023.2.20f1 | |
- 6000.0.22f1 | |
testMode: | |
- All # run tests in editor | |
include: | |
- unityVersion: 2019.4.40f1 | |
octocov: true | |
- unityVersion: 2023.2.20f1 | |
testMode: Standalone # run tests on player | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: false | |
lfs: false | |
- uses: actions/cache@v4 | |
with: | |
path: Library | |
key: Library-linux-${{ matrix.unityVersion }}-${{ github.ref }} | |
restore-keys: | | |
Library-linux-${{ matrix.unityVersion }} | |
Library-linux | |
Library | |
- name: Set coverage assembly filters | |
run: | | |
assemblies=$(find ./Packages -name "*.asmdef" | sed -e s/.*\\//\+/ | sed -e s/\\.asmdef// | sed -e s/^.*\\.Tests//) | |
assemblies+=("+LocalPackageSample*") | |
# shellcheck disable=SC2001,SC2048,SC2086 | |
echo "assembly_filters=+<assets>,$(echo ${assemblies[*]} | sed -e s/\ /,/g),-*.Tests" >> "$GITHUB_ENV" | |
- name: Set license secret key | |
run: echo "secret_key=UNITY_LICENSE_$(echo ${{ matrix.unityVersion }} | cut -c 1-4)" >> "$GITHUB_ENV" | |
- name: Run tests | |
uses: game-ci/unity-test-runner@v4 | |
with: | |
githubToken: ${{ secrets.GITHUB_TOKEN }} | |
unityVersion: ${{ matrix.unityVersion }} # Default is `auto` | |
checkName: test result (${{ matrix.unityVersion }}, ${{ matrix.testMode }}) | |
customParameters: -testCategory "!IgnoreCI;!Integration" | |
coverageOptions: generateAdditionalMetrics;generateTestReferences;generateHtmlReport;generateAdditionalReports;dontClear;assemblyFilters:${{ env.assembly_filters }} | |
# see: https://docs.unity3d.com/Packages/[email protected]/manual/CoverageBatchmode.html | |
testMode: ${{ matrix.testMode }} | |
env: | |
UNITY_LICENSE: ${{ secrets[env.secret_key] }} | |
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
id: test | |
- name: Set coverage path for octocov | |
run: sed -i -r 's/\.\/Logs/${{ steps.test.outputs.coveragePath }}/' .octocov.yml | |
if: ${{ matrix.octocov }} | |
- name: Run octocov | |
uses: k1LoW/octocov-action@v1 | |
if: ${{ matrix.octocov }} | |
- name: Upload test results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: TestResults-Unity${{ matrix.unityVersion }}-${{ matrix.testMode }} | |
path: | | |
${{ steps.test.outputs.artifactsPath }} | |
${{ steps.test.outputs.coveragePath }} | |
if: always() | |
notify: | |
needs: test | |
if: github.event.pull_request.head.repo.fork == false # Skip on public fork, because can not read secrets. | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
permissions: | |
actions: read | |
steps: | |
- uses: Gamesight/[email protected] | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }} |