Skip to content

Comment on the PR

Comment on the PR #81

Workflow file for this run

name: Comment on the PR
# read-write repo token
# access to secrets
on:
workflow_run:
workflows: ["Build PR"]
types:
- completed
env:
OPAMROOT: /home/opam/.opam
OPAMCONFIRMLEVEL: unsafe-yes
jobs:
upload_lints:
if: ${{( github.event.workflow_run.event == 'pull_request') && (github.event.workflow_run.conclusion == 'success') }}
runs-on: ubuntu-latest
container:
image: kakadu18/ocaml:comp25
permissions:
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: false
- run: echo "conclusion = ${{ github.event.workflow_run.conclusion }}"
- run: echo "event = ${{ github.event.workflow_run.event }}"
- name: Download artifact
uses: dawidd6/action-download-artifact@v6
with:
workflow: PR.yml
name: review
allow_forks: true
- run: ls
- run: |
echo "LANG_NAME=$(cat projectname.txt)" >> $GITHUB_ENV
echo "PIARAST_NAME=$(cat piarast.txt)" >> $GITHUB_ENV
echo "CI_PULL_REQUEST=$(cat PR_number.txt)" >> $GITHUB_ENV
echo "CI_COMMIT=$(cat CI_COMMIT.txt)" >> $GITHUB_ENV
echo "CI_REPO_OWNER=Kakadu" >> $GITHUB_ENV
- run: |
echo "${{ env.LANG_NAME }}"
echo "${{ env.PIARAST_NAME }}"
echo "CI_PULL_REQUEST = ${{ env.CI_PULL_REQUEST }}"
echo "CI_COMMIT = ${{ env.CI_COMMIT }}"
echo "CI_REPO_OWNER = ${{ env.CI_REPO_OWNER }}"
- run: |
opam pin add https://github.com/Kakadu/zanuda.git --no-action
opam reinstall zanuda
opam reinstall reviewer
- run: cat lints.rdjsonl
- name: Run reviewer
run: |
opam exec -- reviewer -token ${{ secrets.GITHUB_TOKEN }} \
-owner ${{ env.CI_REPO_OWNER }} \
-repo ${{ github.event.repository.name }} \
-pr_number ${{ env.CI_PULL_REQUEST }} \
-commit ${{ env.CI_COMMIT }} \
-irdjsonl lints.rdjsonl -review
# TODO: Maybe not deploy empty lint files
- run: |
echo "LINTS_NAME=$(date +%Y-%m-%d_%H_%M).json" >> $GITHUB_ENV
- run: |
mkdir -p lints
cp lints.rdjsonl lints/${{ env.LINTS_NAME }}
- name: Deploy found lints
uses: peaceiris/actions-gh-pages@v4
with:
personal_token: ${{ secrets.UPLOAD_LINTS_TOKEN }}
# used only to publish in local repo
publish_dir: ./lints
external_repository: Kakadu/fp2021-ci-artifacts
publish_branch: master
keep_files: true
destination_dir: 2025fp/${{ env.LANG_NAME }}/
# generate new token
# https://github.com/settings/tokens
# put it here
# https://github.com/Kakadu/fp25/settings/secrets/actions/new
- name: Prepare text with found lints
shell: bash
run: |
export TZ='Europe/Moscow'
echo "Linter report from $(date +%F\ %k:%M), for mini language ${{ env.LANG_NAME }}" > text.md
echo '```' >> text.md
cat lints.txt >> text.md
echo '```' >> text.md
#- run: cat text.md
# - name: Find a comment with linter report
# uses: peter-evans/find-comment@v2
# id: fc-linter
# with:
# issue-number: ${{ env.CI_PULL_REQUEST }}
# body-includes: Linter report from
# comment-author: Kakadu
# - name: Tracing ${{ steps.fc-linter.outputs.comment-id }}
# run: echo "${{ steps.fc-linter.outputs.comment-id }}"
# - name: Manually remove comment '${{ steps.fc-linter.outputs.comment-id }}' with lints
# if: ${{ steps.fc-linter.outputs.comment-id != 0 }}
# run: >
# opam exec -- ocaml .github/add_comment.ml \
# -token ${{ secrets.GITHUB_TOKEN }} \
# -issue ${{ env.CI_PULL_REQUEST }} \
# -delete-comment ${{ steps.fc-linter.outputs.comment-id }} \
# -user Kakadu \
# -repo ${{ github.event.repository.name }}
# The way to remove comments changes to prevent pulling extra docker image should exist.
#- name: Delete old comment
# uses: winterjung/comment@v1
# if: ${{ steps.fc.outputs.comment-id != 0 }}
# with:
# type: delete
# comment_id: ${{ steps.fc.outputs.comment-id }}
# token: ${{ secrets.GITHUB_TOKEN }}
# - name: Create comment
# uses: mshick/add-pr-comment@v2
# with:
# message: ${{ steps.read-escaped-markdown.outputs.contents }}
# issue: ${{ env.CI_PULL_REQUEST }}
# repo-owner: Kakadu
# repo-name: ${{ github.event.repository.name }}
# #refresh-message-position: true
# proxy-url: https://add-pr-comment-proxy-94idvmwyie-uc.a.run.app
- uses: mshick/add-pr-comment@v2
with:
message-path: text.md
message-id: linter-report
refresh-message-position: true
issue: ${{ env.CI_PULL_REQUEST }}
- run: opam list
- name: Adding a comment about lints upload via OCaml script
continue-on-error: true
if: false
run: >
opam exec -- ocaml .github/add_comment.ml \
-file text.md \
-token ${{ secrets.GITHUB_TOKEN }} \
-issue ${{ env.CI_PULL_REQUEST }} \
-repo ${{ github.event.repository.name }} \
-user ${{ env.CI_REPO_OWNER }}
- shell: bash
run: echo "LINTER_RESOLUTION=$(bash .github/check_rdjson.sh lints.rdjsonl)" >> $GITHUB_ENV
- name: Tag PR as FEW linter complains
if: ${{ env.LINTER_RESOLUTION == 'FEW' }}
uses: actions/github-script@v6
with:
script: |
github.rest.issues.setLabels({
issue_number: ${{ env.CI_PULL_REQUEST }},
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["A_FEW_LINTS"]
})
- name: Tag PR as TOOMANY linter complains
if: ${{ env.LINTER_RESOLUTION == 'TOOMANY' }}
uses: actions/github-script@v6
with:
script: |
github.rest.issues.setLabels({
issue_number: ${{ env.CI_PULL_REQUEST }},
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["TOO_MANY_LINTS"]
})
- name: Tag PR as OK linter complains
if: ${{ env.LINTER_RESOLUTION == 'OK' }}
uses: actions/github-script@v6
with:
script: |
github.rest.issues.setLabels({
issue_number: ${{ env.CI_PULL_REQUEST }},
owner: context.repo.owner,
repo: context.repo.repo,
labels: []
})
###################################################################################################
upload_docs:
if: ${{( github.event.workflow_run.event == 'pull_request') && (github.event.workflow_run.conclusion == 'success') }}
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Print
run: env | sort
- name: Checkout code
uses: actions/checkout@v4
- name: Download odoc artifact
uses: dawidd6/action-download-artifact@v6
with:
workflow: PR.yml
name: docs
path: _docs
allow_forks: true
#- run: ls docs
- run: |
echo "LANG_NAME=$(cat _docs/projectname.txt)" >> $GITHUB_ENV
echo "PR_NUMBER=$(cat _docs/PR_number.txt)" >> $GITHUB_ENV
- name: Lang is ${{ env.LANG_NAME }}, PR is ${{ env.PR_NUMBER }}
run: echo
# LANG_NAME is required for uploading docs.
# PR_NUMBER -- for adding a comment
- name: Deploy documentation for ${{ env.LANG_NAME }}
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.UPLOAD_LINTS_TOKEN }}
publish_branch: gh-pages
publish_dir: ./_docs/_html
destination_dir: docs/
enable_jekyll: false
keep_files: true
commit_message: >
Deploying documentation for ${{ env.LANG_NAME }}: https://kakadu.github.io/${{ github.event.repository.name }}/docs/${{ env.LANG_NAME }} [skip ci]
user_name: '${{ github.event.repository.name }}[bot]'
user_email: '${{ github.event.repository.name }}[bot]@users.noreply.github.com'
- run: >
.github/make_doc_msg.sh \
"${{ github.event.repository.name }}" \
"${{ env.LANG_NAME }}" \
_docs/percent.txt \
text.md
- run: cat text.md
# - name: Find Comment
# uses: peter-evans/find-comment@v2
# id: fc-docs
# if: ${{ always() }}
# with:
# issue-number: ${{ env.PR_NUMBER }}
# body-includes: Документация и тестовое покрытие
# comment-author: Kakadu
#- run: |
# echo "${{ steps.fc.outputs.comment-id }}"
# echo "${{ steps.fc.outputs.comment-body }}"
# echo "${{ steps.fc.outputs.comment-author }}"
# echo "${{ steps.fc.outputs.comment-created-at }}"
# The way to remove comments changes to prevent pulling extra docker image should exist.
#- name: Delete old comment
# uses: winterjung/comment@v1
# if: ${{ steps.fc.outputs.comment-id != 0 }}
# with:
# type: delete
# comment_id: ${{ steps.fc.outputs.comment-id }}
# token: ${{ secrets.GITHUB_TOKEN }}
# - name: Manually remove comment '${{ steps.fc-docs.outputs.comment-id }}' with docs info
# if: ${{ steps.fc-docs.outputs.comment-id != 0 }}
# run: >
# opam exec -- ocaml .github/add_comment.ml \
# -token ${{ secrets.GITHUB_TOKEN }} \
# -issue ${{ env.PR_NUMBER }} \
# -delete-comment ${{ steps.fc-docs.outputs.comment-id }} \
# -user Kakadu \
# -repo ${{ github.event.repository.name }}
- uses: mshick/add-pr-comment@v2
name: Add comment about uploaded docs to PR '${{ env.PR_NUMBER }}'
with:
message-path: text.md
message-id: docs-uploaded
refresh-message-position: true
issue: ${{ env.PR_NUMBER }}
# - name: Adding a comment from 'text.md' manually
# if: false
# run: >
# opam exec -- ocaml .github/add_comment.ml \
# -file text.md \
# -token ${{ secrets.GITHUB_TOKEN }} \
# -issue ${{ env.PR_NUMBER }} \
# -repo ${{ github.event.repository.name }} \
# -user Kakadu
upload_coverage:
runs-on: ubuntu-latest
if: ${{( github.event.workflow_run.event == 'pull_request') && (github.event.workflow_run.conclusion == 'success') }}
steps:
- name: Download coverage artifact
uses: dawidd6/action-download-artifact@v6
with:
workflow: PR.yml
name: coverage
path: _coverage
allow_forks: true
- run: |
echo "LANG_NAME=$(cat _coverage/projectname.txt)" >> $GITHUB_ENV
- run: echo "${{ env.LANG_NAME }}"
- name: Check '${{ env.LANG_NAME }}' is not empty
if: ${{ env.LANG_NAME == '' }}
run: exit 1
- name: Deploy coverage
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.UPLOAD_LINTS_TOKEN }}
publish_dir: ./_coverage
publish_branch: gh-pages
enable_jekyll: false
keep_files: true
destination_dir: cov/${{ env.LANG_NAME }}
commit_message: >
Deploying coverage for ${{ env.LANG_NAME }}: https://kakadu.github.io/${{ github.event.repository.name }}/cov/${{ env.LANG_NAME }} [skip ci]
user_name: '${{ github.event.repository.name }}[bot]'
user_email: '${{ github.event.repository.name }}[bot]@users.noreply.github.com'
# generate new token
# https://github.com/settings/tokens
# put it here
# https://github.com/Kakadu/comp24/settings/secrets/actions/new
###################################################################################################
process_clones:
runs-on: ubuntu-latest
if: false # CURRENTLY DISABLED
#if: >
# ${{ github.event.workflow_run.event == 'pull_request' &&
# github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download artifact
uses: dawidd6/action-download-artifact@v6
with:
workflow: PR.yml
name: jscpd_report
allow_forks: true
- run: |
echo "PR_NUMBER=$(cat PR_number.txt)" >> $GITHUB_ENV
echo "LANG_NAME=$(cat projectname.txt)" >> $GITHUB_ENV
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ env.PR_NUMBER }}
body-includes: "#### A report of looking for clones for mini language"
comment-author: github-actions[bot]
#- name: ${{ steps.fc.outputs.comment-id }}
# run: |
# echo "${{ steps.fc.outputs.comment-body }}"
- name: Delete old comment
uses: winterjung/comment@v1
if: ${{ steps.fc.outputs.comment-id != 0 }}
with:
type: delete
comment_id: ${{ steps.fc.outputs.comment-id }}
token: ${{ secrets.GITHUB_TOKEN }}
#- name: Delete old comment
# if: ${{ steps.fc.outputs.comment-id != 0 }}
# run: |
# curl -L https://api.github.com/repos/Kakadu/fp2024/pulls/comments/${{ steps.fc.outputs.comment-id }} \
# -X DELETE -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
# -H "X-GitHub-Api-Version: 2022-11-28"
# I tried to remove manually but it doesn't work
# { "message": "Not Found",
# "documentation_url": "https://docs.github.com/rest/pulls/comments#delete-a-review-comment-for-a-pull-request"
#}
- name: Read file contents
id: read-escaped-markdown
uses: andstor/file-reader-action@v1
with:
path: jscpd_report.txt
# https://stackoverflow.com/a/7359879
- name: Prepare text with clones report
id: render_template
shell: bash
run: |
printf "#### A report of looking for clones for mini language ${{ env.LANG_NAME }}\n\n\`\`\`\n" > template.md
cat jscpd_report.txt >> template.md
printf "\`\`\`" >> template.md
- run: cat template.md
# I used the following action earlier, but it pull +1 docker image
#- name: Render template
# id: render_template
# uses: chuhlomin/[email protected]
# with:
# template: .github/jscpd.template.md
# vars: |
# contents: ${{ steps.read-escaped-markdown.outputs.contents }}
- name: Create comment
uses: peter-evans/create-or-update-comment@v3
if: ${{ steps.read-escaped-markdown.outputs.contents != '' }}
with:
edit-mode: replace
issue-number: ${{ env.PR_NUMBER }}
body-path: template.md
- if: ${{ steps.read-escaped-markdown.outputs.contents == '' }}
run: echo "JSPD report is empty"