Skip to content

"No scope" warning for pull request closed events #129

Closed

Description

@SatheeshJM

I get the warning No scopes with read permission were found on the request. if I setup my workflow for triggering on pull request: close.
If I change the trigger to push, it works.

Is the problem that the head_branch of the Pull Request can't read/write to the master's cache?

An example config

on:
  pull_request:
    types: 
      - closed
    branches: 
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        ref: master
        fetch-depth: 1
    - name: Cache node modules
      id: cache_node_modules
      uses: actions/cache@v1
      with: 
        path: node_modules
        key: ${{ runner.os }}-node-${{ hashFiles('package.json') }}

for the above config the cache is never used.. I get the below warning
image

If I tweak the workflow to trigger on branch push, all is well

on:
  push:
    branches: 
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        ref: master
        fetch-depth: 1
    - name: Cache node modules
      id: cache_node_modules
      uses: actions/cache@v1
      with: 
        path: node_modules
        key: ${{ runner.os }}-node-${{ hashFiles('package.json') }}

image

Activity

  1. joshmgross commented on Dec 13, 2019

    @joshmgross
    Contributor

    Is the problem that the head_branch of the Pull Request can't read/write to the master's cache?

    Yep! You'll need to trigger off of a push event to write to the default branch's cache.

  2. SatheeshJM commented on Dec 14, 2019

    @SatheeshJM
    Author

    Ah. But I need my action to trigger on a pull_request event.

    Restricting write makes sense. But reads too?
    From the docs

    Example of search priority
    key:
      npm-feature-d5ea0750
    restore-keys: |
      npm-feature-
      npm-
    For example, if a pull request contains a feature branch (the current scope) and targets the default branch (master), the action searches for key and restore-keys in the following order:
    
    Key npm-feature-d5ea0750 in the feature branch scope
    Key npm-feature- in the feature branch scope
    Key npm- in the feature branch scope
    Key npm-feature-d5ea0750 in the master branch scope
    Key npm-d5ea0750 in the master branch scope
    Key npm in the master branch scope
    

    Doesn't ☝️ imply that a feature branch would be able to read cache which is in the scope of the master branch?

  3. SatheeshJM commented on Dec 15, 2019

    @SatheeshJM
    Author

    Even if I save master cache during a push event (like mentioned here #79 (comment)), my pull event is not able to read the master cache.

  4. chemitaxis commented on Dec 15, 2019

    @chemitaxis

    Can you add @joshmgross to the documentation what events have scope? On "deployment" event does not work either...

  5. SatheeshJM commented on Dec 17, 2019

    @SatheeshJM
    Author

    @joshmgross any thoughts?
    Essentially my branch is not able to access the default branch scoped cache

  6. joshmgross commented on Dec 17, 2019

    @joshmgross
    Contributor

    @SatheeshJM the issue is a mix of scopes and how we determine which events to give write and read access.
    For PRs, we validate that the ref is in the form that we expect refs/pulls... (i.e. it's a pull request branch). Since this is a PR Close event and you're not seeing cache permissions, I'd expect this ref to be in some other form.

    Can you add @joshmgross to the documentation what events have scope? On "deployment" event does not work either...

    Documentation is here: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache

    You can only access the cache in workflows triggered by push and pull_request events.

    We may have to modify to specify which types of pull_request events are supported.

    On "deployment" event does not work either...

    Tracking that with #63

  7. SatheeshJM commented on Dec 20, 2019

    @SatheeshJM
    Author

    So are you saying the default branch's cache will be accessible from other PR events, but PR-close event won't have access, because the ref will be different?
    @joshmgross

  8. joshmgross commented on Dec 20, 2019

    @joshmgross
    Contributor

    @SatheeshJM that's the current behavior yes.

  9. Duckle29 commented on Feb 12, 2020

    @Duckle29

    An update of the docs for that would be nice, as this is currently the only place this behavior is documented :)

  10. klapec commented on Feb 21, 2020

    @klapec

    I'm getting the same error when doing a re-run by clicking the "re-run checks" button after a failed run. Is there anything I can do here?

  11. added
    documentation
    enhancement
    on Feb 21, 2020
  12. joshmgross commented on Feb 21, 2020

    @joshmgross
    Contributor

    An update of the docs for that would be nice, as this is currently the only place this behavior is documented :)

    Yep we can get this documented.

    I'm getting the same error when doing a re-run by clicking the "re-run checks" button after a failed run. Is there anything I can do here?

    What event was your original run? Did it work with caching?
    If you have a link to the run that would be helpful

  13. klapec commented on Feb 22, 2020

    @klapec

    I can't share the link directly as it is a private repo, but here are the logs for the job that fetches the NPM deps and caches them: https://gist.github.com/klapec/3d62182192afdb29d72142a008b95a02
    and here are the logs for the job that's supposed to build the application (and it obviously fails because the dependencies were not loaded from the cache):
    https://gist.github.com/klapec/41a988381d1f58e2baa727eca51e2b6a

  14. daniel-white commented on Feb 28, 2020

    @daniel-white

    @joshmgross why is a read forbidden? its not mutating things. i have an upstream provider that has been really flaky as of late and the cache saves me lots of breaks.

  15. jcornaz commented on Mar 6, 2020

    @jcornaz

    So if I understand well we cannot use actions/cache for pull requests?

  16. joshmgross commented on Mar 6, 2020

    @joshmgross
    Contributor

    So if I understand well we cannot use actions/cache for pull requests?

    No that is not correct. All pull_request events work except for the closed type. By default, this event will not trigger workflows. See https://help.github.com/en/actions/reference/events-that-trigger-workflows#pull-request-event-pull_request

  17. changed the title [-]"No scope" warning for pull request event[/-] [+]"No scope" warning for pull request closed events[/+] on Mar 6, 2020
  18. jcornaz commented on Mar 6, 2020

    @jcornaz

    Ok. Thanks @joshmgross.

    So if all pull_request events are supposed to work, there is a problem. I opened an issue for it: #208.

  19. joshmgross commented on May 29, 2020

    @joshmgross
    Contributor

    The issue of pull request re-runs has been fixed, see #208 for details.

    With V2 of this action, all events with a GitHub ref are supported, so this issue should now be fixed. See https://github.com/actions/cache#whats-new for more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions