unity-builder/.github/workflows/cloud-runner-integrity.yml

301 lines
10 KiB
YAML

name: cloud-runner-integrity
on:
workflow_call:
inputs:
runGithubIntegrationTests:
description: 'Run GitHub Checks integration tests'
required: false
default: 'false'
type: string
permissions:
contents: read
checks: write
statuses: write
env:
# Commented out: Using LocalStack tests instead of real AWS
# AWS_REGION: eu-west-2
# AWS_DEFAULT_REGION: eu-west-2
AWS_STACK_NAME: game-ci-team-pipelines # Still needed for LocalStack S3 bucket creation
CLOUD_RUNNER_BRANCH: ${{ github.ref }}
DEBUG: true
PROJECT_PATH: test-project
USE_IL2CPP: false
jobs:
k8s:
name: Cloud Runner Tests (K8s)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
lfs: false
# Set up Kubernetes (k3s via k3d)
- name: Set up kubectl
uses: azure/setup-kubectl@v4
with:
version: 'v1.34.1'
- name: Install k3d
run: |
curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
k3d version | cat
- name: Create k3s cluster (k3d)
timeout-minutes: 5
run: |
# Create cluster with basic configuration
# Using simpler setup to avoid hangs - resource limits handled via container requests
k3d cluster create unity-builder --agents 1 --wait
kubectl config current-context | cat
- name: Verify cluster readiness
timeout-minutes: 2
run: |
for i in {1..60}; do
if kubectl get nodes 2>/dev/null | grep -q Ready; then
echo "Cluster is ready"
break
fi
echo "Waiting for cluster... ($i/60)"
sleep 5
done
kubectl get nodes
kubectl get storageclass
# Show node resources
kubectl describe nodes | grep -A 5 "Allocated resources" || true
- name: Start LocalStack (S3)
uses: localstack/setup-localstack@v0.2.4
with:
install-awslocal: true
- name: Create S3 bucket for tests (host LocalStack)
run: |
awslocal s3 mb s3://$AWS_STACK_NAME || true
awslocal s3 ls
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: Clean up disk space before tests
run: |
# Clean up any leftover cache files from previous runs
rm -rf ./cloud-runner-cache/* || true
# Clean up system caches and temporary files
sudo apt-get clean || true
docker system prune -f || true
# Show available disk space
df -h
- run: yarn install --frozen-lockfile
- name: Run K8s tests sequentially
timeout-minutes: 180
run: |
# List of K8s tests to run sequentially
tests=(
"cloud-runner-end2end-caching"
"cloud-runner-end2end-retaining"
"cloud-runner-hooks"
)
failed_tests=()
for test in "${tests[@]}"; do
echo "========================================="
echo "Running test: $test"
echo "========================================="
# Clean up K8s resources before each test
echo "Cleaning up K8s resources before test..."
kubectl delete jobs --all --ignore-not-found=true --all-namespaces || true
kubectl delete pods --all --ignore-not-found=true --all-namespaces || true
kubectl delete pvc --all --ignore-not-found=true --all-namespaces || true
kubectl delete secrets --all --ignore-not-found=true --all-namespaces || true
sleep 3
# Clean up disk space before each test
rm -rf ./cloud-runner-cache/* || true
docker system prune -f || true
# Run the test
if yarn run test "$test" --detectOpenHandles --forceExit --runInBand; then
echo "✓ Test $test passed"
else
echo "✗ Test $test failed"
failed_tests+=("$test")
fi
echo ""
done
# Report results
if [ ${#failed_tests[@]} -eq 0 ]; then
echo "========================================="
echo "All tests passed!"
echo "========================================="
exit 0
else
echo "========================================="
echo "Failed tests: ${failed_tests[*]}"
echo "========================================="
exit 1
fi
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
PROJECT_PATH: test-project
TARGET_PLATFORM: StandaloneWindows64
cloudRunnerTests: true
versioning: None
KUBE_STORAGE_CLASS: local-path
PROVIDER_STRATEGY: k8s
# Set lower resource requests for tests to prevent evictions in k3d
containerCpu: '512'
containerMemory: '512'
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
AWS_S3_ENDPOINT: http://localhost:4566
AWS_ENDPOINT: http://localhost:4566
INPUT_AWSS3ENDPOINT: http://localhost:4566
INPUT_AWSENDPOINT: http://localhost:4566
AWS_S3_FORCE_PATH_STYLE: 'true'
AWS_EC2_METADATA_DISABLED: 'true'
GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
localstack:
name: Cloud Runner Tests (LocalStack)
runs-on: ubuntu-latest
services:
localstack:
image: localstack/localstack
ports:
- 4566:4566
env:
SERVICES: cloudformation,ecs,kinesis,cloudwatch,s3,logs
steps:
- uses: actions/checkout@v4
with:
lfs: false
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: Clean up disk space before tests
run: |
# Clean up any leftover cache files from previous runs
rm -rf ./cloud-runner-cache/* || true
# Clean up system caches and temporary files
sudo apt-get clean || true
docker system prune -f || true
# Show available disk space
df -h
- run: yarn install --frozen-lockfile
- name: Run LocalStack tests sequentially
timeout-minutes: 300
run: |
# List of LocalStack tests to run sequentially
tests=(
"cloud-runner-end2end-locking"
"cloud-runner-end2end-caching"
"cloud-runner-end2end-retaining"
"cloud-runner-caching"
"cloud-runner-environment"
"cloud-runner-image"
"cloud-runner-hooks"
"cloud-runner-local-persistence"
"cloud-runner-locking-core"
"cloud-runner-locking-get-locked"
)
failed_tests=()
for test in "${tests[@]}"; do
echo "========================================="
echo "Running test: $test"
echo "========================================="
# Clean up disk space before each test
rm -rf ./cloud-runner-cache/* || true
docker system prune -f || true
df -h
# Run the test
if yarn run test "$test" --detectOpenHandles --forceExit --runInBand; then
echo "✓ Test $test passed"
else
echo "✗ Test $test failed"
failed_tests+=("$test")
fi
echo ""
done
# Report results
if [ ${#failed_tests[@]} -eq 0 ]; then
echo "========================================="
echo "All tests passed!"
echo "========================================="
exit 0
else
echo "========================================="
echo "Failed tests: ${failed_tests[*]}"
echo "========================================="
exit 1
fi
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
PROJECT_PATH: test-project
TARGET_PLATFORM: StandaloneWindows64
cloudRunnerTests: true
versioning: None
KUBE_STORAGE_CLASS: local-path
PROVIDER_STRATEGY: aws
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
AWS_ENDPOINT: http://localhost:4566
AWS_ENDPOINT_URL: http://localhost:4566
GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
# Commented out: Using LocalStack tests instead of real AWS
# aws:
# name: Cloud Runner Tests (AWS)
# runs-on: ubuntu-latest
# needs: [k8s, localstack]
# strategy:
# fail-fast: false
# matrix:
# test:
# - 'cloud-runner-end2end-caching'
# - 'cloud-runner-end2end-retaining'
# - 'cloud-runner-hooks'
# steps:
# - uses: actions/checkout@v4
# with:
# lfs: false
# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: ${{ env.AWS_REGION }}
# - uses: actions/setup-node@v4
# with:
# node-version: 20
# cache: 'yarn'
# - run: yarn install --frozen-lockfile
# - run: yarn run test "${{ matrix.test }}" --detectOpenHandles --forceExit --runInBand
# timeout-minutes: 60
# env:
# UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
# UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
# UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
# PROJECT_PATH: test-project
# TARGET_PLATFORM: StandaloneWindows64
# cloudRunnerTests: true
# versioning: None
# PROVIDER_STRATEGY: aws
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
# GITHUB_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}