Skip to content

Commit

Permalink
Merge pull request #63 from UN-OCHA/develop
Browse files Browse the repository at this point in the history
Deploy 04-04-2024
  • Loading branch information
attiks authored Apr 4, 2024
2 parents 1550a09 + d6d0fbe commit 3aa0d19
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 57 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ jobs:
uses: cafuego/command-output@main
with:
run: |
docker-compose -f tests/docker-compose.yml up -d
docker compose -f tests/docker-compose.yml up -d
sleep 10
docker ps -a
docker-compose -f tests/docker-compose.yml exec -w /srv/www -T drupal composer install
docker compose -f tests/docker-compose.yml exec -w /srv/www -T drupal composer install
env:
fail-fast: true

Expand All @@ -115,13 +115,13 @@ jobs:
uses: cafuego/command-output@main
with:
run: |
docker-compose -f tests/docker-compose.yml exec -w /srv/www -T drupal /usr/bin/composer run sub-theme
docker compose -f tests/docker-compose.yml exec -w /srv/www -T drupal /usr/bin/composer run sub-theme
- name: PHPCS
id: phpcs
uses: cafuego/command-output@main
with:
run: |
docker-compose -f tests/docker-compose.yml exec -u appuser -w /srv/www -T drupal phpcs -p --report=full --standard=phpcs.xml ./html/modules/custom ./html/themes/custom
docker compose -f tests/docker-compose.yml exec -u appuser -w /srv/www -T drupal phpcs -p --report=full --standard=phpcs.xml ./html/modules/custom ./html/themes/custom
env:
fail-fast: true

Expand All @@ -130,7 +130,7 @@ jobs:
uses: cafuego/command-output@main
with:
run: |
docker-compose -f tests/docker-compose.yml exec -T drupal drush -y si --existing-config minimal install_configure_form.enable_update_status_emails=NULL
docker compose -f tests/docker-compose.yml exec -T drupal drush -y si --existing-config minimal install_configure_form.enable_update_status_emails=NULL
env:
fail-fast: true

Expand All @@ -139,21 +139,21 @@ jobs:
uses: cafuego/command-output@main
with:
run: |
docker-compose -f tests/docker-compose.yml exec -T drupal drush -y cset gtm_barebones.settings container_id 'GTM-ABCDEFGHIJK'
docker-compose -f tests/docker-compose.yml exec -T drupal drush -y en dblog
docker-compose -f tests/docker-compose.yml exec -T drupal chmod -R 777 /srv/www/html/sites/default/files /srv/www/html/sites/default/private
docker-compose -f tests/docker-compose.yml exec -T drupal mkdir -p /srv/www/html/build/logs
docker-compose -f tests/docker-compose.yml exec -T drupal chmod -R 777 /srv/www/html/build/logs
docker-compose -f tests/docker-compose.yml exec -T drupal mkdir -p /srv/www/html/sites/default/files/browser_output
docker-compose -f tests/docker-compose.yml exec -T drupal chmod -R 777 /srv/www/html/sites/default/files/browser_output
docker-compose -f tests/docker-compose.yml exec -T -w /srv/www -e XDEBUG_MODE=coverage -e BROWSERTEST_OUTPUT_DIRECTORY=/srv/www/html/sites/default/files/browser_output -e DTT_BASE_URL=http://127.0.0.1 drupal ./vendor/bin/phpunit --coverage-clover /srv/www/html/build/logs/clover.xml --debug
docker compose -f tests/docker-compose.yml exec -T drupal drush -y cset gtm_barebones.settings container_id 'GTM-ABCDEFGHIJK'
docker compose -f tests/docker-compose.yml exec -T drupal drush -y en dblog
docker compose -f tests/docker-compose.yml exec -T drupal chmod -R 777 /srv/www/html/sites/default/files /srv/www/html/sites/default/private
docker compose -f tests/docker-compose.yml exec -T drupal mkdir -p /srv/www/html/build/logs
docker compose -f tests/docker-compose.yml exec -T drupal chmod -R 777 /srv/www/html/build/logs
docker compose -f tests/docker-compose.yml exec -T drupal mkdir -p /srv/www/html/sites/default/files/browser_output
docker compose -f tests/docker-compose.yml exec -T drupal chmod -R 777 /srv/www/html/sites/default/files/browser_output
docker compose -f tests/docker-compose.yml exec -T -w /srv/www -e XDEBUG_MODE=coverage -e BROWSERTEST_OUTPUT_DIRECTORY=/srv/www/html/sites/default/files/browser_output -e DTT_BASE_URL=http://127.0.0.1 drupal ./vendor/bin/phpunit --coverage-clover /srv/www/html/build/logs/clover.xml --debug
env:
fail-fast: true

- name: Copy Coveralls
id: copy_coveralls
if: success()
run: docker cp "$(docker-compose -f tests/docker-compose.yml ps -q drupal)":/srv/www/html/build/logs/clover.xml . || echo "skip=true" >> "$GITHUB_OUTPUT"
run: docker cp "$(docker compose -f tests/docker-compose.yml ps -q drupal)":/srv/www/html/build/logs/clover.xml . || echo "skip=true" >> "$GITHUB_OUTPUT"

- name: Monitor coverage
id: coveralls
Expand All @@ -173,7 +173,7 @@ jobs:
uses: cafuego/command-output@main
with:
run: |
docker-compose -f tests/docker-compose.yml exec -T drupal drush watchdog:show
docker compose -f tests/docker-compose.yml exec -T drupal drush watchdog:show
- name: Find Comment
uses: peter-evans/find-comment@v2
Expand Down
13 changes: 13 additions & 0 deletions PATCHES/social_auth_blocked.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/User/UserAuthenticator.php b/src/User/UserAuthenticator.php
index 868e033..089ddef 100644
--- a/src/User/UserAuthenticator.php
+++ b/src/User/UserAuthenticator.php
@@ -305,7 +305,7 @@ public function authenticateNewUser(UserInterface $drupal_user = NULL) {
if ($drupal_user) {

// If the account needs admin approval.
- if ($this->isApprovalRequired()) {
+ if ($this->isApprovalRequired() && $drupal_user->isBlocked()) {
$this->messenger->addWarning($this->t("Your account was created, but it needs administrator's approval."));
$this->nullifySessionKeys();

66 changes: 33 additions & 33 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions composer.patches.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"drupal/csp": {
"Simplify log format": "PATCHES/csp-log-format.patch"
},
"drupal/social_auth": {
"Allow activate on users": "PATCHES/social_auth_blocked.patch"
},
"drupal/user_expire": {
"Allow the notification email to be customised": "PATCHES/user_expire-customize-notification-email.patch",
"Reset expiration when user is reactivated": "PATCHES/user_expire-reset-expiration-on-reactivation.patch"
Expand Down
18 changes: 14 additions & 4 deletions html/modules/custom/ocha_ai_summarize/ocha_ai_summarize.module
Original file line number Diff line number Diff line change
Expand Up @@ -1387,10 +1387,20 @@ function ocha_ai_summarize_user_presave(UserInterface $user) {
$user->setUsername($user->getInitialEmail());
$user->activate();
$user->addRole('document_analyzer');
}
}

\Drupal::messenger()->deleteAll();
\Drupal::messenger()->addMessage(t('Your account has been automatically approved, you can now log in.'));
/**
* Implements hook_ENTITY_TYPE_insert().
*/
function ocha_ai_summarize_user_insert(UserInterface $user) {
$parts = explode('@', $user->getInitialEmail());
if ($parts[1] != 'un.org') {
return;
}

\Drupal::messenger()->deleteAll();
\Drupal::messenger()->addMessage(t('Your account has been automatically approved.'));
}

/**
Expand All @@ -1415,15 +1425,15 @@ function ocha_ai_summarize_notify_user(NodeInterface $node) {
$mail_manager = \Drupal::service('plugin.manager.mail');
$module = 'ocha_ai_summarize';
$key = 'notify_user';
$to = $node->getOwner()->getInitialEmail();
$to = $node->getOwner()->getEmail();
$langcode = $node->getOwner()->getPreferredLangcode();

$params['subject'] = t('AI Summarize: your document has been processed.');
$params['message'] = implode("\r\n\r\n", [
t('Dear'),
t('Your document has been processed.'),
t('You can see the result on @link', [
'@link' => $node->toUrl('absolute')->toString(),
'@link' => $node->toUrl('absolute')->setAbsolute()->toString(),
]),
]);

Expand Down
6 changes: 3 additions & 3 deletions html/themes/custom/common_design_subtheme/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ make

# Create the site, memcache and mysql containers.
echo "Create the site, memcache and mysql containers."
docker-compose -p ai-summarize-test -f tests/docker-compose.yml up -d
docker compose -p ai-summarize-test -f tests/docker-compose.yml up -d

# Dump some information about the created containers.
echo "Dump some information about the created containers."
Expand Down Expand Up @@ -51,4 +51,4 @@ docker exec -it -u root -w /srv/www -e XDEBUG_MODE=coverage -e BROWSERTEST_OUTPU

# Remove the image.
echo "Remove the test image"
docker-compose -p ai-summarize-test -f tests/docker-compose.yml down -v
docker compose -p ai-summarize-test -f tests/docker-compose.yml down -v

0 comments on commit 3aa0d19

Please sign in to comment.