Skip to content

Commit

Permalink
Merge branch '1.x' into 13/feature/alert-banner
Browse files Browse the repository at this point in the history
  • Loading branch information
markconroy committed Jul 28, 2023
2 parents 78077d6 + b127df3 commit d1333e6
Show file tree
Hide file tree
Showing 12 changed files with 335 additions and 58 deletions.
207 changes: 207 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
name: Test localgovdrupal/localgov_multilingual drupal-module

on:
push:
branches:
- '1.x'
pull_request:
branches:
- '1.x'

env:
LOCALGOV_DRUPAL_PROJECT: localgovdrupal/localgov_multilingual
LOCALGOV_DRUPAL_PROJECT_PATH: web/modules/contrib/localgov_multilingual

jobs:

build:
name: Install LocalGov Drupal
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
localgov-version:
- '3.x'
drupal-version:
- '~10.0'
php-version:
- '8.1'

steps:

- name: Save git branch and git repo names to env if this is not a pull request
if: github.event_name != 'pull_request'
run: |
echo "GIT_BASE=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "HEAD_USER=localgovdrupal" >> $GITHUB_ENV
- name: Save git branch and git repo names to env if this is a pull request
if: github.event_name == 'pull_request'
run: |
echo "GIT_BASE=${GITHUB_BASE_REF}" >> $GITHUB_ENV
echo "GIT_BRANCH=${GITHUB_HEAD_REF}" >> $GITHUB_ENV
export HEAD="${{ github.event.pull_request.head.label }}"
echo "HEAD_USER=${HEAD%%:*}" >> $GITHUB_ENV
- name: Set composer branch reference for version branches
if: endsWith(github.ref, '.x')
run: echo "COMPOSER_REF=${GIT_BRANCH}-dev" >> $GITHUB_ENV

- name: Set composer branch reference for non-version branches
if: endsWith(github.ref, '.x') == false
run: echo "COMPOSER_REF=dev-${GIT_BRANCH}" >> $GITHUB_ENV

- name: Get the latest tagged release for branch version
run: |
LATEST_RELEASE=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${GITHUB_REPOSITORY}/git/matching-refs/tags/${GIT_BASE%'.x'} | grep -Po '(?<=refs/tags/)[^"]+' | tail -1)
if [ -z $LATEST_RELEASE ]; then LATEST_RELEASE=1; fi
echo "LATEST_RELEASE=${LATEST_RELEASE}" >> $GITHUB_ENV
- name: Cached workspace
uses: actions/cache@v2
with:
path: ./html
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}

- name: Clone drupal_container
uses: actions/checkout@v2
with:
repository: localgovdrupal/drupal-container
ref: php${{ matrix.php-version }}

- name: Create LocalGov Drupal project
run: |
composer create-project --stability dev --no-install localgovdrupal/localgov-project ./html "${{ matrix.localgov-version }}"
composer --working-dir=./html require --no-install localgovdrupal/localgov:${{ matrix.localgov-version }}-dev
composer --working-dir=./html require --no-install drupal/core-recommended:${{ matrix.drupal-version }} drupal/core-composer-scaffold:${{ matrix.drupal-version }} drupal/core-project-message:${{ matrix.drupal-version }} drupal/core-dev:${{ matrix.drupal-version }}
composer --working-dir=./html install
- name: Obtain the test target using Composer
if: env.HEAD_USER == 'localgovdrupal'
run: |
composer --working-dir=html config repositories.1 vcs git@github.com:${LOCALGOV_DRUPAL_PROJECT}.git
composer global config github-oauth.github.com ${{ github.token }}
composer --working-dir=./html require --with-all-dependencies ${LOCALGOV_DRUPAL_PROJECT}:"${COMPOSER_REF} as ${LATEST_RELEASE}"
- name: Obtain the test target using Git
if: env.HEAD_USER != 'localgovdrupal'
uses: actions/checkout@v2
with:
path: ${{ env.LOCALGOV_DRUPAL_PROJECT_PATH }}

phpcs:
name: Coding standards checks
needs: build
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
localgov-version:
- '3.x'
drupal-version:
- '~10.0'
php-version:
- '8.1'

steps:

- name: Cached workspace
uses: actions/cache@v2
with:
path: ./html
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }}
restore-keys: |
localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}

- name: Run coding standards checks
run: |
cd html
./bin/phpcs -p ${LOCALGOV_DRUPAL_PROJECT_PATH}
phpstan:
name: Deprecated code checks
needs: build
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
localgov-version:
- '3.x'
drupal-version:
- '~10.0'
php-version:
- '8.1'

steps:

- name: Cached workspace
uses: actions/cache@v2
with:
path: ./html
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }}
restore-keys: |
localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}

- name: Run deprecated code checks
run: |
cd html
./bin/phpstan analyse -c ./phpstan.neon ${LOCALGOV_DRUPAL_PROJECT_PATH}
phpunit:
name: PHPUnit tests
needs: build
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
localgov-version:
- '3.x'
drupal-version:
- '~10.0'
php-version:
- '8.1'

steps:

- name: Clone Drupal container
uses: actions/checkout@v2
with:
repository: localgovdrupal/drupal-container
ref: php${{ matrix.php-version }}

- name: Cached workspace
uses: actions/cache@v2
with:
path: ./html
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }}
restore-keys: |
localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-
- name: Start Docker environment
run: docker-compose -f docker-compose.yml up -d

