Skip to content

Merge pull request #2 from nowsprinting/fix/support_2021_or_older #5

Merge pull request #2 from nowsprinting/fix/support_2021_or_older

Merge pull request #2 from nowsprinting/fix/support_2021_or_older #5

Workflow file for this run

# Copyright (c) 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
permissions: write-all
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
unityVersion: # Available versions see: https://game.ci/docs/docker/versions
- 2019.4.40f1
- 2022.2.19f1
include:
- unityVersion: 2022.2.19f1
octocov: true
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: false
lfs: false
- name: Crete project for tests
uses: nowsprinting/create-unity-project-action@v2
with:
project-path: UnityProject~
- uses: actions/cache@v3
with:
path: ${{ env.CREATED_PROJECT_PATH }}/Library
key: Library-${{ matrix.unityVersion }}
restore-keys: |
Library-
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Set npm bin path for cache
run: echo "path=$(npm bin -g)" >> "$GITHUB_OUTPUT"
id: npm_bin
- uses: actions/cache@v3
with:
path: ${{ steps.npm_bin.outputs.path }}
key: npm-${{ hashFiles('.github/workflows/test.yml') }}
- name: Set package name
run: |
echo "package_name=$(grep -o -E '"name": "(.+)"' ./package.json | cut -d ' ' -f2)" >> "$GITHUB_ENV"
- name: Install dependencies
run: |
npm install -g openupm-cli
openupm add -f com.unity.test-framework
openupm add -f com.unity.testtools.codecoverage
openupm add -ft "${{ env.package_name }}"@file:../../
working-directory: ${{ env.CREATED_PROJECT_PATH }}
- name: Set coverage assembly filters
run: |
assemblies=$(find . -name "*.asmdef" -maxdepth 3 | sed -e s/.*\\//\+/ | sed -e s/\\.asmdef// | sed -e s/^.*\\.Tests//)
# shellcheck disable=SC2001,SC2048,SC2086
echo "assembly_filters=$(echo ${assemblies[*]} | sed -e s/\ /,/g),+<assets>,-*.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@v2
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
unityVersion: ${{ matrix.unityVersion }} # Default is `auto`
checkName: test result (${{ matrix.unityVersion }})
projectPath: ${{ env.CREATED_PROJECT_PATH }}
customParameters: -testCategory "!IgnoreCI"
coverageOptions: generateAdditionalMetrics;generateTestReferences;generateHtmlReport;generateAdditionalReports;dontClear;assemblyFilters:${{ env.assembly_filters }}
# see: https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CoverageBatchmode.html
env:
UNITY_LICENSE: ${{ secrets[env.secret_key] }}
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@v0
if: ${{ matrix.octocov }}
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: TestResults-Unity${{ matrix.unityVersion }}
path: |
${{ steps.test.outputs.artifactsPath }}
${{ steps.test.outputs.coveragePath }}
if: always()
notify:
needs: test
runs-on: ubuntu-latest
if: always()
steps:
- uses: Gamesight/slack-workflow-status@v1.2.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}