Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activate Git action that enforces test coverage #786

Merged
merged 6 commits into from
Sep 4, 2024

Conversation

0xDEnYO
Copy link
Contributor

@0xDEnYO 0xDEnYO commented Sep 3, 2024

Which Jira task belongs to this PR?

Why did I implement it this way?

Checklist before requesting a review

  • I have performed a self-review of my code
  • This pull request is as small as possible and only tackles one problem
  • I have added tests that cover the functionality / test the bug
  • I have updated any required documentation

Checklist for reviewer (DO NOT DEPLOY and contracts BEFORE CHECKING THIS!!!)

  • I have checked that any arbitrary calls to external contracts are validated and or restricted
  • I have checked that any privileged calls (i.e. storage modifications) are validated and or restricted
  • I have ensured that any new contracts have had AT A MINIMUM 1 preliminary audit conducted on by <company/auditor>

Copy link
Contributor

coderabbitai bot commented Sep 3, 2024

Warning

Rate limit exceeded

@lifi-action-bot has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 29 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 49aa253 and 2616ad2.

Walkthrough

A new GitHub Actions workflow named enforceTestCoverage.yml has been introduced to enforce a minimum test coverage threshold of 74% for pull requests. This workflow triggers on specific pull request events and includes steps for setting up the environment, generating a coverage report, and posting results as comments on pull requests. The previous workflow has been deactivated, reflecting changes in job naming, coverage thresholds, dependency management, and toolchain version updates.

Changes

Files Change Summary
.github/workflows/enforceTestCoverage.yml New workflow added to enforce a minimum test coverage threshold of 74% for pull requests.
.github/workflows_deactivated/enforceTestCoverage.yml Previous workflow deactivated; changes include job name update, coverage threshold adjustment from 80% to 75%, and dependency management shift from npm to yarn.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0edaeca and f9d19b0.

Files selected for processing (2)
  • .github/workflows/enforceTestCoverage.yml (1 hunks)
  • .github/workflows_deactivated/enforceTestCoverage.yml (2 hunks)
Additional context used
actionlint
.github/workflows/enforceTestCoverage.yml

59-59: shellcheck reported issue in this script: SC2086:info:58:8: Double quote to prevent globbing and word splitting

(shellcheck)


59-59: shellcheck reported issue in this script: SC2129:style:69:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


59-59: shellcheck reported issue in this script: SC2086:info:69:54: Double quote to prevent globbing and word splitting

(shellcheck)


59-59: shellcheck reported issue in this script: SC2086:info:70:62: Double quote to prevent globbing and word splitting

(shellcheck)


59-59: shellcheck reported issue in this script: SC2086:info:71:58: Double quote to prevent globbing and word splitting

(shellcheck)


59-59: shellcheck reported issue in this script: SC2086:info:72:58: Double quote to prevent globbing and word splitting

(shellcheck)

Additional comments not posted (12)
.github/workflows_deactivated/enforceTestCoverage.yml (7)

1-1: LGTM!

The workflow name change accurately reflects the new focus on enforcing a minimum test coverage threshold.


8-9: LGTM!

The workflow trigger change to respond to pull request events aligns the coverage enforcement with the pull request lifecycle, which is a good practice.


12-12: LGTM!

The job name change accurately reflects the new emphasis on enforcing minimum coverage requirements.


14-15: LGTM!

The conditional statement to run the job only when the pull request is not in a draft state enhances the workflow's efficiency by preventing unnecessary checks on draft pull requests.


28-28: LGTM!

The minimum test coverage percentage change to 75% with a plan to gradually increase it to 100% by the end of 2024 reflects a strategic decision to lower the immediate threshold while still committing to future improvements.


37-38: Verify the reason for the change in package manager.

The dependency installation step has been changed from using npm to yarn. Please verify the reason for this change and ensure that it aligns with the project's package management preferences.


41-43: LGTM!

The Foundry toolchain version update to v1.2.0 suggests an upgrade to leverage new features or improvements.

.github/workflows/enforceTestCoverage.yml (5)

1-10: LGTM!

The workflow name and trigger events are appropriate for the purpose of enforcing test coverage on pull requests.


11-28: LGTM!

The job configuration looks good:

  • The job name is appropriate.
  • It runs on the latest Ubuntu.
  • It only runs when the PR is ready for review.
  • The permissions are set appropriately.
  • The required environment variables are set.

29-46: LGTM!

The checkout and setup steps look good:

  • Using the latest versions of the checkout and setup-node actions.
  • Installing dev dependencies using Yarn.
  • Installing the nightly version of Foundry using the latest version of the foundry-toolchain action.
  • Installing Foundry dependencies using forge install.

48-56: LGTM!

The coverage report generation step looks good:

  • Generates the coverage report in the standard lcov format using forge coverage.
  • Filters the coverage report using a TypeScript script to only include relevant folders.
  • Saves the filtered report to lcov-filtered.info.

133-141: LGTM!

The step that comments the coverage summary on the pull request looks good:

  • Uses the mshick/add-pr-comment@v2 action to add a comment.
  • Includes the coverage summary stored in the GitHub environment variables in the comment.

@lifi-action-bot
Copy link
Collaborator

Test Coverage Report

Line Coverage: 74.43% (1575 / 2116 lines)
Function Coverage: 82.85% ( 343 / 414 functions)
Branch Coverage: 49.02% ( 252 / 514 branches)
Test coverage (74.43%) is above min threshold (74%). Check passed.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f9d19b0 and 64f530f.

Files selected for processing (1)
  • .github/workflows/enforceTestCoverage.yml (1 hunks)
Additional context used
actionlint
.github/workflows/enforceTestCoverage.yml

