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

ci: unify solidity ci #314

Merged
merged 1 commit into from
Dec 10, 2024
Merged

ci: unify solidity ci #314

merged 1 commit into from
Dec 10, 2024

Conversation

fbac
Copy link
Collaborator

@fbac fbac commented Dec 9, 2024

Summary

  • Unify all Solidity CI jobs under a single workflow with concurrency.
  • Trigger workflow only when path contract/ is changed.
  • All other workflow ignore contracts/.

Summary by CodeRabbit

  • New Features

    • Introduced a new continuous integration workflow for Solidity smart contracts, including testing, linting, and static analysis.
    • Added a command to update dependencies before deploying smart contracts.
  • Bug Fixes

    • Removed unnecessary contract-related jobs from testing and linting workflows to streamline processes.
  • Chores

    • Removed outdated workflows related to Solidity analysis and contract testing.

@fbac fbac requested a review from a team as a code owner December 9, 2024 16:51
Copy link

coderabbitai bot commented Dec 9, 2024

Walkthrough

The pull request includes significant modifications to the GitHub Actions workflows related to Solidity smart contracts. The lint.yml and test.yml workflows have been updated to ignore changes in the contracts/** directory and have removed the contracts job. The solidity-slither.yml workflow has been deleted, while a new solidity.yml workflow has been introduced, which integrates continuous integration tasks for Solidity contracts, including initialization, testing, linting, and static analysis using Slither. Additionally, deployment scripts for smart contracts have been updated to include a dependency update step.

Changes

File Change Summary
.github/workflows/lint.yml Modified to ignore contracts/** directory; removed contracts job.
.github/workflows/solidity-slither.yml Deleted workflow for analyzing Solidity contracts using Slither.
.github/workflows/solidity.yml New workflow added for CI of Solidity contracts, including jobs for init, test, lint, and slither.
.github/workflows/test.yml Modified to ignore contracts/** directory; removed contracts job.
dev/contracts/deploy-ephemeral Added command forge soldeer update before contract deployment.
dev/contracts/deploy-testnet Added command forge soldeer update before contract deployment.

Possibly related PRs

  • ci: slither and soldeer #310: The changes in this PR involve the introduction of a new GitHub Actions workflow for analyzing Solidity contracts using Slither, which is relevant to the modifications made in the main PR regarding the removal of the contracts job in the linting workflow. Both PRs deal with the management of workflows related to Solidity contracts.

Suggested reviewers

  • richardhuaaa
  • neekolas

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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

@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: 3

🧹 Outside diff range and nitpick comments (6)
dev/contracts/deploy-ephemeral (1)

8-9: Fix typo in comment

The word "dependencies" is misspelled in the comment.

-# Update depencencies
+# Update dependencies
.github/workflows/solidity.yml (5)

13-15: Consider making the concurrency group more specific.

While the current concurrency setup works, it could be improved to be more granular. Consider including the workflow name or job name in the group to prevent blocking unrelated workflow runs.

 concurrency:
-  group: ci-solidity-${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true

40-44: Improve cache key specificity.

The cache key could be more specific to improve cache hits and prevent unintended cache sharing.

         with:
           path: contracts
-          key: ci-solidity-${{ github.ref }}
+          key: ci-solidity-${{ github.ref }}-${{ hashFiles('contracts/**/**.sol') }}

73-74: Enhance test execution and reporting.

Consider adding more test options and capturing test results:

  • Add fail-fast option
  • Capture test results for GitHub Actions
       - name: Run Forge tests
-        run: forge test -vvv
+        run: |
+          forge test -vvv --fail-fast > test-results.txt
+          cat test-results.txt
+      
+      - name: Upload test results
+        if: always()
+        uses: actions/upload-artifact@v4
+        with:
+          name: forge-test-results
+          path: contracts/test-results.txt

94-95: Expand linting scope.

Consider checking both source and test files for consistent formatting.

       - name: Run Forge fmt
-        run: forge fmt contracts/src --check
+        run: forge fmt . --check

1-2: Add workflow status badge.

Consider adding a workflow status badge to your README.md to provide visibility into the CI status.

Add this markdown to your README.md:

[![CI Solidity](https://github.com/xmtp/xmtpd/actions/workflows/solidity.yml/badge.svg)](https://github.com/xmtp/xmtpd/actions/workflows/solidity.yml)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b9e0ffc and 341c74e.

📒 Files selected for processing (6)
  • .github/workflows/lint.yml (1 hunks)
  • .github/workflows/solidity-slither.yml (0 hunks)
  • .github/workflows/solidity.yml (1 hunks)
  • .github/workflows/test.yml (1 hunks)
  • dev/contracts/deploy-ephemeral (1 hunks)
  • dev/contracts/deploy-testnet (1 hunks)
💤 Files with no reviewable changes (1)
  • .github/workflows/solidity-slither.yml
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/lint.yml
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/solidity.yml

47-47: shellcheck reported issue in this script: SC2086:info:1:37: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (3)
dev/contracts/deploy-ephemeral (1)

9-9: Verify the forge command

The forge soldeer update command seems unusual. Should this be forge update instead?

✅ Verification successful

Let me gather more information to verify if this is a typo or a custom command.


Let me check the content of the soldeer.lock file and look for any custom scripts that might define this command.


Let me check the foundry.toml configuration to understand the soldeer setup.


forge soldeer update is a valid command - it's a dependency management tool

Based on the evidence found in the codebase:

  • The presence of soldeer.lock file with dependency specifications
  • Configuration in foundry.toml with a [soldeer] section
  • Multiple deployment scripts consistently using this command

This appears to be a legitimate dependency management tool for Forge/Foundry, similar to npm's package-lock.json, used to manage Solidity dependencies.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if 'soldeer' is a valid forge subcommand
forge --help | grep -A 5 "Available Commands:"

# Check if this command exists in other files
rg "forge soldeer" -A 2 -B 2

Length of output: 1062


Script:

#!/bin/bash
# Check for any documentation or README files that might explain the tooling
fd -e md | xargs rg -i "forge|soldeer" -A 2 -B 2

# Check if there's any custom script or configuration related to soldeer
fd soldeer

Length of output: 1388


Script:

#!/bin/bash
# Check the content of soldeer.lock
cat contracts/soldeer.lock

# Look for any custom scripts or configurations that might define this command
fd -e toml -e json | xargs rg "soldeer"

Length of output: 758


Script:

#!/bin/bash
# Check the content of foundry.toml
cat contracts/foundry.toml

Length of output: 396

dev/contracts/deploy-testnet (1)

7-8: Fix typo in comment

The word "dependencies" is misspelled in the comment.

-# Update depencencies
+# Update dependencies

The forge soldeer update command needs verification as mentioned in the deploy-ephemeral script review.

.github/workflows/test.yml (1)

6-7: LGTM: Workflow trigger optimization

The addition of paths-ignore for the contracts/** directory aligns perfectly with the PR objective of separating Solidity CI concerns. This ensures that the test workflow only runs when relevant files are changed.

Also applies to: 9-10

.github/workflows/solidity.yml Show resolved Hide resolved
.github/workflows/solidity.yml Show resolved Hide resolved
.github/workflows/solidity.yml Show resolved Hide resolved
@fbac fbac enabled auto-merge (squash) December 9, 2024 20:24
Copy link
Collaborator

@mkysel mkysel left a comment

Choose a reason for hiding this comment

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

looks good

@fbac fbac disabled auto-merge December 10, 2024 16:25
@fbac fbac merged commit b95ff7e into main Dec 10, 2024
7 checks passed
@fbac fbac deleted the ci/solidity branch December 10, 2024 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants