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

chore: fix circle ci build and test on master #1527

Merged
merged 14 commits into from
Dec 12, 2024
Merged

Conversation

rodrigopavezi
Copy link
Member

@rodrigopavezi rodrigopavezi commented Dec 10, 2024

Problem

Integration tests which requires smart contracts deployed are failing as smart contract packages is not built.

Description of the changes

  • Increase resource class for build job and test-integration-test-smart-contracts job to xlarge
  • Update CircleCI configuration to skip Nx cache during next release
  • build smart contract before test commands
  • set unit test concurrency to 2, integration test concurrency to 1
  • move test-request-node and test-ethereum-storage from unit test job to integration test job

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Enhanced build and testing processes for improved efficiency.
    • Added new steps to build smart contracts in integration testing jobs.
    • Introduced a step to build all packages in the release job.
    • Updated build command for optimization in the build job.
  • Improvements
    • Increased resource allocation for build and testing jobs.
    • Simplified test commands by removing unnecessary flags.
    • Added caching configuration to improve task execution speed.
    • Enhanced ignore rules for specific directories related to smart contracts and caching.

…nd remove 'since master' flag from test commands
Copy link
Contributor

coderabbitai bot commented Dec 10, 2024

Walkthrough

The changes in this pull request focus on enhancing the build and testing processes within the .circleci/config.yml file. Notable updates include increasing the resource_class for the build job and simplifying commands for building and testing workflows. New steps have been introduced for building smart contracts in integration testing jobs, and an additional step for building all packages has been added to the next-release job. Modifications to the .gitignore and nx.json files further optimize the CI/CD process without altering the fundamental job structure.

Changes

File Change Summary
.circleci/config.yml - Updated resource_class from large to xlarge for build job.
- Updated command in build job from yarn build --since master to yarn build.
- Updated command in test-unit job to exclude specific packages from testing.
- Added Build smart-contracts step in test-integration-with-smart-contracts job.
- Added Build smart-contracts step in test-integration-with-request-node job.
- Updated commands in integration test jobs to specify scopes for testing.
- Added Build all packages with lerna step in next-release job.
- Updated command in next-release job to yarn build --skip-nx-cache.
.gitignore - Updated entry for /packages/smart-contracts/cache-zk/ to ensure it is ignored.
- Added .nx-cache/ entry to ignore.
nx.json - Added cacheDirectory set to .nx-cache in tasksRunnerOptions.
- Added parallel set to 3 in tasksRunnerOptions.
- Added fileHashVersion set to 2 in tasksRunnerOptions.

Possibly related PRs

  • feat: Develop SingleRequestProxy Smart Contracts #1453: The changes in the main PR enhance the CircleCI configuration for testing and building smart contracts, which is directly related to the development of the SingleRequestProxy smart contracts in this PR.
  • refactor: circle ci scripts  #1510: This PR modifies the .circleci/config.yml file, similar to the main PR, by changing job configurations and resource classes, indicating a direct relationship in terms of CircleCI setup.
  • fix: next release #1517: This PR also updates the .circleci/config.yml file by adding an environment variable to manage memory usage during builds, which aligns with the resource management aspect of the main PR's changes.

Suggested reviewers

  • rodrigopavezi
  • sstefdev
  • leoslr
  • aimensahnoun

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 generate docstrings to generate docstrings for this PR. (Experiment)
  • @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.

.circleci/config.yml Outdated Show resolved Hide resolved
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

🧹 Outside diff range and nitpick comments (1)
.circleci/config.yml (1)

159-161: Consider DRYing up the duplicated smart contract build step

The smart contract build step is duplicated in both integration test jobs. Consider extracting it into a reusable command like the existing step_graph_deploy and step_wait_for_node.

 references:
+  step_build_smart_contracts: &step_build_smart_contracts
+    name: 'Build smart-contracts'
+    command: 'yarn build --scope @requestnetwork/smart-contracts'

   # ... existing references ...

 jobs:
   test-integration-with-smart-contracts:
     steps:
       - run:
-          name: 'Build smart-contracts'
-          command: 'yarn build --scope @requestnetwork/smart-contracts'
+          <<: *step_build_smart_contracts

   test-integration-with-request-node:
     steps:
       - run:
-          name: 'Build smart-contracts'
-          command: 'yarn build --scope @requestnetwork/smart-contracts'
+          <<: *step_build_smart_contracts

Also applies to: 194-196

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between acf11c0 and c15bc6b.

📒 Files selected for processing (1)
  • .circleci/config.yml (4 hunks)
🔇 Additional comments (2)
.circleci/config.yml (2)

Line range hint 306-349: LGTM! The workflow dependencies are well structured

The workflow configuration ensures that:

  1. All tests run after the build job
  2. The next-release job runs only after all tests pass
  3. The release process is properly gated by the test suite

