Skip to content

Commit

Permalink
CLI-979: Consolidate update-check logic (#1774)
Browse files Browse the repository at this point in the history
* CLI-979: Consolidate update-check logic

* a

* remove guzzle cache

* fix tests

* upstream

* test updates

* refactor

* fix updates

* fix tests

* update self-update
  • Loading branch information
danepowell committed Aug 27, 2024
1 parent b98f592 commit a700f92
Show file tree
Hide file tree
Showing 25 changed files with 146 additions and 363 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BUGSNAG_KEY=abcd1234
AMPLITUDE_KEY=acbd1234
ACLI_VERSION=1.0.0
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ drupal

cx-api-spec
gardener
.env

// Artifacts from mutation testing
*.cache
10 changes: 1 addition & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,11 @@ Be sure to validate and test your code locally using the provided Composer test
To test changes in production mode, build and run `acli.phar` using this process. The _build-release_ stage of [`.github/workflows/ci.yml`](.github/workflows/ci.yml) follows a similar process.

1. Install Composer production dependencies: `composer install --no-dev --optimize-autoloader`
2. Create a `.env` file with Bugsnag and Amplitude keys
2. Populate `.env`: `cp .env.example .env`
3. Clear and rebuild your Symfony caches: `./bin/acli ckc && ./bin/acli cc`
4. Install Box (only need to do this once): `composer box-install`
5. Compile phar: `composer box-compile`

### Testing the `update` command

Any changes to the `acli update` command should be manually tested using the following steps:

1. Replace `@package_version@` on this line with `1.0.0` or any older version string: https://github.com/acquia/cli/blob/v1.0.0/bin/acli#L84
1. Build acli.phar as described above.
1. Now test: `./var/acli.phar self:update`

### Writing tests

New code should be covered at 100% (or as close to it as reasonably possible) by PHPUnit tests. It should also minimize the number of escaped mutants (as close to 0% as reasonably possible), which will appear as annotations on your PR after unit tests run.
Expand Down
7 changes: 4 additions & 3 deletions bin/acli
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use Acquia\Cli\Exception\AcquiaCliException;
use Acquia\Cli\Helpers\LocalMachineHelper;
use Dotenv\Dotenv;
use SelfUpdate\SelfUpdateCommand;
use SelfUpdate\SelfUpdateManager;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
Expand Down Expand Up @@ -93,14 +94,14 @@ if (!getenv('ACLI_REPO_ROOT')) {
$application = $container->get(Application::class);
/** @var OutputInterface $output */
$output = $container->get(OutputInterface::class);
$application->setName('Acquia CLI');
$application->setVersion(getenv('ACLI_VERSION'));
/** @var ApiCommandHelper $helper */
$helper = $container->get(ApiCommandHelper::class);
$application->addCommands($helper->getApiCommands( __DIR__ . '/../assets/acquia-spec.json', 'api', $container->get(ApiCommandFactory::class)));
$application->addCommands($helper->getApiCommands( __DIR__ . '/../assets/acsf-spec.json', 'acsf', $container->get(AcsfCommandFactory::class)));
try {
$application->add(new SelfUpdateCommand($application->getName(), $application->getVersion(), 'acquia/cli'));
/** @var SelfUpdateManager $selfUpdateManager*/
$selfUpdateManager = $container->get(SelfUpdateManager::class);
$application->add(new SelfUpdateCommand($selfUpdateManager));
}
catch (\UnexpectedValueException) {
// Do nothing for development builds.
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
"acquia/drupal-environment-detector": "^1.2.0",
"bugsnag/bugsnag": "^3.0",
"composer/semver": "^3.3",
"consolidation/self-update": "dev-main as 2.1.0",
"consolidation/self-update": "3.0.0-alpha1 as 2.1.0",
"dflydev/dot-access-data": "^3",
"grasmash/expander": "^3",
"guzzlehttp/guzzle": "^7.4",
"http-interop/http-factory-guzzle": "^1.0",
"kevinrob/guzzle-cache-middleware": "^5",
"laminas/laminas-validator": "^2.20.0",
"league/csv": "^9.8",
"loophp/phposinfo": "^1.7.2",
Expand Down
Loading

0 comments on commit a700f92

Please sign in to comment.