diff --git a/.github/workflows/local-ci.yaml b/.github/workflows/local-ci.yaml index 22cc39c..0bd1b00 100644 --- a/.github/workflows/local-ci.yaml +++ b/.github/workflows/local-ci.yaml @@ -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 @@ -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<> $GITHUB_OUTPUT + echo ${msg} >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + + echo 'tcs_pass_rate<> $GITHUB_OUTPUT + echo ${tcs_pass_rate} >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + + echo 'tests_pass_rate<> $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/BYOB@v1.3.0 + 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/BYOB@v1.3.0 + 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 }} \ No newline at end of file diff --git a/README.md b/README.md index 9181701..8a41fcb 100644 --- a/README.md +++ b/README.md @@ -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)