ecma262-compare icon indicating copy to clipboard operation
ecma262-compare copied to clipboard

Post comment or status to ecma262 PR

Open arai-a opened this issue 5 years ago • 9 comments

Post URL to ecma262 PR, after updating PR data

arai-a avatar Feb 14 '20 00:02 arai-a

There's issue about the delay, gh-pages doesn't update immediately after the push (takes ~10 minutes). So, posting the URL in the same job for updating PR history might be misleading.

arai-a avatar Mar 01 '20 22:03 arai-a

Requirement:

  • post at most once per each PR

Mild requirement:

  • do not post until gh-pages get deployed

arai-a avatar Mar 01 '20 22:03 arai-a

do not post until gh-pages get deployed

https://help.github.com/en/actions/reference/events-that-trigger-workflows#deployment-event-deployment

post at most once per each PR

Storing a JSON file that tracks it can solve. (It's better avoid accessing PR comments for it, because it consumes the access limit) but it should be stored in other branch than gh-pages, say pr-comments branch. (otherwise updating the JSON file triggers another deployment)

possible flow:

  1. Create pr-comments.json file with { "posted": [], "new": [] } content, in pr-comments branch
  2. When updating PR data:
    1. Let comments be the body of pr-comments.json
    2. Let prs be the list of PR numbers that has been updated
    3. Remove items from prs where comments.posted also contains
    4. Append prs to comments.new
    5. Write comments to pr-comments.json
    6. Commit and push to pr-comments branch
  3. When gh-pages gets deployed:
    1. Let comments be the body of pr-comments.json
    2. For each PR number prnum in comments.new:
      1. Post a comment to ecma262 PR prnum, with URL for the diff
    3. Append comments.new to comments.posted
    4. Let comments.new to []
    5. Write comments to pr-comments.json
    6. Commit and push to pr-comments branch

Here, check for comments.new should be done without cloning the repository, to avoid unnecessary traffic. and if comments.new isn't empty, clone it and do the remaining

arai-a avatar Mar 01 '20 23:03 arai-a

https://developer.github.com/v3/repos/contents/#create-or-update-a-file

this could be used to avoid clone even if comments.new isn't empty.

arai-a avatar Mar 01 '20 23:03 arai-a

https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#about-the-github_token-secret

The token's permissions are limited to the repository that contains your workflow. For more information

https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#permissions-for-the-github_token

~~Creating PR comment on ecma262 cannot be done with secrets.GITHUB_TOKEN. so we need encrypted PAT for ecma262 repository.~~

~~I guess adding a comment doesn't need PAT or any extra permission~~

arai-a avatar Mar 01 '20 23:03 arai-a

I got "Resource not accessible by integration" when posting comments to other repository. looks like it needs some kind of token

arai-a avatar Mar 02 '20 18:03 arai-a

Apparently, PAT for any user works.

arai-a avatar Mar 02 '20 19:03 arai-a

listening to deployment doesn't work, even for manual push to gh-pages. I'll try just post comment immediately

arai-a avatar Mar 02 '20 20:03 arai-a

Currently posting to https://github.com/arai-a/workflow-test/pull/2

arai-a avatar Mar 07 '20 09:03 arai-a