Skip to content

CLI-1711: [NCI] Database and File commands support#1959

Closed
jigar-shah-acquia wants to merge 44 commits intoacquia:mainfrom
jigar-shah-acquia:CLI-1711
Closed

CLI-1711: [NCI] Database and File commands support#1959
jigar-shah-acquia wants to merge 44 commits intoacquia:mainfrom
jigar-shah-acquia:CLI-1711

Conversation

@jigar-shah-acquia
Copy link
Contributor

@jigar-shah-acquia jigar-shah-acquia commented Feb 3, 2026

Motivation

This change adds support for NCI database, file, and environment commands in ACLI. These commands enable internal workflows for managing site instances, including database backups, database and file copy operations, environment log creation, and Varnish cache clearing, without exposing raw API endpoints directly to customers.

This work also cleans up previous non-standard API spec handling and aligns ACLI with service-owned and cx-api-spec definitions.

Fixes CLI-1711


Proposed Changes

  • Implement support for the following custom ACLI commands:
    • api:environment-v3:log-create
    • api:environments-v3:clear-caches
    • api:environments-v3:log-list
    • api:environments-v3:log-download
    • api:environments-v3:code-switch
    • api:site-instances:database:backups:create
    • api:site-instances:database:copy
    • api:site-instances:files:copy
  • Remove non-cx-api-spec additions previously committed to acquia-spec.json (from PR CLI-1696: MEO commands #1955).
  • Move non-standard/generated API specs into a secure GitHub Actions secret instead of version control.
  • Update the build process to merge API specs from secrets with existing stable specs.
  • Remove _links from API responses to align with expected CLI output.
  • Mark these commands as deprecated so they are not exposed directly to customers.
  • Add and validate a hand-rolled OpenAPI spec (post-log-openapi.json) for environment log creation.
  • Address issues identified via mutation testing and improve overall test coverage.

Alternatives Considered

  • Exposing raw API endpoints directly through ACLI was considered but rejected to avoid exposing unstable or internal APIs to customers.
  • Using only backend service OpenAPI specs was considered, but cx-api-spec was preferred for stability and consistency where available.

Testing Steps

  1. Follow the contribution guide to set up the development environment or download a pre-built acli.phar.
  2. If running from source, clear the kernel cache to load new and updated commands:
    ./bin/acli ckc
  3. Run the existing CLI test suite to check for regressions.
  4. Validate new functionality:
  • Create a database backup for a site instance.
  • Perform database copy between site instances.
  • Perform file copy between site instances.
  • Create environment logs using the translation-based endpoint.
  • Attempt to clear Varnish cache (note: may be blocked due to N3 proxy limitations).
  1. Verify command output formatting, error handling, and schema validation align with ACLI standards.

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Try the dev build for this PR: https://acquia-cli.s3.amazonaws.com/build/pr/1959/acli.phar

curl -OL https://acquia-cli.s3.amazonaws.com/build/pr/1959/acli.phar
chmod +x acli.phar

@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.28%. Comparing base (481e78d) to head (d8cb766).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1959   +/-   ##
=========================================
  Coverage     92.28%   92.28%           
+ Complexity     1916     1910    -6     
=========================================
  Files           122      122           
  Lines          6995     6987    -8     
=========================================
- Hits           6455     6448    -7     
+ Misses          540      539    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jigar-shah-acquia jigar-shah-acquia marked this pull request as ready for review February 5, 2026 10:07
Copilot AI review requested due to automatic review settings February 5, 2026 10:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for NCI database, file, and environment commands in ACLI by implementing a system to merge additional API specs from environment variables or GitHub Actions secrets. The changes enable internal workflows for managing site instances without exposing unstable APIs directly to customers.

Changes:

  • Implemented API spec merging logic to combine additional specs from environment variables with base specs
  • Removed previously hardcoded non-standard API endpoints from acquia-spec.json
  • Updated _links removal to apply to all API responses instead of only translation endpoints
  • Modified CI workflow to extract additional API specs from GitHub Actions secrets

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Command/Api/ApiCommandHelper.php Added mergeAdditionalSpecs() method to load and merge additional API specs from environment variables
src/Command/Api/ApiBaseCommand.php Updated mungeResponse() to recursively remove _links from all API responses
assets/acquia-spec.json Removed hardcoded NCI endpoints that are now loaded via additional specs
assets/acquia-spec.version Updated spec version reference
tests/phpunit/src/Commands/Api/ApiCommandTest.php Added comprehensive test coverage for spec merging and _links removal
tests/phpunit/src/Misc/ExceptionListenerTest.php Removed test assertion for log-create help message
src/EventListener/ExceptionListener.php Removed special handling for log-download error message
.github/workflows/ci.yml Added step to extract additional API specs from GitHub Actions secrets

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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