Skip to content

chore: authentication deep link login #5080

chore: authentication deep link login

chore: authentication deep link login #5080

name: Unity Performance Test
on:
workflow_dispatch:
pull_request:
types:
- opened
- reopened
- synchronize
- labeled
permissions:
contents: read
packages: write
actions: read
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_LICENSE: ${{ secrets.UNITY_PERSONAL_LICENSE }}
UNITY_IMAGE_FLAVOR: linux-il2cpp
UNITY_IMAGE_VERSION: 3.2.0
GHCR_IMAGE_NAME: unityci-editor
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
performance-test:
name: Performance Test (PlayMode)
runs-on: ubuntu-latest
# Run on manual dispatch OR when PR has 'perf_test' label (already present or just added)
if: |
github.event_name == 'workflow_dispatch' ||
contains(github.event.pull_request.labels.*.name, 'perf_test')
steps:
- name: Move Docker data-root to /mnt/docker
run: |
sudo systemctl stop docker
sudo mkdir -p /mnt/docker
echo '{"data-root":"/mnt/docker"}' | sudo tee /etc/docker/daemon.json
sudo systemctl start docker
docker info | sed -n '1,40p'
df -h /mnt /mnt/docker
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
lfs: true
submodules: recursive
- name: Create LFS file list
run: git lfs ls-files -l | awk '{print $1}' | sort > .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v5
id: lfs-cache
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
- name: Git LFS Pull
run: |
git lfs pull
git add .
git reset --hard
- uses: webfactory/ssh-agent@v0.8.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: 'Add GitHub to the SSH known hosts file'
run: |
mkdir -p -m 0700 /home/runner/.ssh
curl --silent https://api.github.com/meta | jq --raw-output '"github.com "+.ssh_keys[]' >> /home/runner/.ssh/known_hosts
chmod 600 /home/runner/.ssh/known_hosts
- name: Restore Library cache
uses: actions/cache@v5
with:
path: Explorer/Library
key: Library-Explorer-Ubuntu
# --- Detect Unity version from the project ---
- name: Read Unity version from ProjectVersion.txt
id: unity-version
run: |
verFile="Explorer/ProjectSettings/ProjectVersion.txt"
if [ ! -f "$verFile" ]; then
echo "File not found: $verFile"
exit 1
fi
ver=$(grep -o 'm_EditorVersion: [0-9a-f.]*' "$verFile" | cut -d' ' -f2)
if [ -z "$ver" ]; then
echo "Could not parse Unity version from $verFile"
exit 1
fi
echo "version=$ver" >> $GITHUB_OUTPUT
echo "Detected Unity version: $ver"
# --- Build image references (GHCR + upstream) ---
- name: Set image names
id: img
run: |
version="${{ steps.unity-version.outputs.version }}"
flavor="${{ env.UNITY_IMAGE_FLAVOR }}"
imgVer="${{ env.UNITY_IMAGE_VERSION }}"
# ubuntu-<unityVersion>-<flavor>-<gameciVersion>
tag="ubuntu-$version-$flavor-$imgVer"
owner=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
upstream="unityci/editor:$tag"
ghcr="ghcr.io/$owner/${{ env.GHCR_IMAGE_NAME }}:$tag"
echo "tag=$tag" >> $GITHUB_OUTPUT
echo "upstream=$upstream" >> $GITHUB_OUTPUT
echo "ghcr=$ghcr" >> $GITHUB_OUTPUT
echo "Upstream image: $upstream"
echo "GHCR image: $ghcr"
# --- Log into GHCR ---
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
# --- Restore Unity image from GHCR (fast path) ---
- name: Restore Unity image from GHCR
id: restore-image
continue-on-error: true
run: |
docker pull "${{ steps.img.outputs.ghcr }}"
# --- Seed GHCR from Docker Hub if missing (one-time per tag) ---
- name: Download from Docker Hub and upload to GHCR (if missing)
if: steps.restore-image.outcome == 'failure'
run: |
upstream="${{ steps.img.outputs.upstream }}"
ghcr="${{ steps.img.outputs.ghcr }}"
echo "GHCR miss. Pulling upstream: $upstream"
docker pull $upstream
docker tag $upstream $ghcr
docker push $ghcr
echo "Seeded GHCR: $ghcr"
# Configure test runner for Performance tests only
- uses: game-ci/unity-test-runner@v4.3.1
id: testRunner
timeout-minutes: 180
continue-on-error: true
env:
SHELL: /bin/bash
with:
projectPath: Explorer
testMode: playmode
sshAgent: ${{ env.SSH_AUTH_SOCK }}
customImage: ${{ steps.img.outputs.ghcr }}
customParameters: -buildTarget StandaloneLinux64 -testCategory "Performance" -perfTestResults ./PerformanceTestResults.json -DCLBenchmarkCIPKey ${{ secrets.DCL_BENCHMARK_CIP_KEY }}
githubToken: ${{ env.GITHUB_TOKEN }}
# Generate PDF report
- name: Set up Python
if: always()
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install report dependencies
if: always()
run: pip install -r scripts/requirements-perf-report.txt
- name: Generate performance report PDF
if: always()
run: |
python scripts/generate_perf_report.py Explorer/PerformanceTestResults.json Explorer/PerformanceBenchmarkReport.pdf --github-summary Explorer/github_summary.md
cat Explorer/github_summary.md >> $GITHUB_STEP_SUMMARY
# Upload performance test results JSON
- name: Upload performance test results (JSON)
uses: actions/upload-artifact@v6
if: always()
with:
name: Performance test results (JSON)
path: Explorer/PerformanceTestResults.json
if-no-files-found: warn
# Upload performance report PDF
- name: Upload performance report (PDF)
uses: actions/upload-artifact@v6
if: always()
with:
name: Performance benchmark report (PDF)
path: Explorer/PerformanceBenchmarkReport.pdf
if-no-files-found: warn