Skip to content

Commit

Permalink
Merge branch 'develop' into initial_commit_aab
Browse files Browse the repository at this point in the history
  • Loading branch information
Rd4dev authored Nov 21, 2024
2 parents e87dd96 + 04e5c9c commit 6621197
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 26 deletions.
45 changes: 29 additions & 16 deletions .github/workflows/comment_coverage_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,23 @@ jobs:
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
- name: Find the last Coverage Report
uses: peter-evans/find-comment@v3
id: last-coverage-report
- name: Find the latest Code Coverage Report Comment
uses: actions/github-script@v6
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: Coverage Report
direction: last
- run: |
echo "${{ steps.last-coverage-report.outputs.comment-body }}" >> comment.md
script: |
const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ github.event.pull_request.number }},
});
for (let i = comments.length - 1; i >= 0; i--) {
if (comments[i].body.includes("Coverage Report")) {
const latestCodeCoverageComment = comments[i].body;
require('fs').writeFileSync('latest_code_coverage_comment.md', latestCodeCoverageComment, 'utf8');
return
}
}
- name: Find CI workflow run for PR
id: find-workflow-run
Expand Down Expand Up @@ -84,17 +92,22 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ steps.find-workflow-run.outputs.run-id }}

- name: Compare coverage report with the comment body (workkkkk!!)
- name: Compare Current Coverage Report with the Latest Coverage Report
run: |
sed -i -e '$a\' CoverageReport.md
sed -i -e '$a\' comment.md
if [ -f latest_code_coverage_comment.md ]; then
sed -i -e '$a\' CoverageReport.md
sed -i -e '$a\' latest_code_coverage_comment.md
if diff -B CoverageReport.md comment.md > /dev/null; then
echo "No significant changes detected; skipping coverage comment."
echo "skip_coverage_comment=true" >> $GITHUB_ENV
if diff -B CoverageReport.md latest_code_coverage_comment.md > /dev/null; then
echo "No significant changes detected; skipping coverage comment."
echo "skip_coverage_comment=true" >> $GITHUB_ENV
else
echo "Changes detected; proceeding with the coverage comment."
diff CoverageReport.md latest_code_coverage_comment.md || true
echo "skip_coverage_comment=false" >> $GITHUB_ENV
fi
else
echo "Changes detected; proceeding with the coverage comment."
diff CoverageReport.md comment.md || true
echo "No previous coverage comment found; posting coverage comment."
echo "skip_coverage_comment=false" >> $GITHUB_ENV
fi
Expand Down
27 changes: 17 additions & 10 deletions .github/workflows/stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ jobs:
repo: context.repo.repo,
pull_number: ${{ matrix.prInfo.number }},
});
const latestCommentDate = "${{ steps.find_latest_apk_aab_comment.outputs.latest_aab_comment_created_at }}";
const recentCommits = commits.filter(commit => {
const commitDate = new Date(commit.commit.committer.date);
return commitDate > new Date("${{ steps.find_latest_apk_aab_comment.outputs.latest_aab_comment_created_at }}");
Expand All @@ -90,7 +91,7 @@ jobs:
console.log(`Recent Commits count - ${recentCommitsCount}`);
if(recentCommitsCount > 0) {
if(recentCommitsCount > 0 || !latestCommentDate) {
console.log("New commits found after the last apk & aab stat analysis");
core.setOutput("new_commits", "true");
} else {
Expand Down Expand Up @@ -275,20 +276,26 @@ jobs:
- name: Compare apk aab analysis with the previous report
if: ${{ steps.check_commits_after_latest_apk_aab_comment.outputs.new_commits == 'true' }}
run: |
sed -i -e '$a\' ./develop/brief_build_summary.log
sed -i -e '$a\' latest_aab_comment_body.log
if [ -f latest_aab_comment_body.log ]; then
sed -i -e '$a\' ./develop/brief_build_summary.log
sed -i -e '$a\' latest_aab_comment_body.log
if diff -B ./develop/brief_build_summary.log latest_aab_comment_body.log > /dev/null; then
echo "No significant changes detected; skipping apk aab analysis comment."
echo "skip_apk_aab_comment=true" >> $GITHUB_ENV
if diff -B ./develop/brief_build_summary.log latest_aab_comment_body.log > /dev/null; then
echo "No significant changes detected; skipping apk aab analysis comment."
echo "skip_apk_aab_comment=true" >> $GITHUB_ENV
else
echo "Changes detected; proceeding with the apk aab analysis comment."
diff ./develop/brief_build_summary.log latest_aab_comment_body.log || true
echo "skip_apk_aab_comment=false" >> $GITHUB_ENV
fi
else
echo "Changes detected; proceeding with the apk aab analysis comment."
diff ./develop/brief_build_summary.log latest_aab_comment_body.log || true
# File does not exist, post apk aab analysis comment
echo "No 'latest_aab_comment_body.log' found; introducing apk aab analysis comment."
echo "skip_apk_aab_comment=false" >> $GITHUB_ENV
fi
- name: Add build stats summary comment
if: ${{ steps.check_commits_after_latest_apk_aab_comment.outputs.new_commits == 'true' && !env.skip_apk_aab_comment }}
if: ${{ steps.check_commits_after_latest_apk_aab_comment.outputs.new_commits == 'true' && env.skip_apk_aab_comment == 'false' }}
env:
PR_NUMBER: ${{ matrix.prInfo.number }}
uses: peter-evans/create-or-update-comment@v1
Expand Down

0 comments on commit 6621197

Please sign in to comment.