ParticleEffectForUGUI/.github/workflows/test.yml

125 lines
4.0 KiB
YAML
Raw Normal View History

2024-01-23 14:07:10 +08:00
# Required secrets
# UNITY_LICENSE: The contents of Unity license file
2024-02-01 15:22:52 +08:00
# UNITY_EMAIL: Unity user email to login
# UNITY_PASSWORD: Unity user password to login
2024-01-23 14:07:10 +08:00
name: 🧪 Test
2024-12-18 18:50:31 +08:00
run-name: 🧪 Test (${{ github.event.pull_request.title || github.ref_name }})
2024-01-23 14:07:10 +08:00
env:
# MINIMUM_VERSION: The minimum version of Unity.
MINIMUM_VERSION: 2019.4
2024-02-01 15:27:19 +08:00
# EXCLUDE_FILTER: The excluded versions of Unity.
2024-12-18 18:50:31 +08:00
EXCLUDE_FILTER: "(2020.2.0|2021.1|2023.3)"
2024-01-23 14:07:10 +08:00
on:
workflow_dispatch:
2024-11-21 00:46:37 +08:00
inputs:
usePeriodVersions:
2024-12-18 18:50:31 +08:00
description: "Use the period versions (.0f1, .10f1, 20f1, ...)."
2024-11-21 00:46:37 +08:00
required: false
2024-12-18 18:50:31 +08:00
default: "true"
2024-01-23 14:07:10 +08:00
push:
branches:
- develop
2024-05-23 18:08:50 +08:00
- develop-preview
2024-01-23 14:07:10 +08:00
tags:
- "!*"
paths-ignore:
2024-12-18 18:50:31 +08:00
- "**.md"
pull_request_target:
2024-01-23 14:07:10 +08:00
types:
- opened
2024-12-18 18:50:31 +08:00
- reopened
2024-01-23 14:07:10 +08:00
- synchronize
2024-12-18 18:50:31 +08:00
paths-ignore:
- "**.md"
2024-01-23 14:07:10 +08:00
jobs:
setup:
name: ⚙️ Setup
runs-on: ubuntu-latest
outputs:
unityVersions: ${{ steps.setup.outputs.unityVersions }}
steps:
- name: ⚙️ Find target Unity versions
id: setup
run: |
echo "==== Target Unity Versions ===="
2024-12-18 18:50:31 +08:00
LATEST_VERSIONS=`npx unity-changeset@latest list --versions --latest-patch --min ${MINIMUM_VERSION} --json --all`
2024-11-21 00:46:37 +08:00
if [ "${{ inputs.usePeriodVersions }}" = "true" ]; then
ADDITIONAL_VERSIONS=`npx unity-changeset list --versions --grep '0f' --min ${MINIMUM_VERSION} --json`
else
ADDITIONAL_VERSIONS=[]
fi
2024-02-01 15:22:52 +08:00
2024-01-23 14:07:10 +08:00
VERSIONS=`echo "[${LATEST_VERSIONS}, ${ADDITIONAL_VERSIONS}]" \
| jq -c '[ flatten | sort | unique | .[] | select( test("${{ env.EXCLUDE_FILTER }}") | not ) ]'`
echo "unityVersions=${VERSIONS}" | tee $GITHUB_OUTPUT
test:
name: 🧪 Run tests
runs-on: ubuntu-latest
permissions:
checks: write
contents: read
needs: setup
strategy:
fail-fast: false
2024-11-21 00:46:37 +08:00
max-parallel: 6
2024-01-23 14:07:10 +08:00
matrix:
unityVersion: ${{ fromJson(needs.setup.outputs.unityVersions) }}
steps:
2024-12-18 18:50:31 +08:00
- name: 🚚 Checkout ($${{ github.ref }})
if: github.event_name == 'push'
uses: actions/checkout@v4
- name: 🚚 Checkout pull request (pull_request_target)
if: github.event_name == 'pull_request_target'
2024-01-23 14:07:10 +08:00
uses: actions/checkout@v4
2024-12-18 18:50:31 +08:00
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: 🚚 Marge pull request (pull_request_target)
if: github.event_name == 'pull_request_target'
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git merge origin/${{ github.event.pull_request.base.ref }} --no-edit
2024-01-23 14:07:10 +08:00
- name: 📥 Cache library
2024-02-01 15:22:52 +08:00
uses: actions/cache@v4
2024-01-23 14:07:10 +08:00
with:
path: Library
2024-12-18 18:50:31 +08:00
key: Library-${{ matrix.unityVersion }}-${{ github.event.pull_request.head.sha || github.sha }}
2024-01-23 14:07:10 +08:00
restore-keys: |
Library-${{ matrix.unityVersion }}-
Library-
2024-11-21 00:46:37 +08:00
- name: 🛠️ Build Unity Project (Test)
2024-02-01 15:22:52 +08:00
uses: game-ci/unity-builder@v4
timeout-minutes: 45
2024-01-23 14:07:10 +08:00
with:
customImage: ghcr.io/mob-sakai/unity3d:${{ matrix.unityVersion }}
targetPlatform: StandaloneLinux64
allowDirtyBuild: true
customParameters: -nographics
2024-12-18 18:50:31 +08:00
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
2024-01-23 14:07:10 +08:00
2024-12-18 18:50:31 +08:00
- name: 🧪 Run tests
uses: game-ci/unity-test-runner@v4
timeout-minutes: 45
with:
customImage: ghcr.io/mob-sakai/unity3d:${{ matrix.unityVersion }}
# unityVersion: ${{ matrix.unityVersion }}
customParameters: -nographics
checkName: ${{ matrix.unityVersion }} Test Results
githubToken: ${{ github.token }}
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}