Skip to content

Feat: totalSize attribute#9524

Merged
Meldiron merged 2 commits intofeat-sitesfrom
feat-deployment-total-size
Mar 18, 2025
Merged

Feat: totalSize attribute#9524
Meldiron merged 2 commits intofeat-sitesfrom
feat-deployment-total-size

Conversation

@Meldiron
Copy link
Copy Markdown
Contributor

@Meldiron Meldiron commented Mar 17, 2025

What does this PR do?

Adds totalSize to deployment, sum of soruceSize and outputSize. Storing this in DB allows easy integration and consistency with Console, plus ability to query by this total.

Test Plan

Tests updated

Related PRs and Issues

x

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

Summary by CodeRabbit

  • New Features

    • Added an automated review configuration to streamline quality checks on selected branches.
    • Enhanced deployments and project management with comprehensive file size tracking that aggregates source and build metrics.
    • Improved numeric initialization for deployment properties, ensuring consistent metric reporting.
  • Tests

    • Expanded test coverage to validate the updated deployment metrics and ensure accurate file size reporting during various operations.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 17, 2025

Walkthrough

This pull request introduces a new auto-review configuration in the .coderabbit.yaml file by defining base branches. It also adds a totalSize attribute in several deployments modules and the projects collection schema to track cumulative file sizes in deployments, along with associated index and validation updates. Furthermore, the tests for functions and sites have been updated to assert the correct values for sourceSize, buildSize, and totalSize.

Changes

File(s) Change Summary
.coderabbit.yaml Added reviews.auto_review.base_branches with values main, 1.6.x, 1.7.x, and feat-sites.
app/config/collections/projects.php Introduced a new totalSize attribute (integer, default null) and a corresponding index key _key_totalSize for the projects collection.
src/Appwrite/.../Functions/Http/Deployments/Create.php,
src/Appwrite/.../Functions/Http/Deployments/Duplicate/Create.php,
src/Appwrite/.../Functions/Workers/Builds.php,
src/Appwrite/.../Sites/Http/Deployments/Create.php,
src/Appwrite/.../Sites/Http/Deployments/Duplicate/Create.php
Added a new totalSize field to deployment documents. In some cases it is set directly from $fileSize or computed from sourceSize (and buildSize), and duplicate deployments now initialize additional attributes (buildDuration, buildSize) to 0.
src/Appwrite/.../Database/Validator/Queries/Deployments.php,
src/Appwrite/.../Response/Model/Deployment.php
Updated deployment schema and validation by adding the totalSize attribute (integer, default 0, with an example provided) as an allowed and described property.
tests/e2e/Services/Functions/FunctionsCustomServerTest.php,
tests/e2e/Services/Sites/SitesCustomServerTest.php
Enhanced test assertions to verify that sourceSize, buildSize, and totalSize are correctly set after deployments and duplications.

Suggested reviewers

  • vermakhushboo

Poem

I'm a little rabbit on a code-filled spree,
Hopping through configs with joyful glee.
Total size added, bytes in a neat array,
Auto-review branches guiding our way.
With every deployment, I bounce in delight –
Celebrating changes from morning to night!
🥕🐇

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
  • @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.

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.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 17, 2025

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
binutils 2.42-r0 CVE-2025-0840 HIGH
libexpat 2.6.4-r0 CVE-2024-8176 HIGH
libxml2 2.12.7-r0 CVE-2024-56171 HIGH
libxml2 2.12.7-r0 CVE-2025-24928 HIGH
libxml2 2.12.7-r0 CVE-2025-27113 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 17, 2025

✨ Benchmark results

  • Requests per second: 886
  • Requests with 200 status code: 159,467
  • P99 latency: 0.210468365

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 886 1,193
200 159,467 214,831
P99 0.210468365 0.15721774

Copy link
Copy Markdown
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

🧹 Nitpick comments (1)
.coderabbit.yaml (1)

1-7: Missing newline at end of file.

The YAML configuration looks good, but there is a linting issue detected. YAMLlint reports that there's no newline character at the end of the file.

Add a newline character at the end of the file to fix this linting issue:

 - 1.6.x
 - 1.7.x
 - feat-sites # temporary until merged to 1.7.x
+
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 7-7: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6c193f4 and fd4b435.

📒 Files selected for processing (11)
  • .coderabbit.yaml (1 hunks)
  • app/config/collections/projects.php (2 hunks)
  • src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php (2 hunks)
  • src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php (1 hunks)
  • src/Appwrite/Platform/Modules/Functions/Workers/Builds.php (3 hunks)
  • src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php (2 hunks)
  • src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php (1 hunks)
  • src/Appwrite/Utopia/Database/Validator/Queries/Deployments.php (1 hunks)
  • src/Appwrite/Utopia/Response/Model/Deployment.php (1 hunks)
  • tests/e2e/Services/Functions/FunctionsCustomServerTest.php (5 hunks)
  • tests/e2e/Services/Sites/SitesCustomServerTest.php (4 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.coderabbit.yaml

[error] 7-7: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms (19)
  • GitHub Check: E2E Service Test (Webhooks)
  • GitHub Check: E2E Service Test (Locale)
  • GitHub Check: E2E Service Test (VCS)
  • GitHub Check: E2E Service Test (Messaging)
  • GitHub Check: E2E Service Test (Storage)
  • GitHub Check: E2E Service Test (FunctionsSchedule)
  • GitHub Check: E2E Service Test (Teams)
  • GitHub Check: E2E Service Test (Realtime)
  • GitHub Check: E2E Service Test (Proxy)
  • GitHub Check: E2E Service Test (Sites)
  • GitHub Check: E2E Service Test (Projects)
  • GitHub Check: E2E Service Test (Users)
  • GitHub Check: E2E Service Test (GraphQL)
  • GitHub Check: E2E Service Test (Account)
  • GitHub Check: E2E Service Test (Functions)
  • GitHub Check: E2E Service Test (Avatars)
  • GitHub Check: E2E Service Test (Console)
  • GitHub Check: Benchmark
  • GitHub Check: E2E General Test
🔇 Additional comments (25)
src/Appwrite/Utopia/Database/Validator/Queries/Deployments.php (1)

10-10: Good addition of totalSize to the allowed attributes.

This change correctly adds the new attribute to the ALLOWED_ATTRIBUTES array, which will enable querying deployments based on this value. This supports the PR objective of enhancing integration with the Console and providing query capabilities.

src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php (2)

246-246: Successfully added totalSize attribute to deployment record.

The new totalSize attribute is correctly initialized with the $fileSize value, which matches the current behavior of sourceSize. This change supports the PR's objective of introducing the attribute that represents the total deployment size.


304-304: Consistently implemented totalSize attribute for chunked uploads.

The totalSize attribute is correctly added to the chunked upload case, maintaining consistency with the non-chunked implementation.

src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php (1)

103-103: Correctly propagated totalSize attribute during deployment duplication.

The new totalSize attribute is successfully added to the duplicate deployment, using the source deployment's sourceSize value with a fallback to 0 if not present.

src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php (2)

237-237: Good implementation of the new totalSize attribute.

The addition of totalSize attribute is correctly implemented as part of the deployment creation process, initializing it with the value of $fileSize. This matches the PR's objective of introducing a totalSize attribute to enhance integration with the Console.


268-268: Consistent implementation of totalSize in chunked upload scenario.

The totalSize attribute is correctly initialized for chunked uploads as well, ensuring consistency in how deployment size is tracked regardless of the upload method.

src/Appwrite/Utopia/Response/Model/Deployment.php (1)

67-72: Well-defined model rule for totalSize attribute.

The new rule for totalSize is properly defined with the correct type (integer), an appropriate description that clearly explains it represents the sum of source and build output sizes, and sensible default/example values. This addition aligns with the PR objectives and provides the necessary model definition for the new attribute.

src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php (2)

114-114: Good implementation of totalSize in deployment duplication.

The totalSize attribute is correctly initialized during deployment duplication, using the original deployment's sourceSize value. This ensures the new attribute is properly propagated when duplicating deployments.


122-123: Improved initialization of numeric attributes.

Changing the initialization of buildDuration and buildSize from null to explicit 0 values improves type consistency for these numeric fields, which is a good practice.

app/config/collections/projects.php (2)

1553-1563: Proper schema definition for totalSize attribute.

The schema definition for the new totalSize attribute is correctly implemented with the appropriate type (integer), along with necessary metadata for the database schema. This aligns with the model definition in the Response class.


1634-1640: Good addition of index for query performance.

Adding an index for the totalSize attribute is a good practice as it will improve query performance when filtering or sorting by this field. The index is properly configured to sort in ascending order, consistent with the other size-related indexes.

src/Appwrite/Platform/Modules/Functions/Workers/Builds.php (3)

288-289: LGTM: Properly initializing totalSize attribute

Initial setting of totalSize equal to sourceSize during the first stage of deployment makes sense since build hasn't been completed yet.


440-441: LGTM: Consistent approach to initializing totalSize

This mirrors the same pattern used earlier in the file, maintaining consistency in how totalSize is initially set.


725-725: LGTM: Correctly calculating final totalSize value

This properly updates the totalSize attribute to be the sum of buildSize and sourceSize after the build is complete, which aligns with the feature's intent.

tests/e2e/Services/Functions/FunctionsCustomServerTest.php (5)

412-415: LGTM: Good test coverage for initial deployment state

These assertions correctly verify that sourceSize, buildSize, and totalSize are all initially zero before the deployment is processed.


489-494: LGTM: Comprehensive verification of totalSize calculation

Good test assertions that verify both source and build sizes are greater than zero after deployment, and that totalSize equals their sum.


1673-1678: LGTM: Consistent test coverage in cookie execution test

These assertions maintain consistency with other tests, verifying the same properties in a different test scenario.


2061-2065: LGTM: Test coverage for duplicate deployment scenario

Important test case that verifies the initial state of a duplicate deployment where buildSize is 0 but sourceSize is already copied, ensuring totalSize equals just the sourceSize at this stage.


2076-2081: LGTM: Complete test coverage for post-execution state

These assertions correctly verify that after execution, both source and build sizes are populated and totalSize properly equals their sum.

tests/e2e/Services/Sites/SitesCustomServerTest.php (6)

363-369: Great test coverage for the new totalSize attribute

The assertions correctly verify that the totalSize is the sum of sourceSize and buildSize after a successful deployment response. This is a good implementation of the new feature requirement.


1520-1525: Good validation of initial deployment state

These assertions properly verify that when a template deployment is initially created, all size attributes (sourceSize, buildSize, totalSize) are set to 0, which makes sense since no resources have been allocated yet.


1547-1553: Good validation of deployment after completion

This test section correctly verifies that after the deployment completes, the totalSize reflects the sum of sourceSize and buildSize. This ensures the integrity of the size calculations throughout the deployment lifecycle.


2003-2014: Good implementation of duplicate deployment check

The test correctly verifies that for a newly duplicated deployment, the totalSize initially equals the sourceSize since buildSize is 0 at creation time. This is a good edge case to test.


2015-2019: Well-structured wait for deployment activation

Good implementation of assertEventually to wait for the deployment to be activated and properly set as the site's active deployment.


2023-2029: Complete verification of final deployment state

This section thoroughly validates that after the deployment is fully processed, the totalSize correctly equals the sum of sourceSize and buildSize. This ensures the size calculations are maintained properly throughout the deployment lifecycle.

@Meldiron Meldiron merged commit a0d4e47 into feat-sites Mar 18, 2025
31 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Mar 26, 2025
2 tasks
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