8000 CI: Add PR write permissions to artifact redirector. by rossbar · Pull Request #22567 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

CI: Add PR write permissions to artifact redirector. #22567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

rossbar
Copy link
Contributor
@rossbar rossbar commented Nov 9, 2022

Re-enable the circleci artifact redirector action which was disabled when permissions were added to the workflow. Note: permissions added at the job level rather than the workflow level reflecting recommended security practices.

I'm not exactly sure which permissions are required, @larsoner any ideas here? The github docs on workflow permissions are here.

Re-enable the circleci artifact redirector action which was disabled
when permissions were added to the workflow. Note: permissions added
at the job level rather than the workflow level reflecting recommended
security practices.

[skip github] [skip travis] [skip azp]
@mattip
Copy link
Member
mattip commented Nov 9, 2022

Thanks @rossbar, let's give it a try

@mattip mattip merged commit 6aacc51 into numpy:main Nov 9, 2022
@larsoner
Copy link
Contributor

Looking at #22566 it looks like it didn't work, right?

Might be worth enabling debugging to see what the problem is

@larsoner
Copy link
Contributor

@seberg
Copy link
Member
seberg commented Nov 10, 2022

tried close/reopen there, but should probably wait for the next PR coming in (or open a dummy one for testing). That one is older than this one.

@rossbar
Copy link
Contributor Author
rossbar commented Nov 10, 2022

Might be worth enabling debugging to see what the problem is

This is a good suggestion. Unfortunately setting up debug logging requires access to the repo secrets which I don't have permissions for. Maybe @mattip or @seberg can give it a shot.

@seberg
Copy link
Member
seberg commented Nov 10, 2022

I guess the log is this, but not helpful?

[@octokit/rest] `const Octokit = require("@octokit/rest")` is deprecated. Use `const { Octokit } = require("@octokit/rest")` instead
[8](https://github.com/numpy/numpy/actions/runs/3438627024/jobs/5734926752#step:2:9)

[9](https://github.com/numpy/numpy/actions/runs/3438627024/jobs/5734926752#step:2:10)
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
[10](https://github.com/numpy/numpy/actions/runs/3438627024/jobs/5734926752#step:2:11)
(node:1524) UnhandledPromiseRejectionWarning: HttpError: Resource not accessible by integration
[11](https://github.com/numpy/numpy/actions/runs/3438627024/jobs/5734926752#step:2:12)
    at /home/runner/work/_actions/larsoner/circleci-artifacts-redirector-action/master/dist/index.js:26670:21
[12](https://github.com/numpy/numpy/actions/runs/3438627024/jobs/5734926752#step:2:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
[13](https://github.com/numpy/numpy/actions/runs/3438627024/jobs/5734926752#step:2:14)
(node:1524) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
[14](https://github.com/numpy/numpy/actions/runs/3438627024/jobs/5734926752#step:2:15)
(node:1524) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Do you really have to add that secret for all workflows?

@larsoner
Copy link
Contributor

Nowadays via the GitHub UI you can also individually run failed workflows with debugging turned on after they fail I think

Maybe the

    permissions:
      pull-requests: write

is not broad enough? on_status runs in the main branch, so it might need broader repo-wide permissions 😨

@seberg
Copy link
Member
seberg commented Nov 10, 2022

@larsoner the workflow doesn't seem to fail? It just doesn't show up?

@seberg
Copy link
Member
seberg commented Nov 10, 2022

Ah, there is a debug button in the rerun though, so here you go (can't say I see anything suspicious):

2022-11-10T18:37:24.2017852Z Requested labels: ubuntu-latest
2022-11-10T18:37:24.2017908Z Job defined at: numpy/numpy/.github/workflows/circleci.yml@refs/heads/main
2022-11-10T18:37:24.2017939Z Waiting for a runner to pick up this job...
2022-11-10T18:37:24.4908518Z Job is waiting for a hosted runner to come online.
2022-11-10T18:37:26.9702358Z Job is about to start running on the hosted runner: Hosted Agent (hosted)
2022-11-10T18:37:29.1513364Z ##[debug]Starting: Run CircleCI artifacts redirector
2022-11-10T18:37:29.1538608Z ##[debug]Cleaning runner temp folder: /home/runner/work/_temp
2022-11-10T18:37:29.1876032Z ##[debug]Starting: Set up job
2022-11-10T18:37:29.1876448Z Current runner version: '2.299.1'
2022-11-10T18:37:29.1900216Z ##[group]Operating System
2022-11-10T18:37:29.1900661Z Ubuntu
2022-11-10T18:37:29.1900956Z 20.04.5
2022-11-10T18:37:29.1901238Z LTS
2022-11-10T18:37:29.1901573Z ##[endgroup]
2022-11-10T18:37:29.1901901Z ##[group]Runner Image
2022-11-10T18:37:29.1902272Z Image: ubuntu-20.04
2022-11-10T18:37:29.1902601Z Version: 20221027.1
2022-11-10T18:37:29.1903071Z Included Software: https://github.com/actions/runner-images/blob/ubuntu20/20221027.1/images/linux/Ubuntu2004-Readme.md
2022-11-10T18:37:29.1903761Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu20%2F20221027.1
2022-11-10T18:37:29.1904216Z ##[endgroup]
2022-11-10T18:37:29.1904515Z ##[group]Runner Image Provisioner
2022-11-10T18:37:29.1904853Z 2.0.91.1
2022-11-10T18:37:29.1905335Z ##[endgroup]
2022-11-10T18:37:29.1905973Z ##[group]GITHUB_TOKEN Permissions
2022-11-10T18:37:29.1906573Z Metadata: read
2022-11-10T18:37:29.1906927Z PullRequests: write
2022-11-10T18:37:29.1907227Z ##[endgroup]
2022-11-10T18:37:29.1910788Z Secret source: Actions
2022-11-10T18:37:29.1911317Z ##[debug]Primary repository: numpy/numpy
2022-11-10T18:37:29.1911686Z Prepare workflow directory
2022-11-10T18:37:29.1989164Z ##[debug]Creating pipeline directory: '/home/runner/work/numpy'
2022-11-10T18:37:29.1991795Z ##[debug]Creating workspace directory: '/home/runner/work/numpy/numpy'
2022-11-10T18:37:29.1992862Z ##[debug]Update context data
2022-11-10T18:37:29.1995425Z ##[debug]Evaluating job-level environment variables
2022-11-10T18:37:29.2670024Z ##[debug]Evaluating job container
2022-11-10T18:37:29.2674021Z ##[debug]Evaluating job service containers
2022-11-10T18:37:29.2676884Z ##[debug]Evaluating job defaults
2022-11-10T18:37:29.2750757Z Prepare all required actions
2022-11-10T18:37:29.2933944Z Getting action download info
2022-11-10T18:37:29.5968367Z Download action repository 'larsoner/circleci-artifacts-redirector-action@master' (SHA:6f28ccae9bc210ecdda6d0533ad4bbda4f0b1d36)
2022-11-10T18:37:29.8407009Z ##[debug]Download 'https://api.github.com/repos/larsoner/circleci-artifacts-redirector-action/tarball/6f28ccae9bc210ecdda6d0533ad4bbda4f0b1d36' to '/home/runner/work/_actions/_temp_d86afe51-1bfe-4b74-bcbd-d791380ecf69/373bb5c7-9c2b-4d40-ba77-0cfe497af69e.tar.gz'
2022-11-10T18:37:29.9589070Z ##[debug]Unwrap 'larsoner-circleci-artifacts-redirector-action-6f28cca' to '/home/runner/work/_actions/larsoner/circleci-artifacts-redirector-action/master'
2022-11-10T18:37:29.9648372Z ##[debug]Archive '/home/runner/work/_actions/_temp_d86afe51-1bfe-4b74-bcbd-d791380ecf69/373bb5c7-9c2b-4d40-ba77-0cfe497af69e.tar.gz' has been unzipped into '/home/runner/work/_actions/larsoner/circleci-artifacts-redirector-action/master'.
2022-11-10T18:37:29.9824567Z ##[debug]action.yml for action: '/home/runner/work/_actions/larsoner/circleci-artifacts-redirector-action/master/action.yml'.
2022-11-10T18:37:30.0635616Z ##[debug]Set step '__larsoner_circleci-artifacts-redirector-action' display name to: 'GitHub Action step'
2022-11-10T18:37:30.0643135Z ##[debug]Collect running processes for tracking orphan processes.
2022-11-10T18:37:30.1060535Z ##[debug]Finishing: Set up job
2022-11-10T18:37:30.1274945Z ##[debug]Evaluating condition for step: 'GitHub Action step'
2022-11-10T18:37:30.1432747Z ##[debug]Evaluating: success()
2022-11-10T18:37:30.1439234Z ##[debug]Evaluating success:
2022-11-10T18:37:30.1468876Z ##[debug]=> true
2022-11-10T18:37:30.1476056Z ##[debug]Result: true
2022-11-10T18:37:30.1518230Z ##[debug]Starting: GitHub Action step
2022-11-10T18:37:30.1720878Z ##[debug]Loading inputs
2022-11-10T18:37:30.1767390Z ##[debug]Evaluating: secrets.GITHUB_TOKEN
2022-11-10T18:37:30.1768418Z ##[debug]Evaluating Index:
2022-11-10T18:37:30.1770490Z ##[debug]..Evaluating secrets:
2022-11-10T18:37:30.1771555Z ##[debug]..=> Object
2022-11-10T18:37:30.1785998Z ##[debug]..Evaluating String:
2022-11-10T18:37:30.1786781Z ##[debug]..=> 'GITHUB_TOKEN'
2022-11-10T18:37:30.1791200Z ##[debug]=> '***'
2022-11-10T18:37:30.1793198Z ##[debug]Result: '***'
2022-11-10T18:37:30.1804961Z ##[debug]Loading env
2022-11-10T18:37:30.1897011Z ##[group]Run larsoner/circleci-artifacts-redirector-action@master
2022-11-10T18:37:30.1897526Z with:
2022-11-10T18:37:30.1898097Z   repo-token: ***
2022-11-10T18:37:30.1898431Z   artifact-path: 0/doc/build/html/index.html
2022-11-10T18:37:30.1898775Z   circleci-jobs: build
2022-11-10T18:37:30.1899071Z ##[endgroup]
2022-11-10T18:37:30.4406071Z [@octokit/rest] `const Octokit = requ
8000
ire("@octokit/rest")` is deprecated. Use `const { Octokit } = require("@octokit/rest")` instead
2022-11-10T18:37:30.4650997Z ##[debug]18:37:30 GMT+0000 (Coordinated Universal Time)
2022-11-10T18:37:30.4653296Z ##[debug]Considering CircleCI jobs named: ci/circleci: build
2022-11-10T18:37:30.4653798Z ##[debug]context:    ci/circleci: build
2022-11-10T18:37:30.4654408Z ##[debug]state:      pending
2022-11-10T18:37:30.4655014Z ##[debug]target_url: https://circleci.com/gh/numpy/numpy/28558
2022-11-10T18:37:30.4655470Z ##[debug]org:   numpy
2022-11-10T18:37:30.4655850Z ##[debug]repo:  numpy
2022-11-10T18:37:30.4656223Z ##[debug]build: 28558
2022-11-10T18:37:30.4656702Z ##[debug]Fetching JSON: https://circleci.com/api/v2/project/gh/numpy/numpy/28558/artifacts
2022-11-10T18:37:30.6987373Z ##[debug]Artifacts JSON:
2022-11-10T18:37:30.6989756Z [@octokit/rest] `const Octokit = require("@octokit/rest")` is deprecated. Use `const { Octokit } = require("@octokit/rest")` instead
2022-11-10T18:37:30.6990370Z ##[debug]{"next_page_token":null,"items":[]}
2022-11-10T18:37:30.6991357Z ##[debug]Linking to: https://circleci.com/gh/numpy/numpy/28558
2022-11-10T18:37:30.6992309Z ##[debug]18:37:30 GMT+0000 (Coordinated Universal Time)
2022-11-10T18:37:30.6992689Z 
2022-11-10T18:37:30.6997528Z ::set-output name=url::https://circleci.com/gh/numpy/numpy/28558
2022-11-10T18:37:30.7009232Z ##[warning]The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
2022-11-10T18:37:30.7018758Z ##[debug]='https://circleci.com/gh/numpy/numpy/28558'
2022-11-10T18:37:30.8243597Z (node:1571) UnhandledPromiseRejectionWarning: HttpError: Resource not accessible by integration
2022-11-10T18:37:30.8244606Z     at /home/runner/work/_actions/larsoner/circleci-artifacts-redirector-action/master/dist/index.js:26670:21
2022-11-10T18:37:30.8245277Z     at processTicksAndRejections (internal/process/task_queues.js:97:5)
2022-11-10T18:37:30.8288548Z (node:1571) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
2022-11-10T18:37:30.8290199Z (node:1571) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2022-11-10T18:37:30.8326572Z ##[debug]Node Action run completed with exit code 0
2022-11-10T18:37:30.8452510Z ##[debug]Finishing: GitHub Action step
2022-11-10T18:37:30.8570035Z ##[debug]Starting: Complete job
2022-11-10T18:37:30.8571701Z Uploading runner diagnostic logs
2022-11-10T18:37:30.8856961Z ##[debug]Starting diagnostic file upload.
2022-11-10T18:37:30.8857325Z ##[debug]Setting up diagnostic log folders.
2022-11-10T18:37:30.8859905Z ##[debug]Creating diagnostic log files folder.
2022-11-10T18:37:30.8880230Z ##[debug]Copying 1 worker diagnostic logs.
2022-11-10T18:37:30.8898214Z ##[debug]Copying 1 runner diagnostic logs.
2022-11-10T18:37:30.8899835Z ##[debug]Zipping diagnostic files.
2022-11-10T18:37:30.8938966Z ##[debug]Uploading diagnostic metadata file.
2022-11-10T18:37:30.8973798Z ##[debug]Diagnostic file upload complete.
2022-11-10T18:37:30.8974422Z Completed runner diagnostic log upload
2022-11-10T18:37:30.8974680Z Cleaning up orphan processes
2022-11-10T18:37:30.9308366Z ##[debug]Finishing: Complete job
2022-11-10T18:37:30.9432517Z ##[debug]Finishing: Run CircleCI artifacts redirector

@larsoner
Copy link
Contributor

the workflow doesn't seem to fail? It just doesn't show up?

By "it" in the "doesn't show up", you mean the status update pointing to the artifact? I think this implies that it is failing in some way, even if the action shows up green in your list. In particular I'm worried about this stuff:

2022-11-10T18:37:30.8243597Z (node:1571) UnhandledPromiseRejectionWarning: HttpError: Resource not accessible by integration
2022-11-10T18:37:30.8244606Z     at /home/runner/work/_actions/larsoner/circleci-artifacts-redirector-action/master/dist/index.js:26670:21
2022-11-10T18:37:30.8245277Z     at processTicksAndRejections (internal/process/task_queues.js:97:5)
2022-11-10T18:37:30.8288548Z (node:1571) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
2022-11-10T18:37:30.8290199Z (node:1571) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2022-11-10T18:37:30.8326572Z ##[debug]Node Action run completed with exit code 0

https://github.com/larsoner/circleci-artifacts-redirector-action/blob/master/dist/index.js#L26670

To me this looks like it tried to post the request to make a status update and it was rejected, but node did not raise an error so the action completes "successfully". See for example actions/first-interaction#10. This is why I think it might still be a permissions issue...

@seberg
Copy link
Member
seberg commented Nov 10, 2022

Yes, I mean it shows as green and run successful in the logs, but "doesn't show up" in the PR status.

OK, that makes sense... then I guess it is more trial and error about the permissions...

@larsoner
Copy link
Contributor

FWIW I haven't had to do this for other repos like MNE-Python. But maybe your actions permissions are by default more strict somehow?

@rossbar
Copy link
Contributor Author
rossbar commented Nov 10, 2022

FWIW I haven't had to do this for other repos like MNE-Python. But maybe your actions permissions are by default more strict somehow?

Yeah there was a recent PR #22367 to add permissions to workflows as a general security best-practice, though this may also be part of the new OpenSSF scorecard (#22482) as well.

In any case - in the short term we could get the redirector action back by removing the permissions from the workflow entirely (as was done temporarily for the labeler action).

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

Successfully merging this pull request may close these issues.

4 participants
0