From 4ef574b6bec28545c6331e14b0d155e1cb065fb3 Mon Sep 17 00:00:00 2001 From: Talha Date: Fri, 30 Jan 2026 09:40:26 +0500 Subject: [PATCH 1/2] ci: release please update --- .github/workflows/release-please.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index 79b05af..2acb6a3 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -11,16 +11,12 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -permissions: - contents: write - pull-requests: write - jobs: release-please: runs-on: ubuntu-latest steps: - uses: googleapis/release-please-action@v4 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.RELEASE_PLEASE_GITHUB_TOKEN }} config-file: .github/release-please/release-please-config.json manifest-file: .github/release-please/release-please-manifest.json From 89875746885fdb7098ebd9499cf7c575a9a104ab Mon Sep 17 00:00:00 2001 From: Talha Date: Fri, 30 Jan 2026 09:42:48 +0500 Subject: [PATCH 2/2] ci: new ci updates --- .../release-please/release-please-config.json | 1 - .github/workflows/build-sample-webgl.yaml | 87 +++++ .github/workflows/packaging.yaml | 41 +-- .github/workflows/testpackage.yaml | 35 -- .github/workflows/testupm.yaml | 38 ++ .github/workflows/unity-tests-gate.yaml | 94 +++++ .github/workflows/unity-tests-run.yaml | 325 ++++++++++++++++++ .github/workflows/verify-js-plugin.yaml | 41 +++ 8 files changed, 600 insertions(+), 62 deletions(-) create mode 100644 .github/workflows/build-sample-webgl.yaml delete mode 100644 .github/workflows/testpackage.yaml create mode 100644 .github/workflows/testupm.yaml create mode 100644 .github/workflows/unity-tests-gate.yaml create mode 100644 .github/workflows/unity-tests-run.yaml create mode 100644 .github/workflows/verify-js-plugin.yaml diff --git a/.github/release-please/release-please-config.json b/.github/release-please/release-please-config.json index 69be73c..19a9359 100644 --- a/.github/release-please/release-please-config.json +++ b/.github/release-please/release-please-config.json @@ -1,7 +1,6 @@ { "include-component-in-tag": false, "include-v-in-tag": true, - "release-as": "1.5.5", "pull-request-title-pattern": "chore${scope}: release${component} ${version} [release-please]", "packages": { ".": { diff --git a/.github/workflows/build-sample-webgl.yaml b/.github/workflows/build-sample-webgl.yaml new file mode 100644 index 0000000..50ffb41 --- /dev/null +++ b/.github/workflows/build-sample-webgl.yaml @@ -0,0 +1,87 @@ +name: Build Sample WebGL + +on: + workflow_dispatch: + inputs: + sample: + description: Sample base name to build + required: true + type: choice + options: + - 2d-platformer + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + build-sample: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + lfs: true + + - name: Cache Unity Library + uses: actions/cache@v4 + with: + path: Library + key: Library-${{ runner.os }}-2022.3.62f3-${{ hashFiles('Packages/com.playroomkit.sdk/package.json', 'Packages/manifest.json', 'Packages/packages-lock.json') }} + restore-keys: | + Library-${{ runner.os }}-2022.3.62f3- + + - uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Resolve sample scene + run: | + case "${{ inputs.sample }}" in + 2d-platformer) + echo "SAMPLE_SCENE=Packages/com.playroomkit.sdk/Samples~/2d-platformer/2d-platformer.unity" >> $GITHUB_ENV + echo "SAMPLE_SCENE_GUID=cf82eec4c654cf44b89cec2a91afebd5" >> $GITHUB_ENV + ;; + *) + echo "Unknown sample: ${{ inputs.sample }}" + exit 1 + ;; + esac + echo "BUILD_OUTPUT=build/webgl/${{ inputs.sample }}" >> $GITHUB_ENV + + - name: Set build scenes + run: | + cat > ProjectSettings/EditorBuildSettings.asset < metaList - echo "Assets/Plugins.meta" >> metaList - echo "Assets/WebGLTemplates.meta" >> metaList - find Assets/PlayroomKit/ -name \*.meta >> metaList - find Assets/WebGLTemplates/ -name \*.meta >> metaList - echo metaList - - - run: mkdir output - - - name: Set release version ENV - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - - uses: pCYSl5EDgo/create-unitypackage@master + - uses: actions/setup-node@v4 with: - package-path: "output/playroomkit.unitypackage" - include-files: metaList + node-version: 20 + + - name: Pack UPM package + run: | + mkdir -p output + cd Packages/com.playroomkit.sdk + npm pack --pack-destination ../../output - - name: Release + - name: Upload UPM package to release uses: softprops/action-gh-release@v1 with: - draft: true - generate_release_notes: true - files: output/playroomkit.unitypackage + files: output/*.tgz diff --git a/.github/workflows/testpackage.yaml b/.github/workflows/testpackage.yaml deleted file mode 100644 index 5d1813b..0000000 --- a/.github/workflows/testpackage.yaml +++ /dev/null @@ -1,35 +0,0 @@ -name: Create Unity Package on release tag - -on: - [push, pull_request] - -jobs: - echo: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/checkout@v4 - - - run: | - echo "Assets/PlayroomKit.meta" > metaList - echo "Assets/Plugins.meta" >> metaList - echo "Assets/WebGLTemplates.meta" >> metaList - find Assets/PlayroomKit/ -name \*.meta >> metaList - find Assets/WebGLTemplates/ -name \*.meta >> metaList - echo metaList - - - run: mkdir output - - - name: Set release version ENV - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - - uses: pCYSl5EDgo/create-unitypackage@master - with: - package-path: 'output/playroomkit.unitypackage' - include-files: metaList - - - uses: actions/upload-artifact@v4 - with: - name: playroomkit.unitypackage - path: output/playroomkit.unitypackage diff --git a/.github/workflows/testupm.yaml b/.github/workflows/testupm.yaml new file mode 100644 index 0000000..c81e910 --- /dev/null +++ b/.github/workflows/testupm.yaml @@ -0,0 +1,38 @@ +name: Build UPM Package Artifact + +on: + push: + branches: + - main + paths: + - "Packages/com.playroomkit.sdk/**" + - "Tools/playroomkit-js/**" + pull_request: + paths: + - "Packages/com.playroomkit.sdk/**" + - "Tools/playroomkit-js/**" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + pack-upm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Pack UPM package + run: | + mkdir -p output + cd Packages/com.playroomkit.sdk + npm pack --pack-destination ../../output + + - uses: actions/upload-artifact@v4 + with: + name: com.playroomkit.sdk.tgz + path: output/*.tgz diff --git a/.github/workflows/unity-tests-gate.yaml b/.github/workflows/unity-tests-gate.yaml new file mode 100644 index 0000000..b9fcfe6 --- /dev/null +++ b/.github/workflows/unity-tests-gate.yaml @@ -0,0 +1,94 @@ +name: Unity Tests Gate + +on: + pull_request_target: + branches: [main] + types: [opened, reopened, synchronize, ready_for_review] + paths: + - "Packages/com.playroomkit.sdk/**/*.cs" + - "Packages/com.playroomkit.sdk/**/*.asmdef" + - "Packages/com.playroomkit.sdk/**/*.asmref" + - "Packages/com.playroomkit.sdk/**/*.unity" + +permissions: + contents: read + pull-requests: write + issues: write + +concurrency: + group: unity-tests-gate-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + mark-pending: + runs-on: ubuntu-latest + steps: + - name: Mark Unity tests as pending + uses: actions/github-script@v7 + with: + script: | + const pr = context.payload.pull_request; + const owner = context.repo.owner; + const repo = context.repo.repo; + const sha = pr.head.sha; + + const labelPending = "unity-test: pending"; + const labelPassed = "unity-test: passed"; + const labelFailed = "unity-test: failed"; + const commentTag = ""; + const body = [ + commentTag, + "### Unity EditMode Tests", + "Not run automatically for PRs.", + "Trigger manually (members/collaborators):", + "`/run-unity-tests`", + ].join("\n"); + + for (const label of [labelPassed, labelFailed]) { + try { + await github.rest.issues.removeLabel({ + owner, + repo, + issue_number: pr.number, + name: label, + }); + } catch (error) { + if (error.status !== 404) { + throw error; + } + } + } + + await github.rest.issues.addLabels({ + owner, + repo, + issue_number: pr.number, + labels: [labelPending], + }); + + const { data: comments } = await github.rest.issues.listComments({ + owner, + repo, + issue_number: pr.number, + per_page: 100, + }); + + const existing = comments.find((comment) => + comment.body && comment.body.includes(commentTag) + ); + + if (existing) { + await github.rest.issues.updateComment({ + owner, + repo, + comment_id: existing.id, + body, + }); + } else { + await github.rest.issues.createComment({ + owner, + repo, + issue_number: pr.number, + body, + }); + } diff --git a/.github/workflows/unity-tests-run.yaml b/.github/workflows/unity-tests-run.yaml new file mode 100644 index 0000000..30d7c1b --- /dev/null +++ b/.github/workflows/unity-tests-run.yaml @@ -0,0 +1,325 @@ +name: Unity EditMode Tests + +on: + issue_comment: + types: [created] + push: + branches: [main] + paths: + - "Packages/com.playroomkit.sdk/**/*.cs" + - "Packages/com.playroomkit.sdk/**/*.asmdef" + - "Packages/com.playroomkit.sdk/**/*.asmref" + - "Packages/com.playroomkit.sdk/**/*.unity" + - "Packages/com.playroomkit.sdk/package.json" + +concurrency: + group: unity-tests-${{ github.event.issue.number || github.ref }} + cancel-in-progress: true + +permissions: + contents: read + checks: write + pull-requests: write + issues: write + +jobs: + resolve-pr: + if: github.event_name == 'issue_comment' + runs-on: ubuntu-latest + outputs: + should_run: ${{ steps.resolve.outputs.should_run }} + pr_number: ${{ steps.resolve.outputs.pr_number }} + sha: ${{ steps.resolve.outputs.sha }} + head_repo: ${{ steps.resolve.outputs.head_repo }} + comment_id: ${{ steps.resolve.outputs.comment_id }} + steps: + - name: Resolve PR from comment + id: resolve + uses: actions/github-script@v7 + with: + script: | + const body = context.payload.comment.body || ""; + const command = "/run-unity-tests"; + if (!body.trim().startsWith(command)) { + core.setOutput("should_run", "false"); + return; + } + + if (!context.payload.issue.pull_request) { + core.setOutput("should_run", "false"); + return; + } + + const allowed = ["OWNER", "MEMBER", "COLLABORATOR"]; + if (!allowed.includes(context.payload.comment.author_association)) { + core.setOutput("should_run", "false"); + return; + } + + const owner = context.repo.owner; + const repo = context.repo.repo; + const prNumber = context.payload.issue.number; + const { data: pr } = await github.rest.pulls.get({ + owner, + repo, + pull_number: prNumber, + }); + + core.setOutput("should_run", "true"); + core.setOutput("pr_number", String(prNumber)); + core.setOutput("sha", pr.head.sha); + core.setOutput("head_repo", pr.head.repo.full_name); + core.setOutput("comment_id", String(context.payload.comment.id)); + + unity-tests-pr: + if: github.event_name == 'issue_comment' && needs.resolve-pr.outputs.should_run == 'true' + needs: resolve-pr + runs-on: ubuntu-latest + environment: unity-ci + steps: + - name: Mark Unity tests as running + uses: actions/github-script@v7 + with: + script: | + const owner = context.repo.owner; + const repo = context.repo.repo; + const sha = "${{ needs.resolve-pr.outputs.sha }}"; + const prNumber = Number("${{ needs.resolve-pr.outputs.pr_number }}"); + const commentId = Number("${{ needs.resolve-pr.outputs.comment_id }}"); + + const labelPending = "unity-test: pending"; + const labelPassed = "unity-test: passed"; + const labelFailed = "unity-test: failed"; + const commentTag = ""; + const body = [ + commentTag, + "### Unity EditMode Tests", + "**Status:** running", + "Triggered by a member/collaborator.", + ].join("\n"); + + await github.rest.reactions.createForIssueComment({ + owner, + repo, + comment_id: commentId, + content: "eyes", + }); + + for (const label of [labelPassed, labelFailed]) { + try { + await github.rest.issues.removeLabel({ + owner, + repo, + issue_number: prNumber, + name: label, + }); + } catch (error) { + if (error.status !== 404) { + throw error; + } + } + } + + await github.rest.issues.addLabels({ + owner, + repo, + issue_number: prNumber, + labels: [labelPending], + }); + + const { data: comments } = await github.rest.issues.listComments({ + owner, + repo, + issue_number: prNumber, + per_page: 100, + }); + + const existing = comments.find((comment) => + comment.body && comment.body.includes(commentTag) + ); + + if (existing) { + await github.rest.issues.updateComment({ + owner, + repo, + comment_id: existing.id, + body, + }); + } else { + await github.rest.issues.createComment({ + owner, + repo, + issue_number: prNumber, + body, + }); + } + + - uses: actions/checkout@v4 + with: + lfs: true + repository: ${{ needs.resolve-pr.outputs.head_repo }} + ref: ${{ needs.resolve-pr.outputs.sha }} + + - name: Run EditMode tests + uses: game-ci/unity-test-runner@v4 + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + with: + projectPath: Packages/com.playroomkit.sdk + packageMode: true + unityVersion: 2022.3.62f3 + testMode: editmode + artifactsPath: Assets/test-results + githubToken: ${{ github.token }} + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v4 + with: + name: unity-test-results + path: Assets/test-results + + - name: Publish test report + id: report + if: always() && hashFiles('Assets/test-results/editmode-results.xml') != '' + uses: dorny/test-reporter@v2 + continue-on-error: true + with: + name: EditMode Test Results + path: Assets/test-results/editmode-results.xml + reporter: dotnet-nunit + fail-on-error: true + + - name: Update PR status + if: always() + uses: actions/github-script@v7 + with: + script: | + const owner = context.repo.owner; + const repo = context.repo.repo; + const sha = "${{ needs.resolve-pr.outputs.sha }}"; + const prNumber = Number("${{ needs.resolve-pr.outputs.pr_number }}"); + const commentId = Number("${{ needs.resolve-pr.outputs.comment_id }}"); + const conclusion = "${{ job.status }}"; + const reportOutcome = "${{ steps.report.outcome }}"; + + const labelPending = "unity-test: pending"; + const labelPassed = "unity-test: passed"; + const labelFailed = "unity-test: failed"; + const commentTag = ""; + const statusLine = + conclusion === "success" + ? "Unity EditMode tests passed." + : "Unity EditMode tests failed."; + const runLink = `${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}`; + const reportLine = + reportOutcome && reportOutcome !== "success" + ? "Test report failed to publish." + : ""; + const body = [ + commentTag, + "### Unity EditMode Tests", + `**Status:** ${conclusion === "success" ? "passed" : "failed"}`, + statusLine, + reportLine, + `Run: ${runLink}`, + "Manual rerun: `/run-unity-tests`", + ].filter(Boolean).join("\n"); + + await github.rest.reactions.createForIssueComment({ + owner, + repo, + comment_id: commentId, + content: conclusion === "success" ? "hooray" : "confused", + }); + + try { + await github.rest.issues.removeLabel({ + owner, + repo, + issue_number: prNumber, + name: labelPending, + }); + } catch (error) { + if (error.status !== 404) { + throw error; + } + } + + await github.rest.issues.addLabels({ + owner, + repo, + issue_number: prNumber, + labels: [conclusion === "success" ? labelPassed : labelFailed], + }); + + const { data: comments } = await github.rest.issues.listComments({ + owner, + repo, + issue_number: prNumber, + per_page: 100, + }); + + const existing = comments.find((comment) => + comment.body && comment.body.includes(commentTag) + ); + + if (existing) { + await github.rest.issues.updateComment({ + owner, + repo, + comment_id: existing.id, + body, + }); + } else { + await github.rest.issues.createComment({ + owner, + repo, + issue_number: prNumber, + body, + }); + } + + + unity-tests-main: + if: github.event_name == 'push' + runs-on: ubuntu-latest + environment: unity-ci + steps: + - uses: actions/checkout@v4 + with: + lfs: true + + - name: Run EditMode tests + uses: game-ci/unity-test-runner@v4 + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + with: + projectPath: Packages/com.playroomkit.sdk + packageMode: true + unityVersion: 2022.3.62f3 + testMode: editmode + artifactsPath: Assets/test-results + githubToken: ${{ github.token }} + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v4 + with: + name: unity-test-results + path: Assets/test-results + + - name: Publish test report + id: report + if: always() && hashFiles('Assets/test-results/editmode-results.xml') != '' + uses: dorny/test-reporter@v2 + continue-on-error: true + with: + name: EditMode Test Results + path: Assets/test-results/editmode-results.xml + reporter: dotnet-nunit + fail-on-error: true diff --git a/.github/workflows/verify-js-plugin.yaml b/.github/workflows/verify-js-plugin.yaml new file mode 100644 index 0000000..d4256c5 --- /dev/null +++ b/.github/workflows/verify-js-plugin.yaml @@ -0,0 +1,41 @@ +name: Verify JS Plugin (PlayroomKit JS Wrapper) change synced to Unity Package + +on: + push: + branches: + - main + paths: + - "Tools/playroomkit-js/**" + - "Packages/com.playroomkit.sdk/Runtime/Plugins/Playroom/**" + pull_request: + paths: + - "Tools/playroomkit-js/**" + - "Packages/com.playroomkit.sdk/Runtime/Plugins/Playroom/**" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + verify-js-plugin: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Build JS plugin + run: npm ci + working-directory: Tools/playroomkit-js + + - name: Verify plugin output is up to date + run: | + git diff --name-only -- Packages/com.playroomkit.sdk/Runtime/Plugins/Playroom \ + | grep -v '\.meta$' \ + | tee /tmp/js-plugin-diff.txt + if [ -s /tmp/js-plugin-diff.txt ]; then + echo "JS plugin output is out of date." + exit 1 + fi