Skip to content
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

does-not-run-on: GitHub Enterprise plan #81

Open
Freubert opened this issue Jun 13, 2024 · 5 comments · Fixed by #82
Open

does-not-run-on: GitHub Enterprise plan #81

Freubert opened this issue Jun 13, 2024 · 5 comments · Fixed by #82

Comments

@Freubert
Copy link

Our setup suddenly breaks on display-results task with following error. I'm not sure, but we recently changed our plan to GitHub Enterprise and I think this is connected. We had to rearrange some of our own workflows as well, as some data structure is different on the Enterprise plan.
Seems like the error arises from the first line of the following snippet.

  echo "$COMMENTS" | jq -c --arg username "github-actions[bot]" '.[] | select(.user.login == $username and (.body | index("Eco-CI") // false))' | while read -r comment; do
      COMMENT_ID=$(echo "$comment" | jq -r '.id')
      COMMENT_BODY=$(echo "$comment" | jq -r '.body')
      INNER_BODY=$(echo "$COMMENT_BODY" | sed 's/<details><summary>Old Energy Estimation<\/summary>//g' | sed 's/<\/details>//g')
  
      ## indentation here is important, otherwise newlines are not properly sent/processed
      PAYLOAD=$(jq --null-input --arg body "<details><summary>Old Energy Estimation</summary>
  
  $INNER_BODY
  
  </details>" '{"body": $body}')
      curl -s -H "Authorization: ***" -X PATCH -d "$PAYLOAD" "[...]/$COMMENT_ID"
      echo "Comment $COMMENT_ID collapsed."
  done
  
  NEW_COMMENT=$(cat "/tmp/eco-ci/output-pr.txt" | jq -Rs '.')
  API_URL="[...]"
  curl -X POST -H "Authorization: ***" -d @- $API_URL <<EOF
  {
    "body": $NEW_COMMENT
  }
  EOF
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env: [...]
jq: error (at <stdin>:5): Cannot index string with string "user"
Error: Process completed with exit code 5.
@ArneTR ArneTR linked a pull request Jun 13, 2024 that will close this issue
@ArneTR
Copy link
Member

ArneTR commented Jun 13, 2024

Hey @Freubert ,

thanks for opening an issue on this! We love to see that the tool is in use ❤️

We had issues with Github Enterprise before but never could really drill down the issue as we have not testing setup (we ourselves only use the free plan).

When looking at the code I believe it comes from the fact that the wrong API endpoint is used.

I created a PR that normalizes all API endpoints to the ${{ github.api_url }}, which was not the case so far.

#82

Please check if that already works for you. You can just change the integration in your workflow to uses: green-coding-solutions/eco-ci-energy-estimation@enterprise-fix

If that does not solve your issue it might be that your enterprise github is hosted on a custom domain. Is that the case?

If so you must modify the variable in the inputs as given in the README. See this part:

api-base: (optional) (default: 'api.github.com')
Eco-CI uses the github api to post/edit PR comments
set to github's default api, but can be changed if you are using github enterprise

Let me know if it works!

@Freubert
Copy link
Author

Hi @ArneTR, thanks for the quick response.

Unfortunately this doesn't seem to help. The error message raised stays exactly the same on the fixed branch.

We are not hosted on a custom domain with our enterprise plan. We are on native github.com as well. Therefor, our API url should also simply be api.github.com.

Could I assist any further with more info/logs or something?

@ArneTR
Copy link
Member

ArneTR commented Jun 17, 2024

Is it maybe a private repo you are using?

In case this part of the docs might help: https://github.com/green-coding-solutions/eco-ci-energy-estimation?tab=readme-ov-file#note-on-private-repos

@ArneTR ArneTR reopened this Jun 18, 2024
@ArneTR
Copy link
Member

ArneTR commented Jun 18, 2024

Hey @Freubert , sorry the issue was closed automatically although I understand it is not resolved.

I just merged the PR as it was needed anyway, but apparently not a fix to this issue.

Please follow up if you have more details.

The branch to target now with the current version would be eco-ci-energy-estimation@main

@Freubert
Copy link
Author

In fact we are using a private repo, but already had the permission set correctly. Before updating to Github Enterprise the workflow ran flawlessly.
I'm currently short on time, but will research a little more during the next days or weeks.

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

Successfully merging a pull request may close this issue.

2 participants