ubiquity-os / ubiquity-os-kernel

1 stars 13 forks source link

Support calling specific plugin branch #53

Closed rndquu closed 3 months ago

rndquu commented 3 months ago

Check this config which is meant to call the pull/1 branch of the https://github.com/rndquu/user-activity-watcher plugin via github actions.

The kernel throws this error for the above config:

response: {
      url:
  'https://api.github.com/repos/rndquu/user-activity-watcher/actions/workflows/compute.yml/dispatches',
      status: 404,
      headers: {
        'access-control-allow-origin': '*',
        'access-control-expose-headers': 'ETag, Link, Location, Retry-After,
  X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource,
  X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type,
  X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
        'content-length': '140',
        'content-security-policy': "default-src 'none'",
        'content-type': 'application/json; charset=utf-8',
        date: 'Mon, 10 Jun 2024 19:34:29 GMT',
        'referrer-policy': 'origin-when-cross-origin,
  strict-origin-when-cross-origin',
        server: 'GitHub.com',
        'strict-transport-security': 'max-age=31536000; includeSubdomains;
  preload',
        vary: 'Accept-Encoding, Accept, X-Requested-With',
        'x-accepted-github-permissions': 'actions=write',
        'x-content-type-options': 'nosniff',
        'x-frame-options': 'deny',
        'x-github-api-version-selected': '2022-11-28',
        'x-github-media-type': 'github.v3; format=json',
        'x-github-request-id': '09B7:2577A1:ADBA2C:AE93DA:66675545',
        'x-ratelimit-limit': '5550',
        'x-ratelimit-remaining': '5549',
        'x-ratelimit-reset': '1718051669',
        'x-ratelimit-resource': 'core',
        'x-ratelimit-used': '1',
        'x-xss-protection': '0'
      },
      data: {
        message: 'Not Found',
        documentation_url:
  'https://docs.github.com/rest/actions/workflows#create-a-workflow-dispatch-event',
        status: '404'
      }
    }

It seems that the kernel doesn't support calling a specific branch of the plugin which is really useful for QA.

What should be done:

rndquu commented 3 months ago

@gentlementlegen @whilefoo Pls check the description. Not sure if the issue is relevant, perhaps there is another way to call a specific branch of a plugin.

gentlementlegen commented 3 months ago

Thank you for the details. It is likely that the parser we made to extract the repo / owner / branch / version doesn't support your test case which results in the plugin not being found. Will have a look.

gentlementlegen commented 3 months ago

@rndquu So I replicated your test case by having a pull/1 branch in my repository, and calling it with the following configuration

plugins:
  '*':
    - uses:
      - plugin: gentlementlegen/user-activity-watcher:compute.yml@pull/1
        type: github
        with:
          unassignUserThreshold: 0.003473
          sendRemindersThreshold: 0.000695

Which resulted in the workflow running as expected: https://github.com/gentlementlegen/user-activity-watcher/actions/runs/9479416128

Also tested within an org: https://github.com/Meniole/user-activity-watcher/actions/runs/9479199313

I still added a test case in the linked PR to make sure this pattern is properly parsed. The only time I had a not found error is when my main branch did not contain the Workflow, because even if the pull/1 branch does contain it, if it is not present in the default branch and it seems that GitHub cannot run it, which might have been your case? Or, it has been fixed through my last PR to parse Org configurations. If you could give it another run with the latest version, would be appreciated.

ubiquibot[bot] commented 3 months ago
! No price label has been set. Skipping permit generation.
rndquu commented 3 months ago

@rndquu So I replicated your test case by having a pull/1 branch in my repository, and calling it with the following configuration

plugins:
  '*':
    - uses:
      - plugin: gentlementlegen/user-activity-watcher:compute.yml@pull/1
        type: github
        with:
          unassignUserThreshold: 0.003473
          sendRemindersThreshold: 0.000695

Which resulted in the workflow running as expected: https://github.com/gentlementlegen/user-activity-watcher/actions/runs/9479416128

Also tested within an org: https://github.com/Meniole/user-activity-watcher/actions/runs/9479199313

I still added a test case in the linked PR to make sure this pattern is properly parsed. The only time I had a not found error is when my main branch did not contain the Workflow, because even if the pull/1 branch does contain it, if it is not present in the default branch and it seems that GitHub cannot run it, which might have been your case? Or, it has been fixed through my last PR to parse Org configurations. If you could give it another run with the latest version, would be appreciated.

You're right, it seems that everything worked as expected initially and I just misconfigured something. I've double checked the latest kernel and specific branches are called as expected. @gentlementlegen Thank you for your time and effort.