Skip to content

Commit

Permalink
ci: pr comments with artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
eruizalo committed Sep 14, 2022
1 parent d8177f7 commit edfee25
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 22 deletions.
11 changes: 10 additions & 1 deletion .github/templates/pr_comment.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
This is an auto-generated comment created by:
:octocat: This is an auto-generated comment created by:

- workflow: {{ .workflow }}
- run: {{ .run_url }}
- attempt: {{ .attempt }}
- previous attempt: .previous_attempt
- job name: {{ .job_name }}

Test summary report 📊

| Spark version | testing |
|:-------------:|:-------------:|
132 changes: 111 additions & 21 deletions .github/workflows/pr_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ on:
workflow_run:
workflows: [CI]
# branches: [main]
# types:
# - completed
types:
- completed

#permissions:
# pull-requests: write

jobs:
add_comment:
create_test_summary_report:
# if: github.repository == 'hablapps/doric'
runs-on: ubuntu-latest
name: Create testing summary comment
steps:
Expand All @@ -20,8 +21,10 @@ jobs:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# run: |
# echo "$GITHUB_CONTEXT"

- name: Find Comment
# if: github.event_name == 'pull_request'
# if: ${{ github.event.workflow_run.conclusion == 'success/failure' }}
uses: peter-evans/find-comment@v2
id: fc
with:
Expand All @@ -30,21 +33,118 @@ jobs:

- uses: actions/checkout@v3

- name: Render template
id: template
uses: chuhlomin/[email protected]
with:
template: .github/templates/pr_comment.md
vars: |
workflow: ${{ github.workflow }}
# - name: Render template
# id: template
# uses: chuhlomin/[email protected]
# with:
# template: .github/templates/pr_comment.md
# vars: |
# workflow: ${{ github.workflow }}
# run_url: [${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
# attempt: ${{ github.event.workflow_run.run_attempt }}
# job_name: ${{ github.job }}
- name: Create summary comment
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.workflow_run.pull_requests[0].number }}
token: "${{ secrets.GITHUB_TOKEN }}"
edit-mode: replace
body: ${{ steps.template.outputs.result }}
# body: ${{ steps.template.outputs.result }}
body: |
:octocat: This is an auto-generated comment created by:
- workflow: ${{ github.workflow }}
- run: [${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
- attempt: ${{ github.event.workflow_run.run_attempt }} <!-- ${{ github.run_attempt }} -->
- previous attempt: (${{ github.event.workflow_run.previous_attempt_url }})
- job name: ${{ github.job }}
<table>
<tr>
<th>Actor</th>
<th>Triggering actor</th>
<th>Sender</th>
</tr>
<td>
<a href="${{ github.event.workflow_run.actor.html_url }}">
<img src="${{ github.event.workflow_run.actor.avatar_url }}" alt="${{ github.event.workflow_run.actor.login }}" style="width:50px;height:50px;">
<br>
${{ github.event.workflow_run.actor.login }}
</a>
</td>
<td>
<a href="${{ github.event.workflow_run.triggering_actor.html_url }}">
<img src="${{ github.event.workflow_run.triggering_actor.avatar_url }}" alt="${{ github.event.workflow_run.triggering_actor.login }}" style="width:50px;height:50px;">
<br>
${{ github.event.workflow_run.triggering_actor.login }}
</a>
</td>
<td>
<a href="${{ github.event.sender.html_url }}">
<img src="${{ github.event.sender.avatar_url }}" alt="${{ github.event.sender.login }}" style="width:50px;height:50px;">
<br>
${{ github.event.sender.login }}
</a>
</td>
<tr><td colspan="3">
Triggered by:
- [${{ github.event.workflow_run.name }}](${{ github.event.workflow_run.path }})
- [${{ github.event.workflow_run.html_url }}](${{ github.event.workflow_run.html_url }})
on ${{ github.event_name }} ${{ github.event.action }} <!-- ${{ github.event.workflow_run.status }} -->
</td></tr>
<tr><td colspan="3">
Commit:
- ${{ github.event.workflow_run.head_commit.message }}
- ${{ github.event.workflow_run.head_commit.id }} <!-- ${{ github.event.workflow_run.head_sha }} -->
</td></tr>
</table>
Test summary report 📊
| Spark version | testing |
|:-------------:|:-------------:|
matrix_prep:
# if: github.repository == 'hablapps/doric'
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3

- id: set-matrix
uses: JoshuaTheMiller/[email protected]
with:
filter: '[]'
update_test_summary_report:
needs: ["matrix_prep", "create_test_summary_report"]
runs-on: ubuntu-latest
name: Updating testing summary comment
strategy:
fail-fast: false
matrix: ${{fromJson(needs.matrix_prep.outputs.matrix)}}
steps:
- name: Download workflow artifacts ${{ matrix.spark }}
uses: marcofaggian/[email protected]
with:
names: test-summary-${{ matrix.spark }}.md
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: ${{ github.event.workflow.id }}
commit: ${{ github.event.workflow_run.head_commit.id }}
repo: ${{github.repository}}

- name: Update with test results ${{ matrix.spark }}
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.workflow_run.pull_requests[0].number }}
token: "${{ secrets.GITHUB_TOKEN }}"
edit-mode: append
body: |
| ${{ matrix.spark }} | ${{ steps.get_artifact.outputs.summary }} |
Expand Down Expand Up @@ -109,13 +209,3 @@ jobs:
#
# - name: 'Unzip artifact'
# run: unzip pr_number.zip
# on-success:
# runs-on: ubuntu-latest
# if: ${{ github.event.workflow_run.conclusion == 'success' }}
# steps:
# - run: echo 'The triggering workflow passed'
# on-failure:
# runs-on: ubuntu-latest
# if: ${{ github.event.workflow_run.conclusion == 'failure' }}
# steps:
# - run: echo 'The triggering workflow failed'

0 comments on commit edfee25

Please sign in to comment.