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

Parallel builds webhook #212

Closed
sanjioh opened this issue Dec 5, 2019 · 7 comments
Closed

Parallel builds webhook #212

sanjioh opened this issue Dec 5, 2019 · 7 comments

Comments

@sanjioh
Copy link

sanjioh commented Dec 5, 2019

Hi,

as per Coveralls docs:

https://docs.coveralls.io/parallel-build-webhook

a webhook needs to be called when parallel builds are done with reporting, to inform the service that no more submissions will be performed and thus it can start processing/displaying coverage data.

Is this something that coveralls-python can do? I'm running my CI on GitHub Actions and I'm not able to invoke the webhook without implementing a custom solution.

Thanks!

@agronholm
Copy link

Is this not sufficient for your use case? https://github.com/marketplace/actions/coveralls-github-action

@ArturKlauser
Copy link
Contributor

There is PR #216 in the works that seems to address this issue.

@agronholm
Copy link

Yes, I managed to get it working in my own project using the code from that PR: https://github.com/agronholm/smtpproto/tree/master/.github/workflows

@sanjioh
Copy link
Author

sanjioh commented Jan 7, 2020

Hi,

thanks everybody for your replies.

I haven't tried it yet but, looking at the diff, #216 should work my end as well.

Nevertheless, in my opinion it would be nice to have a dedicated CLI argument in coveralls-python to explicitly tell Coveralls a parallel build has finished. This would make this tool independent from Coveralls' own GitHub Action, which would otherwise be required even after the merge of #216.

Maybe the build_num value (ref. https://docs.coveralls.io/parallel-build-webhook) could be left out as CLI parameter, to be provided by the user in accordance to their CI environment.

Thanks

@TheKevJames
Copy link
Owner

@sanjioh I've just merged #216 and am planning a release pending fixing some test issues (mostly Python/PyPy versions that got deprecated while my back was turned) in #218.

I might consider accepting a PR for adding a flag for this, but I just want to get up-to-speed on this issue first (I don't use Github Actions myself) and only so long as its not easily solve-able outside this project.

@agronholm 's suggestion seems to work pretty well -- looks like you could also do this in curl? Am I understanding correctly that adding the following line to your Github Actions workflow would also do the trick?

- name: Tell Coveralls that the parallel build is finished
  run: |
    curl -k \
        https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN \
        -d "payload[build_num]=$GITHUB_SHA&payload[status]=done"
  env:
    COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

Looks like the payload[build_num] might be non-trivial to send with the whole {SHA}-PR-{REF} thing it has going on... maybe by adding my library to the mix? Would it work correctly by running:

- name: Tell Coveralls that the parallel build is finished
  run: |
    BUILD_NUM=$(python -c 'import coveralls; print(coveralls.Coveralls.load_config_from_github()[1])')
    curl -k \
        https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN \
        -d "payload[build_num]=$BUILD_NUM&payload[status]=done"
  env:
    COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

@TimoRoth
Copy link
Contributor

TimoRoth commented Jun 9, 2020

It seems coveralls and github have changed stuff around again.
Their github action now uses the GitHub provided environment variable GITHUB_RUN_ID as JobID.

Additionally, there now appears to be a first-class github service name, which takes the default-provided secrets.GITHUB_TOKEN for authentication, removing the need to manually enter the token.

I have managed to work around this for now by doing this:

In my workflow file:

env:
    COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    COVERALLS_PARALLEL: true

In my test script:

GITHUB_SHA="$GITHUB_RUN_ID" GITHUB_REF="" coveralls --service=github

This brings coveralls in line with the updated github action from them, and additionally now also properly works with pull requests.

Workflow for reference:
https://github.com/TimoRoth/oggm/blob/master/.github/workflows/run-tests.yml#L36
Test-Script:
https://github.com/TimoRoth/oggm/blob/master/ci/run_tests.sh

@TheKevJames
Copy link
Owner

Closing, as the GH Actions specific issues have been solved and the --finish flag is handled by several pre-built GH Actions such as https://github.com/AndreMiras/coveralls-python-action

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

No branches or pull requests

5 participants