game-ci / unity-test-runner

Run tests for any Unity project
https://github.com/marketplace/actions/unity-test-runner
MIT License
206 stars 135 forks source link

Reasource not Available by Integration #249

Closed JackatDJL closed 8 months ago

JackatDJL commented 10 months ago

Bug description Hello People of Game-CI i would like some help: i keep geting a error: Resource not Available by Integration Log at the bottom

Thank you in front

How to reproduce

  1. Copy my Ci.yaml
  2. Test a Project
  3. Get a Error

Expected behavior

Testing The Project

Additional details

My CI.yaml:

name: Automatic CI 🤖

env:
  UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}

on:
  pull_request:
  workflow_dispatch:

jobs:
  testRunner:
    name: Test in ${{ matrix.testMode }} ✨
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        testMode:
          - EditMode
          - PlayMode
    steps:
      - name: Checkout code ✅
        uses: actions/checkout@v4

      - name: Create LFS file list 📜
        run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id

      - name: Restore LFS cache 🔄
        uses: actions/cache@v3
        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
      - name: Restore Library cache 🔄
        uses: actions/cache@v3
        with:
          path: Library
          key: Library-test-project-${{ matrix.targetPlatform }}
          restore-keys: |
            Library-test-project-
            Library-

      - name: Run ${{ matrix.testMode }} Tests ⏯ 📑
        id: runningTest
        uses: game-ci/unity-test-runner@v3.1.0
        with:
          projectPath: ${{ vars.projectPath }}
          testMode: ${{ matrix.testMode }}
          checkName: ${{ matrix.testMode }} test results
          githubToken: ${{ secrets.GITHUB_TOKEN }}

      # Upload artifacts
      - name: Upload Artifact 📦
        uses: actions/upload-artifact@v3
        with:
          name: Test results (${{ matrix.testMode }}) 📑
          path: ${{ steps.runningTest.outputs.artifactsPath }}

Log: Pastebin

GabLeRoux commented 10 months ago

This is exactly related to the following StackOverflow: https://stackoverflow.com/questions/70435286/resource-not-accessible-by-integration-on-github-post-repos-owner-repo-ac

This happens because the pipeline doesn't have the right to publish the report for the tests.

A quick fix is to go in project's settings > Workflow Permissions section and give actions Read and Write permissions.

GabLeRoux commented 8 months ago

Closing this as I'm quite sure the answer solves the issue. I've encountered this a few times and this was the solution.

shloon commented 8 months ago

Hi, a better fix is to explicitly add the required permissions to the job using this action, e.g.:

jobs:
  test:
    permissions:
      checks: write
...
    steps:
      - name: Run Tests
        uses: game-ci/unity-test-runner@v4

You can see that in action in my own repo here: https://github.com/shloon/Event-Horizon/blob/b13d2c16be65e5ce1b6fc0e0fd3bbf4bab9ec434/.github/workflows/ci.yml#L8

I think it's worth adding to the documentation at the very least.

GabLeRoux commented 8 months ago

💯 oh, agreed, @shloon if you'd like to open a PR for this in the docs, it would be very nice 🙏 Edit: created issue here: https://github.com/game-ci/documentation/issues/443

JackatDJL commented 8 months ago

It worked, Thank you :)