Skip to content

Commit

Permalink
Merge pull request #630 from UN-OCHA/develop
Browse files Browse the repository at this point in the history
Main -> Develop - v1.17.0
  • Loading branch information
orakili authored Jul 25, 2023
2 parents d33602b + 0034948 commit f10bcba
Show file tree
Hide file tree
Showing 69 changed files with 4,037 additions and 4,407 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
!html/modules/custom
!html/themes/custom
!patches
!PATCHES
!scripts
!composer.json
!composer.lock
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/composer-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_dispatch:

jobs:
build:
update:
runs-on: ubuntu-latest
steps:
- name: Update The Thing
Expand All @@ -16,7 +16,6 @@ jobs:
github_access_token: ${{ secrets.PAT }}
patch_branch: 'develop'
patch_packages: 'drupal/*'
patch_maintainers: ${{ secrets.DRUPAL_MAINTAINERS }}
patch_maintainers: ${{ vars.DRUPAL_MAINTAINERS }}
slack_bot_token: ${{ secrets.SLACK_BOT_TOKEN }}
slack_channel_name: ${{ secrets.SLACK_CHANNEL }}
flowdock_token: ${{ secrets.FLOWDOCK_TOKEN }}
slack_channel_name: ${{ vars.SLACK_CHANNEL }}
4 changes: 1 addition & 3 deletions .github/workflows/docker-build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,5 @@ jobs:
docker_password: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
ecr_github_token: ${{ secrets.ECR_GITHUB_TOKEN }}
ecr_jenkins_token: ${{ secrets.JENKINS_ECR_TOKEN }}
flowdock_token: ${{ secrets.FLOWDOCK_TOKEN }}
flowdock_icon_failure: 'warning'
slack_bot_token: ${{ secrets.SLACK_BOT_TOKEN }}
slack_channel_name: ${{ secrets.SLACK_CHANNEL }}
slack_channel_name: ${{ vars.SLACK_CHANNEL }}
254 changes: 254 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
name: Run tests

on: [pull_request]

jobs:
tests:
runs-on: ubuntu-latest
permissions:
contents: write
checks: write
pull-requests: write
actions: read
statuses: write

steps:
- name: Checkout Code
id: checkout
uses: actions/checkout@v3

- name: Extract PHP Version
id: php
uses: docker://ghcr.io/un-ocha/actions:extract-php-version-main
with:
docker_file: 'docker/Dockerfile'
docker_image: 'public.ecr.aws/unocha/php-k8s'

- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
if: ${{ !env.ACT }}
with:
php-version: ${{ steps.php.outputs.php_version }}
tools: composer
env:
fail-fast: true

- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
if: ${{ env.ACT }}
with:
php-version: ${{ steps.php.outputs.php_version }}
tools: composer
env:
fail-fast: true
runner: self-hosted

- name: Software versions
id: versions
uses: cafuego/command-output@main
with:
run: |
php --version && composer --version
- name: Composer Validate
id: validate
uses: cafuego/command-output@main
with:
run: |
composer validate
env:
fail-fast: true

- name: Code Lint
id: lint
uses: cafuego/command-output@main
with:
run: |
test ! -d ./html/modules/custom || find -L ./html/modules/custom -iregex '.*\.\(php\|module\|inc\|install\)$' -print0 | xargs -0 -n 1 -P 4 php -l
test ! -d ./html/themes/custom || find -L ./html/themes/custom -iregex '.*\.\(php\|theme\)$' -print0 | xargs -0 -n 1 -P 4 php -l
env:
fail-fast: true

- name: Configure AWS Credentials
id: aws
uses: aws-actions/configure-aws-credentials@v2
if: ${{ !env.ACT }}
with:
aws-access-key-id: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Login to Public ECR
id: aws-login
uses: docker/[email protected]
if: ${{ !env.ACT }}
with:
registry: public.ecr.aws
username: ${{ secrets.ECR_AWS_ACCESS_KEY_I }}
password: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
env:
AWS_REGION: us-east-1

- name: Build Image
id: build
uses: cafuego/command-output@main
with:
run: |
make
env:
fail-fast: true

- name: Setup Environment
id: docker
uses: cafuego/command-output@main
with:
run: |
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
env:
fail-fast: true