- name: Run PHPUnit tests
run: |
mkdir -p ./html/web/sites/simpletest && chmod 777 ./html/web/sites/simpletest
sed -i "s#http://localgov.lndo.site#http://drupal#" ./html/phpunit.xml.dist
docker exec -t drupal bash -c 'chown docker:docker -R /var/www/html'
docker exec -u docker -t drupal bash -c "cd /var/www/html && ./bin/paratest --processes=4 ${{ env.LOCALGOV_DRUPAL_PROJECT_PATH }}"
5 changes: 2 additions & 3 deletions localgov_multilingual.install
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

/**
* @file
* Install, update and uninstall functions for the
* LocalGov Services: Multilingual module.
* Install, update and uninstall functions for LocalGov Multilingual.
*/

/**
Expand All @@ -18,4 +17,4 @@ function localgov_services_multilingual_install() {
*/
function localgov_services_multilingual_uninstall() {
\Drupal::messenger()->addStatus(__FUNCTION__);
}
}
2 changes: 1 addition & 1 deletion localgov_multilingual.libraries.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
localgov-multilingual:
css:
theme:
css/localgov-multilingual.css: {}
css/localgov-multilingual.css: {}
2 changes: 1 addition & 1 deletion localgov_multilingual.module
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ function localgov_multilingual_preprocess_block(&$variables) {
if ($variables['derivative_plugin_id'] == 'language_interface') {
$variables['content']['#attached']['library'][] = 'localgov_multilingual/localgov-multilingual';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* @file
* Install, update and uninstall functions for the Localgov Multilingual: Blogs module.
* Install, update and uninstall functions for Localgov Multilingual: Blogs..
*/

/**
Expand All @@ -26,16 +26,16 @@ function localgov_multilingual_blogs_install() {
'localgov_blog_related_posts',
];

// Set node fields to be translatable
// Set node fields to be translatable.
foreach ($node_blog_channel_fields as $field) {
$config = $config_factory->getEditable('field.field.node.localgov_blog_channel.' . $field);
$config->set('translatable', true);
$config->set('translatable', TRUE);
$config->save(TRUE);
}

foreach ($node_blog_post_fields as $field) {
$config = $config_factory->getEditable('field.field.node.localgov_blog_post.' . $field);
$config->set('translatable', true);
$config->set('translatable', TRUE);
$config->save(TRUE);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
langcode: en
status: true
dependencies:
config:
- node.type.localgov_directories_org
module:
- content_translation
third_party_settings:
content_translation:
enabled: true
bundle_settings:
untranslatable_fields_hide: '0'
id: node.localgov_directories_org
target_entity_type_id: node
target_bundle: localgov_directories_org
default_langcode: site_default
language_alterable: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: "Localgov Multilingual: Directory Organisation"
type: module
description: Add multilingual capabilities to the directory organisation content type.
package: LocalGov Drupal
core_version_requirement: ^9 || ^10
dependencies:
- localgovdrupal:localgov_directories_org
- localgovdrupal:localgov_multilingual
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/**
* @file
* Install functions for Localgov Multilingual: Directory Organisation.
*/

/**
* Implements hook_install().
*/
function localgov_multilingual_directory_organisation_install() {
$config_factory = \Drupal::configFactory();

$node_directory_organisation_fields = [
'body',
'localgov_directory_channels',
'localgov_directory_email',
'localgov_directory_facets_select',
'localgov_directory_files',
'localgov_location',
'localgov_directory_phone',
'localgov_directory_notes',
'localgov_directory_website',
];

// Set node fields to be translatable.
foreach ($node_directory_organisation_fields as $field) {
$config = $config_factory->getEditable('field.field.node.localgov_directories_org.' . $field);
$config->set('translatable', TRUE);
$config->save(TRUE);
}
}

/**
* Implements hook_uninstall().
*/
function localgov_multilingual_directory_organisation_uninstall() {
\Drupal::messenger()->addStatus(__FUNCTION__);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

/**
* @file
* Primary module hooks for Localgov Multilingual: Directory Organisation.
*/
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* @file
* Install, update and uninstall functions for the Localgov Multilingual: Services module.
* Install, update and uninstall functions for Localgov Multilingual: Services.
*/

/**
Expand All @@ -29,7 +29,7 @@ function localgov_multilingual_irish_services_install() {
'localgov_irish_service_reference',
'localgov_irish_service_lgma_id',
];

$irish_services_page_fields = [
'localgov_irish_service_category',
'localgov_irish_service_topic',
Expand All @@ -42,17 +42,17 @@ function localgov_multilingual_irish_services_install() {

foreach ($irish_services_landing_page_fields as $field) {
$config = $config_factory->getEditable('field.field.node.localgov_services_landing.' . $field);
$config->set('translatable', true);
$config->set('translatable', TRUE);
$config->save(TRUE);
}
foreach ($irish_services_sub_landing_page_fields as $field) {
$config = $config_factory->getEditable('field.field.node.localgov_services_sublanding.' . $field);
$config->set('translatable', true);
$config->set('translatable', TRUE);
$config->save(TRUE);
}
foreach ($irish_services_page_fields as $field) {
$config = $config_factory->getEditable('field.field.node.localgov_services_page.' . $field);
$config->set('translatable', true);
$config->set('translatable', TRUE);
$config->save(TRUE);
}
}
Expand Down
Loading

0 comments on commit d1333e6

Please sign in to comment.