-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
github-ci: add result message from coveralls in PR
Workflow 'debug_coverage' produces and uploads results to 'coveralls.io' web site. Message about it can be shown in PR within each run was done. This patch adds the ability to send message in available PR otherwise it is skipped. Also added 'coverage.info' file to artifacts list. Found that used 'coverallsapp/github-action' action checks if the trigger was 'pull_request' used to run the workflow [1]. And only in this way it writes results message to PR. Previously 'pull_request' trigger was blocked to avoid duplication with 'push' trigger. To make able to run workflow by any single trigger and to send message to PR if it exits, it was implemented the following logic: - run workflows on both triggers 'push' and 'pull_request'; - for workflow with 'push' trigger check if PR exists then skip all jobs otherwise continue running; - for workflow with 'pull_request' trigger continue running; To avoid of issue coverallsapp/github-action#55 [2], sources checkout should be based on 2nd version and later. Closes #5644 [1]: https://github.com/coverallsapp/github-action/blob/master/src/run.ts#L38 [2]: coverallsapp/github-action#55 (comment)
- Loading branch information
Showing
2 changed files
with
43 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ jobs: | |
# We want to run on external PRs, but not on our own internal PRs | ||
# as they'll be run by the push to the branch. | ||
if: ( github.event_name == 'push' || | ||
github.event.pull_request.head.repo.full_name != github.repository ) && | ||
github.event_name == 'pull_request') && | ||
! endsWith(github.ref, '-notest') | ||
|
||
runs-on: ubuntu-20.04 | ||
|
@@ -30,25 +30,61 @@ jobs: | |
shell: bash | ||
run: | | ||
sudo chown -R $(id -u):$(id -g) . | ||
- uses: actions/[email protected] | ||
# Finds an associated PR (PR can be detected only on push and never on pull_request). | ||
# WARNING !!! use in these ways only: | ||
# on push: steps.findPr.outputs.pr | ||
# on pull_request: github.event.pull_request.number | ||
- name: Find the PR associated with this push on push trigger, if there is one. | ||
uses: jwalton/gh-find-current-pr@v1 | ||
id: findPr | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
# Runs w/o PR on push otherwise on PR events. | ||
# To avoid of issue https://github.com/coverallsapp/github-action/issues/55 | ||
# sources checkout should be based on 2nd action version and later. | ||
- name: Sources checkout | ||
if: ( steps.findPr.outputs.pr == false && github.event_name == 'push' ) || | ||
github.event_name == 'pull_request' | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 | ||
submodules: recursive | ||
- uses: ./.github/actions/environment | ||
# Runs w/o PR on push otherwise on PR events. | ||
- name: Set environment | ||
if: ( steps.findPr.outputs.pr == false && github.event_name == 'push' ) || | ||
github.event_name == 'pull_request' | ||
uses: ./.github/actions/environment | ||
# Runs w/o PR on push otherwise on PR events. | ||
- name: test | ||
if: ( steps.findPr.outputs.pr == false && github.event_name == 'push' ) || | ||
github.event_name == 'pull_request' | ||
run: ${CI_MAKE} coverage_ubuntu_ghactions | ||
env: | ||
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }} | ||
# Runs w/o PR on push otherwise on PR events. | ||
- name: Upload coverage.info results to coveralls.io | ||
if: success() && | ||
( ( steps.findPr.outputs.pr == false && github.event_name == 'push' ) || | ||
github.event_name == 'pull_request' ) | ||
uses: coverallsapp/[email protected] | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
path-to-lcov: ./coverage.info | ||
# Runs on failure only. | ||
- name: call action to send Telegram message on failure | ||
env: | ||
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_CORE_TOKEN }} | ||
TELEGRAM_TO: ${{ secrets.TELEGRAM_CORE_TO }} | ||
uses: ./.github/actions/send-telegram-notify | ||
if: failure() | ||
# Runs w/o PR on push otherwise on PR events | ||
# for failed tests either Coveralls results. | ||
- name: artifacts | ||
uses: actions/upload-artifact@v2 | ||
if: failure() | ||
if: always() && | ||
( ( steps.findPr.outputs.pr == false && github.event_name == 'push' ) || | ||
github.event_name == 'pull_request' ) | ||
with: | ||
name: debug | ||
retention-days: 21 | ||
path: test/var/artifacts | ||
path: | | ||
test/var/artifacts | ||
*.info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters