Skip to content

Commit

Permalink
Updated memcached dependency and added testing. (#83)
Browse files Browse the repository at this point in the history
* Updated memcached dependency and added testing.

* Add separate test for memcached.

* Feed the linter.
  • Loading branch information
reynoldsalec authored Feb 21, 2024
1 parent e5b6e17 commit bc618fd
Show file tree
Hide file tree
Showing 15 changed files with 806 additions and 828 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pr-drupal-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
matrix:
leia-tests:
- drupal
- acquia-custom
lando-version:
- 3-dev-slim
os:
Expand Down
17 changes: 13 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
## v1.1.0 - [February 21, 2024](https://github.com/lando/acquia/releases/tag/v1.1.0)

* Updated memcached plugin to [v1.1.0](https://github.com/lando/memcached/releases/tag/v1.1.0).
* Added testing of memcached.
* Updated deps.

## v1.0.0 - [December 7, 2023](https://github.com/lando/acquia/releases/tag/v1.0.0)
* Dialed fully for `lando update`

* Dialed fully for `lando update`

## v0.10.0 - [October 5, 2023](https://github.com/lando/acquia/releases/tag/v0.10.0)

* Added a "wait for user" script to ensure user is loaded before cloning repo. [lando/core#71](https://github.com/lando/core/pull/71)

## v0.9.0 - [July 3, 2023](https://github.com/lando/acquia/releases/tag/v0.9.0)
* Removed bundle-dependencies and version-bump-prompt from plugin.
* Updated package to use prepare-release-action.
* Updated documentation to reflect new release process.

* Removed bundle-dependencies and version-bump-prompt from plugin.
* Updated package to use prepare-release-action.
* Updated documentation to reflect new release process.

## v0.8.0 - [May 17, 2023](https://github.com/lando/acquia/releases/tag/v0.8.0)

Expand Down
34 changes: 17 additions & 17 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ module.exports = (app, lando) => {
if (answers.key && answers.secret) {
const api = new API();
return api.auth(answers.key, answers.secret, true, true)
.then(() => api.getAccount())
.then(account => {
// This is good auth, lets update our cache
const cache = {key: answers.key, label: account.mail, secret: answers.secret};
// Reset this apps metacache
lando.cache.set(app.metaCache, _.merge({}, app.meta, cache), {persist: true});
// Reset the acquia key cache
const keys = utils.sortKeys(app.acquiaKeys, app.hostKeys, [cache]);
lando.cache.set(app.acquiaKeyCache, keys, {persist: true});
// Blow away tooling cache so we can reset our pull commands
lando.cache.remove(`${app.name}.tooling.cache`);
})
// Throw some sort of error
// NOTE: this provides some error handling when we are completely non-interactive
.catch(err => {
throw (_.has(err, 'response.data')) ? new Error(err.response.data) : err;
});
.then(() => api.getAccount())
.then(account => {
// This is good auth, lets update our cache
const cache = {key: answers.key, label: account.mail, secret: answers.secret};
// Reset this apps metacache
lando.cache.set(app.metaCache, _.merge({}, app.meta, cache), {persist: true});
// Reset the acquia key cache
const keys = utils.sortKeys(app.acquiaKeys, app.hostKeys, [cache]);
lando.cache.set(app.acquiaKeyCache, keys, {persist: true});
// Blow away tooling cache so we can reset our pull commands
lando.cache.remove(`${app.name}.tooling.cache`);
})
// Throw some sort of error
// NOTE: this provides some error handling when we are completely non-interactive
.catch(err => {
throw (_.has(err, 'response.data')) ? new Error(err.response.data) : err;
});
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion builders/acquia-memcached.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const _ = require('lodash');
const LandoMemcached = require('@lando/memcached/services/memcached/builder.js');
const LandoMemcached = require('@lando/memcached/builders/memcached.js');

// Builder
module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion builders/acquia-php.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const loadScripts = options => {
const dest = lando.utils.moveConfig(path.join(landoPhpPath, 'scripts'), confDir);
lando.utils.makeExecutable(fs.readdirSync(dest), dest);
lando.log.debug('automoved scripts from %s to %s and set to mode 755',
path.join(landoPhpPath, 'scripts'), confDir);
path.join(landoPhpPath, 'scripts'), confDir);
}
};

Expand Down
11 changes: 11 additions & 0 deletions examples/acquia-custom/.lando.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: acquia-custom
recipe: acquia
config:
php: '8.1'
composer_version: '2.0.7'
xdebug: true
inbox: false
# do not remove this
plugins:
"@lando/acquia": ../..

56 changes: 56 additions & 0 deletions examples/acquia-custom/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Acquia Custom 8Example

This example exists primarily to test the following documentation:

* [Acquia Recipe](https://docs.lando.dev/acquia/config.html)

Start up tests
--------------

Run the following commands to get up and running with this example.

```bash
# Should start up successfully
lando poweroff
lando start
```

Verification commands
---------------------

Run the following commands to validate things are rolling as they should.

```bash
# Should have acli
lando acli -V

# Should be running apache 2.4 by default
lando ssh -s appserver -c "apachectl -V | grep 2.4"
lando ssh -s appserver -c "curl -IL localhost" | grep Server | grep 2.4

# Should use php 8.1
lando php -v | grep "PHP 8.1"

# Should be running mysql 5.7 by default
lando mysql -V | grep 5.7

# Should be able to connect to the database with the default creds
lando mysql acquia -e quit

# Should be running memcached 1.6
lando ssh -s cache -c "memcached --version | grep 1.6"

# Should have xdebug enabled
lando php -m | grep Xdebug
```

Destroy tests
-------------

Run the following commands to trash this app like nothing ever happened.

```bash
# Should be destroyed with success
lando destroy -y
lando poweroff
```
144 changes: 72 additions & 72 deletions inits/acquia.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ const getAutoCompleteSites = (answers, lando, input = null) => {
// how the user is going to provide us with the auth creds
const {key, secret} = getAuthPair(answers);
return api.auth(key, secret, true, true)
.then(() => api.getApplications())
.then(apps => _.map(apps, app => (_.merge({}, {name: app.name, value: app.uuid}, app))))
.then(apps => {
acquiaApps = apps;
return lando.Promise.resolve(acquiaApps);
});
.then(() => api.getApplications())
.then(apps => _.map(apps, app => (_.merge({}, {name: app.name, value: app.uuid}, app))))
.then(apps => {
acquiaApps = apps;
return lando.Promise.resolve(acquiaApps);
});
};

/*
Expand All @@ -103,10 +103,10 @@ module.exports = {
type: 'input',
message: 'Enter an Acquia API token key, visit https://cloud.acquia.com/a/profile/tokens to create one',
when: answers => showKeyEntry(
answers.recipe,
answers['acquia-key'],
lando.config.home,
lando.cache.get(acquiaKeyCache),
answers.recipe,
answers['acquia-key'],
lando.config.home,
lando.cache.get(acquiaKeyCache),
),
validate: (input, answers) => {
// If we end up here we likely need to ask for the secret as well
Expand Down Expand Up @@ -190,13 +190,13 @@ module.exports = {
name: 'get-user-account',
func: (options, lando) => {
return api.auth(options['acquia-key'], options['acquia-secret'], true, true)
.then(() => api.getAccount())
.then(account => {
options['acquia-account'] = account;
options['acquia-keyname'] = `${account.mail}.acquia.lando.id_rsa`;
options['acquia-keycomment'] = `${account.mail}@lando`;
});
},
.then(() => api.getAccount())
.then(account => {
options['acquia-account'] = account;
options['acquia-keyname'] = `${account.mail}.acquia.lando.id_rsa`;
options['acquia-keycomment'] = `${account.mail}@lando`;
});
},
},
{
name: 'generate-key',
Expand All @@ -208,30 +208,30 @@ module.exports = {
const pubKey = path.join(lando.config.userConfRoot, 'keys', `${options['acquia-keyname']}.pub`);
const keyName = options['acquia-key-name'];
return api.auth(options['acquia-key'], options['acquia-secret'], true, true)
.then(() => api.postKey(pubKey, keyName));
.then(() => api.postKey(pubKey, keyName));
},
},
{
name: 'get-git-url',
func: (options, lando) => {
return api.auth(options['acquia-key'], options['acquia-secret'], true, true)
.then(() => api.getEnvironments(options['acquia-app']))
.then(envs => {
// Match our euuid with acquias
const env = utils.getBestEnv(envs);
// Get GIT URL
options['acquia-git-url'] = env.git;
// And some other things
const parts = env.vcs.split('/');
if (parts[0] === 'tags') {
options['acquia-git-branch'] = parts[1];
} else {
options['acquia-git-branch'] = env.vcs;
}
options['acquia-php-version'] = env.php;
options['acquia-site-group'] = env.group;
});
},
.then(() => api.getEnvironments(options['acquia-app']))
.then(envs => {
// Match our euuid with acquias
const env = utils.getBestEnv(envs);
// Get GIT URL
options['acquia-git-url'] = env.git;
// And some other things
const parts = env.vcs.split('/');
if (parts[0] === 'tags') {
options['acquia-git-branch'] = parts[1];
} else {
options['acquia-git-branch'] = env.vcs;
}
options['acquia-php-version'] = env.php;
options['acquia-site-group'] = env.group;
});
},
},
{
name: 'reload-keys',
Expand All @@ -245,47 +245,47 @@ module.exports = {
`${options['acquia-keyname']}`,
remove: 'true',
},
])}],
])}],
build: (options, lando) => {
// Get the info we need to build the relevant config
return api.auth(options['acquia-key'], options['acquia-secret'], true, true)
.then(() => Promise.all([
api.getAccount(),
api.getEnvironments(options['acquia-app']),
]))
.then(data => {
const account = data[0];
const env = utils.getBestEnv(data[1]);
// Write the acli-cli.yml file
utils.writeAcliUuid(options['acquia-app']);
// Reset the name to something human readable
options.name = env.group;
// Merge in other lando config
const landofileConfig = {
config: {
acli_version: 'latest',
ah_application_uuid: options['acquia-app'],
ah_site_group: env.group,
php: env.php,
},
};
.then(() => Promise.all([
api.getAccount(),
api.getEnvironments(options['acquia-app']),
]))
.then(data => {
const account = data[0];
const env = utils.getBestEnv(data[1]);
// Write the acli-cli.yml file
utils.writeAcliUuid(options['acquia-app']);
// Reset the name to something human readable
options.name = env.group;
// Merge in other lando config
const landofileConfig = {
config: {
acli_version: 'latest',
ah_application_uuid: options['acquia-app'],
ah_site_group: env.group,
php: env.php,
},
};

// This is good auth, lets update our cache
const cache = {
key: options['acquia-key'],
label: account.mail,
secret: options['acquia-secret'],
};
// This is good auth, lets update our cache
const cache = {
key: options['acquia-key'],
label: account.mail,
secret: options['acquia-secret'],
};

// Update lando's store of acquia creds
const keys = lando.cache.get(acquiaKeyCache) || [];
lando.cache.set(acquiaKeyCache, utils.sortKeys(keys, [cache]), {persist: true});
// Update app metdata
const metaData = lando.cache.get(`${options.name}.meta.cache`);
lando.cache.set(`${options.name}.meta.cache`, _.merge({}, metaData, cache), {persist: true});
// Update lando's store of acquia creds
const keys = lando.cache.get(acquiaKeyCache) || [];
lando.cache.set(acquiaKeyCache, utils.sortKeys(keys, [cache]), {persist: true});
// Update app metdata
const metaData = lando.cache.get(`${options.name}.meta.cache`);
lando.cache.set(`${options.name}.meta.cache`, _.merge({}, metaData, cache), {persist: true});

// Finish up
return landofileConfig;
});
},
// Finish up
return landofileConfig;
});
},
};
Loading

0 comments on commit bc618fd

Please sign in to comment.