From bfd7a03a446572f6bd16c2a0648e8aeeb30666ad Mon Sep 17 00:00:00 2001 From: Daniel Widgren Date: Fri, 1 May 2026 19:12:50 +0200 Subject: [PATCH] ci: add smoke workflow against sdk_demo_backend Adds .github/workflows/smoke.yml that runs the existing PlayMode SmokeTest against a freshly-booted sdk_demo_backend on every PR and push to main. The workflow: - checks asobi-unity out as an embedded UPM package under _unity_project/Packages/com.asobi.sdk - scaffolds a minimal Unity 2022.3.50f1 host project that lists the package as a testable - clones widgrensit/sdk_demo_backend, brings it up via docker compose, and waits for /api/v1/auth/register to respond < 500 - runs PlayMode tests via game-ci/unity-test-runner@v4 with ASOBI_URL=http://localhost:8084 - dumps docker compose logs on failure and tears the stack down in always() Requires UNITY_LICENSE, UNITY_EMAIL and UNITY_PASSWORD repo secrets to be configured before the job can pass. --- .github/workflows/smoke.yml | 95 +++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 .github/workflows/smoke.yml diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml new file mode 100644 index 0000000..26b06d3 --- /dev/null +++ b/.github/workflows/smoke.yml @@ -0,0 +1,95 @@ +name: Smoke + +on: + pull_request: + push: + branches: [main] + +jobs: + smoke: + name: PlayMode smoke vs sdk_demo_backend + runs-on: ubuntu-24.04 + timeout-minutes: 30 + + steps: + - name: Check out asobi-unity (as embedded package) + uses: actions/checkout@v4 + with: + path: _unity_project/Packages/com.asobi.sdk + + - name: Check out sdk_demo_backend + uses: actions/checkout@v4 + with: + repository: widgrensit/sdk_demo_backend + path: _backend + + - name: Bring up sdk_demo_backend + run: docker compose up -d + working-directory: _backend + + - name: Wait for backend + run: | + for i in $(seq 1 60); do + code=$(curl -s -o /dev/null -w "%{http_code}" -X POST \ + -H 'content-type: application/json' \ + -d '{}' http://localhost:8084/api/v1/auth/register || echo 000) + if [ "$code" != "000" ] && [ "$code" -lt 500 ]; then + echo "Backend reachable (HTTP $code)" + exit 0 + fi + sleep 1 + done + echo "Backend never became reachable" + exit 1 + + - name: Scaffold minimal Unity project + run: | + mkdir -p _unity_project/Assets _unity_project/ProjectSettings + cat > _unity_project/Packages/manifest.json <<'EOF' + { + "dependencies": { + "com.asobi.sdk": "file:com.asobi.sdk", + "com.unity.test-framework": "1.4.5", + "com.unity.ugui": "1.0.0" + }, + "testables": [ + "com.asobi.sdk" + ] + } + EOF + cat > _unity_project/ProjectSettings/ProjectVersion.txt <<'EOF' + m_EditorVersion: 2022.3.50f1 + EOF + + - name: Cache Unity Library + uses: actions/cache@v4 + with: + path: _unity_project/Library + key: Library-${{ hashFiles('_unity_project/Packages/manifest.json', '_unity_project/Packages/com.asobi.sdk/**') }} + restore-keys: | + Library- + + - name: Run PlayMode tests + uses: game-ci/unity-test-runner@v4 + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + ASOBI_URL: http://localhost:8084 + with: + projectPath: _unity_project + unityVersion: 2022.3.50f1 + testMode: playmode + customParameters: -nographics + githubToken: ${{ secrets.GITHUB_TOKEN }} + checkName: PlayMode test results + + - name: Backend logs on failure + if: failure() + run: docker compose logs + working-directory: _backend + + - name: Tear down sdk_demo_backend + if: always() + run: docker compose down -v + working-directory: _backend