- 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
env:
fail-fast: true

- name: Install Environment
id: install
uses: cafuego/command-output@main
with:
run: |
docker compose -f tests/docker-compose.yml exec -T drupal drush -y si --existing-config
env:
fail-fast: true

- name: Run tests
id: tests
uses: cafuego/command-output@main
with:
run: |
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 -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 cp "$(docker compose -f tests/docker-compose.yml ps -q drupal)":/srv/www/html/build/logs/clover.xml .
env:
fail-fast: true

- name: Monitor coverage
uses: slavcodev/coverage-monitor-action@v1
if: ${{ !env.ACT }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
coverage_path: "clover.xml"
threshold_alert: 10
threshold_warning: 50
threshold_metric: "lines"
comment_footer: false

- name: Find Comment
uses: peter-evans/find-comment@v2
if: ${{ !env.ACT }}
id: fc
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Build output

- name: Create or update comment
uses: peter-evans/create-or-update-comment@v2
if: ${{ !env.ACT }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
### Build output
#### Composer Validate `${{ steps.validate.outcome }}`
#### PHP Lint `${{ steps.lint.outcome }}`
#### Docker Build `${{ steps.build.outcome }}`
#### Environment Setup `${{ steps.docker.outcome }}`
#### Site Install `${{ steps.install.outcome }}`
#### PHP Code Sniffer `${{ steps.phpcs.outcome }}`
<details><summary>Software Versions</summary>
<code>${{ steps.versions.outputs.stdout }}</code>
</details>
<details><summary>Drupal Logs</summary>
<code>${{ steps.dblog.outputs.stdout }}</code>
</details>
*Pusher: @${{ github.actor }}, Action: `${{ github.event_name }}`, Workflow: `${{ github.workflow }}`*
edit-mode: replace

- name: Slack Success Notification
id: slack_success
if: ${{ !env.ACT && failure() }}
uses: slackapi/[email protected]
with:
channel-id: '${{ vars.SLACK_CHANNEL }}'
payload: |
{
"text": "Tests passed for a pull request on ${{ github.repository }}",
"attachments": [
{
"color": "#00FF00",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Pull request by @${{ github.triggering_actor }} to merge _${{ github.head_ref }}_ into _${{ github.base_ref }}_ on <${{ github.repositoryUrl }}|${{ github.repository }}> passed tests (<${{ github.event.pull_request.html_url }}|Review>)"
}
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

- name: Slack Failure Notification
id: slack_failure
if: ${{ !env.ACT && failure() }}
uses: slackapi/[email protected]
with:
channel-id: '${{ vars.SLACK_CHANNEL }}'
payload: |
{
"text": "Tests failed for a pull request on ${{ github.repository }}",
"attachments": [
{
"color": "#FF0000",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Pull request by @${{ github.triggering_actor }} to merge _${{ github.head_ref }}_ into _${{ github.base_ref }}_ on <${{ github.repositoryUrl }}|${{ github.repository }}> failed tests (<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|Review>)"
}
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

- name: Clean up
id: docker-clean-up
if: ${{ env.ACT }}
uses: cafuego/command-output@main
with:
run: |
docker compose -f tests/docker-compose.yml down
env:
fail-fast: true
80 changes: 0 additions & 80 deletions .travis.yml

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/username_enumeration_prevention.module b/username_enumeration_prevention.module
index 1038f75b1d823887965f79df9d3b76fc396031a1..075abaa22c8392f810093e066990934328fdd01c 100644
--- a/username_enumeration_prevention.module
+++ b/username_enumeration_prevention.module
@@ -86,3 +86,15 @@ function username_enumeration_prevention_pass_submit($form, FormStateInterface $
\Drupal::messenger()->addMessage(t('If the username or email address exists and is active, further instructions have been sent to your email address.'));
$form_state->setRedirect('user.page');
}
+
+/**
+ * Implements hook_js_settings_alter().
+ *
+ * Remove drupalSettings.path.currentPath on 404 responses.
+ */
+function username_enumeration_prevention_js_settings_alter(&$settings) {
+ if (\Drupal::routeMatch()->getRouteName() === "system.404" ) {
+ $settings['path']['currentPath'] = '';
+ }
+}
+
Loading

0 comments on commit f10bcba

Please sign in to comment.