Skip to content

Commit

Permalink
add commenter
Browse files Browse the repository at this point in the history
Signed-off-by: Pranav Gaikwad <[email protected]>
  • Loading branch information
pranavgaikwad committed Jul 18, 2024
1 parent 30bee29 commit ceccee2
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 1 deletion.
78 changes: 77 additions & 1 deletion .github/workflows/local-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on: ["push", "pull_request"]
jobs:
test:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Setup Homebrew
uses: Homebrew/actions/setup-homebrew@master
Expand All @@ -20,10 +23,83 @@ jobs:
- uses: actions/checkout@v3

- name: Run kantra test
id: kantra-test
run: |
podman cp $(podman create --name kantra-download quay.io/konveyor/kantra:latest):/usr/local/bin/kantra .
podman rm kantra-download
./kantra test ./default/generated/ || true
./kantra test ./default/generated/ | tee output.log || true
tail -n5 output.log > message.md
msg=$(grep -E '.*Rules Summary:' message.md -A1)
tests_pass_rate=$(grep -E '.*Rules Summary:' message.md | sed -E 's| *Rules Summary: *(.*)|\1|' | sed -E 's|.*?:||')
tcs_pass_rate=$(grep -E '.*Test Cases Summary:' message.md | sed -E 's| *Test Cases Summary: *(.*)|\1|' | sed -E 's|.*?:||')
echo 'msg<<EOF' >> $GITHUB_OUTPUT
echo ${msg} >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
echo 'tcs_pass_rate<<EOF' >> $GITHUB_OUTPUT
echo ${tcs_pass_rate} >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
echo 'tests_pass_rate<<EOF' >> $GITHUB_OUTPUT
echo ${tests_pass_rate} >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Comment on the PR
if: ${{ github.event_name == 'pull_request' }}
uses: actions/github-script@v6
with:
script: |
const issue_number = context.payload.pull_request.number;
const owner = context.repo.owner;
const repo = context.repo.repo;
const body = `${{ steps.kantra-test.outputs.msg }}`;
const comments = await github.rest.issues.listComments({
owner,
repo,
issue_number
});
const botComment = comments.data.find(comment =>
comment.user.login === 'github-actions[bot]');
if (botComment) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: botComment.id,
body
});
} else {
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body
});
}
github-token: ${{ secrets.GITHUB_TOKEN }}
debug: true

- name: Update tests badge
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: RubbaBoy/[email protected]
with:
NAME: konveyor-rulesets-tests-rate
LABEL: Test Status
STATUS: ${{ steps.kantra-test.outputs.tests_pass_rate }}
COLOR: blue
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Update test case badge
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: RubbaBoy/[email protected]
with:
NAME: konveyor-rulesets-tcs-rate
LABEL: Test Case Status
STATUS: ${{ steps.kantra-test.outputs.tcs_pass_rate }}
COLOR: blue
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

![](https://byob.yarr.is/konveyor/rulesets/konveyor-rulesets-tests-rate)

![](https://byob.yarr.is/konveyor/rulesets/konveyor-rulesets-tcs-rate)

# Overview
This repository is a future home for Konveyor's static code analysis Rulesets. It is intended to contain future rules to aid static code analysis as well as issues shared by subject matter experts to aid creation of richer Rulesets.
* Intended for [Rules](https://github.com/konveyor/analyzer-lsp/blob/main/docs/rules.md) compatible with [konveyor/analyzer-lsp](https://github.com/konveyor/analyzer-lsp)
Expand Down

0 comments on commit ceccee2

Please sign in to comment.