81-81: Reconsider skipping nx cache as it may impact build performance

The change from --since master to --skip-nx-cache forces a full rebuild of all packages, which could significantly increase build times. While this might temporarily fix the build issues, it's not an optimal long-term solution.

Consider these alternatives:

  1. Use nx's built-in dependency graph to ensure smart contracts are built first: nx affected --target=build
  2. Keep incremental builds but explicitly include smart contracts: yarn build --since master --include @requestnetwork/smart-contracts

Let's analyze the nx configuration to understand the dependency graph:

Also applies to: 280-282

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

🧹 Outside diff range and nitpick comments (2)
.circleci/config.yml (2)

63-63: Consider cost implications of xlarge resource class

While increasing the resource class will help with build performance, it also increases CI costs. Ensure this upgrade is necessary by monitoring resource utilization metrics.


Line range hint 111-117: Consider organizing tests into focused groups

The current approach of listing individual packages to ignore/include makes maintenance challenging. Consider:

  1. Organizing packages into test groups (e.g., core, integration, smart-contracts)
  2. Using package.json workspaces or lerna to define these groups

Also applies to: 168-173

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f110bec and 16c6433.

📒 Files selected for processing (1)
  • .circleci/config.yml (8 hunks)
🔇 Additional comments (2)
.circleci/config.yml (2)

Line range hint 174-185: LGTM! Test results properly configured

The addition of test result storage for ethereum-storage will help with debugging and monitoring test health.


81-81: Verify impact of disabling incremental builds

Skipping Nx cache and building all packages will ensure consistency but may significantly increase build times. Consider:

  1. Adding comments explaining why cache is skipped
  2. Only skipping cache for specific packages that require fresh builds

Also applies to: 285-286

✅ Verification successful

Let me try a different approach to verify the impact of disabling incremental builds.


Let me try one final verification to understand the build dependencies and smart contract relationships.


Based on the gathered information, I can now provide a final response:

Build strategy change is justified and necessary

The change from --since master to --skip-nx-cache is intentional and necessary because:

  1. Smart contract builds are required for integration tests to pass, as evidenced by PR chore: fix circle ci build and test on master #1527 which fixes failing tests due to missing smart contract builds
  2. The project has proper build dependencies configured in nx.json, ensuring correct build order
  3. The codebase has extensive smart contract dependencies across multiple packages, making incremental builds risky for contract-dependent tests

The increased build time is an acceptable trade-off for ensuring reliable test execution, especially for smart contract-related changes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check average build time difference
echo "Checking recent workflow durations..."
gh api -X GET /repos/RequestNetwork/requestNetwork/actions/workflows -q '.workflows[] | select(.name=="build-and-test") | .id' | \
xargs -I {} gh api -X GET "/repos/RequestNetwork/requestNetwork/actions/workflows/{}/runs?per_page=10" -q \
'.workflow_runs[] | select(.conclusion=="success") | {created_at, updated_at, duration: (fromdateiso8601(updated_at) - fromdateiso8601(created_at))} | .duration'

Length of output: 485


Script:

#!/bin/bash
# Check for any documentation or comments explaining the build strategy
echo "Checking for build-related comments in config and docs..."
rg -i "(\bnx\b.*cache|build.*strategy|incremental.*build)" -g "!{node_modules,dist}/*" -A 2

# Check package.json for build scripts
echo -e "\nChecking build scripts configuration..."
fd "package.json" --type f --exec cat {} \; | jq -r 'select(.scripts.build != null) | .scripts.build'

# Look for previous build configurations
echo -e "\nChecking git history for build command changes..."
git log -p --no-merges -S "yarn build" -- .circleci/config.yml | head -n 50

Length of output: 1223


Script:

#!/bin/bash
# Check for smart contract build dependencies
echo "Checking for smart contract build dependencies..."
rg -l "smart.*contract|solidity|ethereum" -g "!{node_modules,dist}/*" --type ts

# Check for build order dependencies
echo -e "\nChecking for build dependencies in nx.json..."
fd nx.json --type f --exec cat {} \;

# Check for recent build-related issues or PRs
echo -e "\nChecking recent PRs mentioning build issues..."
gh pr list --state all --limit 10 --search "build in:title,body" --json title,body,number

Length of output: 44464

.circleci/config.yml Outdated Show resolved Hide resolved
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

🧹 Outside diff range and nitpick comments (2)
.circleci/config.yml (2)

81-81: Consider selective package building for non-master branches

While building all packages ensures completeness, it may increase build times unnecessarily. Consider:

  1. Using --since master for feature branches
  2. Only building all packages on master branch
command: |
  if [[ "$CIRCLE_BRANCH" == "master" ]]; then
    yarn build
  else
    yarn build --since master
  fi

Also applies to: 86-88


114-121: Optimize test execution strategy

The current configuration has several potential improvements:

  1. Consider using test groups instead of listing individual packages
  2. Evaluate if concurrency=2 is optimal for unit tests
  3. Document why specific packages are excluded/included

Example test group configuration:

references:
  unit_test_packages: &unit_test_packages
    - "@requestnetwork/advance-logic"
    - "@requestnetwork/currency"
    # ... other packages

  integration_test_packages: &integration_test_packages
    - "@requestnetwork/request-node"
    - "@requestnetwork/ethereum-storage"
    # ... other packages

Also applies to: 169-175

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3cfe208 and b28d88c.

📒 Files selected for processing (1)
  • .circleci/config.yml (7 hunks)
🔇 Additional comments (2)
.circleci/config.yml (2)

63-63: Verify resource class requirements

The increase in resource class from large to xlarge for both build and integration test jobs will provide more computing power, but also increase CI costs. Please ensure this upgrade is necessary by:

  1. Monitoring resource utilization in previous builds
  2. Considering alternative optimizations like caching or parallel execution

Also applies to: 156-156


283-285: Document cache skipping rationale

The --skip-nx-cache flag forces rebuilding of all packages, which was previously questioned. While this ensures reliability, it impacts build performance. Consider:

  1. Adding a comment explaining why cache skipping is necessary
  2. Making it conditional based on specific scenarios
  3. Monitoring the impact on build times
- run:
    name: 'Build all packages with lerna'
    command: |
      # Skip cache on next release to ensure all packages are rebuilt
      # This prevents issues with smart contract dependencies
      yarn build --skip-nx-cache

@MantisClone
Copy link
Member

@coderabbitai full review

Copy link
Contributor

coderabbitai bot commented Dec 11, 2024

✅ Actions performed

Full review triggered.

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

🧹 Outside diff range and nitpick comments (2)
nx.json (1)

8-8: Consider reducing parallel execution limit

The parallel setting of 3 might be too aggressive for CI resources, especially considering the previous build failures. Consider reducing it to 2 to match the unit test concurrency setting.

-        "parallel": 3,
+        "parallel": 2,
.circleci/config.yml (1)

169-175: Consider extracting package scopes to a shared variable

The package scope lists are duplicated across jobs. Consider defining them in the references section for better maintainability.

Add to references section:

integration_test_packages: &integration_test_packages
  - @requestnetwork/request-node
  - @requestnetwork/ethereum-storage
  - @requestnetwork/request-client.js
  - @requestnetwork/smart-contracts
  - @requestnetwork/payment-detection
  - @requestnetwork/payment-processor
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between efcf1c6 and b28d88c.

📒 Files selected for processing (3)
  • .circleci/config.yml (7 hunks)
  • .gitignore (1 hunks)
  • nx.json (1 hunks)
🔇 Additional comments (5)
.gitignore (1)

44-46: LGTM!

The cache directory entries are properly configured to support the new nx caching strategy and smart contract builds.

.circleci/config.yml (4)

63-63: Resource upgrade and build command simplification look good

The xlarge resource class should help with build performance, and removing the --since master flag ensures all packages are built.

Also applies to: 81-81


114-121: Test concurrency and package filtering look good

The separation of packages between unit and integration tests with appropriate concurrency settings should help with stability.


283-285: Verify skip-nx-cache impact

The --skip-nx-cache flag in the next-release job will ensure fresh builds, but might increase build time significantly.

This aligns with the previous discussion about skipping nx cache for releases.


86-88: Verify workspace persistence configuration

Ensure that the new cache paths are correctly persisted and restored across jobs.

✅ Verification successful

Let me gather more information about the workspace persistence configuration.


Workspace persistence configuration is correctly set up

The workspace persistence is properly configured:

  • The paths being cached (./.nx-cache, packages/*/dist, packages/*/*.tsbuildinfo) are persisted in the persist_to_workspace step
  • These paths are consistently restored across multiple jobs using attach_workspace at the same working directory
  • The root path and overall workspace configuration follows CircleCI best practices
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the cache paths exist in other jobs
rg -A 5 "attach_workspace:" .circleci/config.yml

Length of output: 1942


Script:

#!/bin/bash
# Check for persist_to_workspace configurations
rg -A 5 "persist_to_workspace:" .circleci/config.yml

Length of output: 207

@rodrigopavezi rodrigopavezi merged commit 86df01b into master Dec 12, 2024
10 checks passed
@rodrigopavezi rodrigopavezi deleted the fix/circleci-build branch December 12, 2024 12:27
@coderabbitai coderabbitai bot mentioned this pull request Jan 16, 2025
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.

3 participants