scientific-python / circleci-artifacts-redirector-action

GitHub Action to add a GitHub status link to a CircleCI artifact.
MIT License
14 stars 8 forks source link

Error: Cannot read properties of undefined (reading 'length') #40

Closed jarrodmillman closed 1 year ago

jarrodmillman commented 1 year ago

This looks related to #38. About 5 days ago, this error started showing up again:

rflamary commented 1 year ago

We are also getting here

https://github.com/PythonOT/POT/actions/runs/4661515618

QuLogic commented 1 year ago

Also in Matplotlib: https://github.com/matplotlib/matplotlib/actions/runs/4664564800/jobs/8256939430

larsoner commented 1 year ago

Uh oh 😱 I'll try to look soon but if anyone has ideas or wants to try in the meantime feel free...

larsoner commented 1 year ago

From MNE-Python see:

https://github.com/mne-tools/mne-python/actions/runs/4670258124/jobs/8269763706

##[debug]Considering CircleCI jobs named: ci/circleci: build_docs,ci/circleci: build_docs_main
##[debug]context:    ci/circleci: build_docs
##[debug]state:      pending
##[debug]target_url: https://circleci.com/gh/mne-tools/mne-python/538[26](https://github.com/mne-tools/mne-python/actions/runs/4670258124/jobs/8269763706#step:2:27)
##[debug]org:   mne-tools
##[debug]repo:  mne-python
##[debug]build: 53826
##[debug]Fetching JSON: https://circleci.com/api/v2/project/gh/mne-tools/mne-python/53826/artifacts
##[debug]Artifacts JSON (status=404):
##[debug]{"message":"Job not found."}

Looks like #38 was "bad request" and this is "Job not found" so... that's something.

larsoner commented 1 year ago

... and looking at

https://circleci.com/api/v2/project/gh/mne-tools/mne-python/53826/artifacts

myself does not work. This always at least used to work for me in my web browser given my login credentials etc. This seems like a bug at the CircleCI end. I'll see if I can open a support bug report with them.

larsoner commented 1 year ago

... okay no, it is another access problem. I even added a api-token and it still fails in https://github.com/larsoner/circleci-artifacts-redirector-action/pull/41 even though this URL works fine for me in my browser given my CircleCI permissions:

https://circleci.com/api/v2/project/gh/larsoner/circleci-artifacts-redirector-action/202/artifacts

So somehow when GitHub tries to load this URL it gets a 404, when I load it in Chrome I get the correct JSON:

{
    "next_page_token": null,
    "items": [
        {
            "path": "test_artifacts/root_artifact.md",
            "node_index": 0,
            "url": "https://output.circle-artifacts.com/output/job/08a1256b-8142-4bf5-93dc-b1dd392f5a56/artifacts/0/test_artifacts/root_artifact.md"
        }
    ]
}

So this will require a bit more debugging at our end I think. Next step is probably to look at what headers Chrome is sending vs trying curl or something directly. I did something like this in #38.

larsoner commented 1 year ago

Argh, okay the token must be a personal API token, not a project token at the CircleCI end as those aren't supported yet.

  1. You can create a personal CircleCI token here (I named mine CIRCLE_STATUS): https://app.circleci.com/settings/user/tokens
  2. Add the token value (from the CircleCI website) it to the secrets of your org or project, e.g., for MNE-Python I added it under the name CIRCLE_TOKEN for the org to https://github.com/organizations/mne-tools/settings/secrets/actions
  3. Add it to the action as api-token: ${{ secrets.CIRCLECI_TOKEN }} in the with for the action

I'll close but feel free to comment if this doesn't work and we can investigate further!

jschueller commented 1 year ago

I think this is working again with your recommendations, thanks!

larsoner commented 1 year ago

Great! And norry for the hassle, CircleCI's API just seems to be a bit of moving target :(

rflamary commented 1 year ago

Hello @larsoner thanks for the fix, it does work on POT (https://github.com/PythonOT/POT/pull/460) but it still fails in some cases.

Since the token is a secret it will not run for PR from oher repos where we need to look at the artifact the most. Are there any ways to make this work?

QuLogic commented 1 year ago

The workflow runs on status events, which should still be posted on your main repo as long as the forks have PRs out of them.

rflamary commented 1 year ago

Thanks @QuLogic for the explanation, it makes sens. But then I have no idea why a few worked and now everything is failing : https://github.com/PythonOT/POT/actions/workflows/circleci-redirector.yml

rflamary commented 1 year ago

OK I found my bug sorry for bothering you all and again thank to @larsoner for this extremely usefull action!