58-58: shellcheck reported issue in this script: SC2086:info:58:8: Double quote to prevent globbing and word splitting

(shellcheck)


58-58: shellcheck reported issue in this script: SC2129:style:69:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


58-58: shellcheck reported issue in this script: SC2086:info:69:54: Double quote to prevent globbing and word splitting

(shellcheck)


58-58: shellcheck reported issue in this script: SC2086:info:70:62: Double quote to prevent globbing and word splitting

(shellcheck)


58-58: shellcheck reported issue in this script: SC2086:info:71:58: Double quote to prevent globbing and word splitting

(shellcheck)


58-58: shellcheck reported issue in this script: SC2086:info:72:58: Double quote to prevent globbing and word splitting

(shellcheck)

Additional comments not posted (7)
.github/workflows/enforceTestCoverage.yml (7)

1-6: The workflow name and description look good!

The workflow name clearly conveys the purpose of enforcing a minimum test coverage threshold. The description provides additional context, including the current coverage threshold, the plan to increase it over time, and the focus on 'lines' coverage.


7-15: The workflow trigger conditions are set up correctly.

The workflow is triggered on the appropriate pull request events (opened, synchronized, reopened) and only runs when the pull request is not in draft state. This ensures that the test coverage check is performed at the right time during the code review process.


17-27: The workflow permissions and environment variables are properly set.

The required permissions for the workflow are correctly specified. The sensitive information (Ethereum node URIs) is securely stored using secrets and accessed through environment variables. The minimum test coverage threshold is also defined as an environment variable, allowing for easy adjustment if needed.


28-45: The setup steps in the workflow are comprehensive and well-defined.

The workflow properly sets up the environment by checking out the repository, installing Node.js, Foundry, and the required dependencies. Using specific versions for Node.js and Foundry ensures consistency across runs. The setup steps are complete and in the correct order.


47-55: The coverage report generation step is well-structured and includes the necessary commands.

The forge coverage command is used with the appropriate flags to generate the lcov report. The generated report is then filtered using a TypeScript script to include only the relevant source code from the 'src/' folder, excluding the 'test/' and 'script/' folders. This filtering step ensures that the coverage metrics are based on the actual production code.


57-130: The coverage summary generation step looks good, but there are a few issues reported by actionlint that should be addressed.

The overall logic of the step is correct:

  • Reads the filtered lcov file line by line.
  • Extracts the total lines, functions, and branches found and hit using regex matching.
  • Calculates the coverage percentages for lines, functions, and branches using bc with high precision.
  • Formats the coverage percentages with two decimal places and alignment.
  • Checks the line coverage percentage against the minimum threshold.
  • Outputs the coverage summary and result.
  • Stores the coverage reports in GitHub environment variables.

However, actionlint reported the following issues in the shell script:

  • SC2086: Double quote to prevent globbing and word splitting.
  • SC2129: Consider using { cmd1; cmd2; } >> file instead of individual redirects.

To fix these issues, apply the following changes:

- echo "LINE_COVERAGE_REPORT=$LINE_COVERAGE_REPORT" >> $GITHUB_ENV
- echo "FUNCTION_COVERAGE_REPORT=$FUNCTION_COVERAGE_REPORT" >> $GITHUB_ENV
- echo "BRANCH_COVERAGE_REPORT=$BRANCH_COVERAGE_REPORT" >> $GITHUB_ENV
- echo "RESULT_COVERAGE_REPORT=$RESULT_COVERAGE_REPORT" >> $GITHUB_ENV
+ {
+   echo "LINE_COVERAGE_REPORT=$LINE_COVERAGE_REPORT"
+   echo "FUNCTION_COVERAGE_REPORT=$FUNCTION_COVERAGE_REPORT"  
+   echo "BRANCH_COVERAGE_REPORT=$BRANCH_COVERAGE_REPORT"
+   echo "RESULT_COVERAGE_REPORT=$RESULT_COVERAGE_REPORT"
+ } >> "$GITHUB_ENV"
Tools
actionlint

58-58: shellcheck reported issue in this script: SC2086:info:58:8: Double quote to prevent globbing and word splitting

(shellcheck)


58-58: shellcheck reported issue in this script: SC2129:style:69:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


58-58: shellcheck reported issue in this script: SC2086:info:69:54: Double quote to prevent globbing and word splitting

(shellcheck)


58-58: shellcheck reported issue in this script: SC2086:info:70:62: Double quote to prevent globbing and word splitting

(shellcheck)


58-58: shellcheck reported issue in this script: SC2086:info:71:58: Double quote to prevent globbing and word splitting

(shellcheck)


58-58: shellcheck reported issue in this script: SC2086:info:72:58: Double quote to prevent globbing and word splitting

(shellcheck)


132-141: The step for commenting the coverage summary in the pull request is properly configured.

The mshick/add-pr-comment action is used correctly to add a comment to the pull request with the coverage summary. The authentication is securely handled using a personal access token stored as a secret. The message of the comment includes the relevant coverage reports stored in the GitHub environment variables, providing a clear overview of the test coverage results.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 64f530f and 5cb12d3.

Files selected for processing (1)
  • .github/workflows/enforceTestCoverage.yml (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/enforceTestCoverage.yml

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5cb12d3 and 49aa253.

Files selected for processing (1)
  • .github/workflows/enforceTestCoverage.yml (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/enforceTestCoverage.yml

@0xDEnYO 0xDEnYO merged commit 033ab32 into main Sep 4, 2024
9 of 11 checks passed
@0xDEnYO 0xDEnYO deleted the activateEnforceTestCoverage branch September 4, 2024 08:10
@coderabbitai coderabbitai bot mentioned this pull request Mar 7, 2025
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants