Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0.1 release for Drupal 9 support #139

Merged
merged 9 commits into from
May 18, 2021
107 changes: 83 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,109 @@ name: Test LocalGov Drupal Alert Banner

on:
push:
branches: [ master ]
branches:
- '1.x'
pull_request:
branches: [ master ]
branches:
- '1.x'

jobs:

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

strategy:
fail-fast: false
matrix:
include:
- localgov-version: "1.x"
drupal-version: "~8.9"
php-version: "7.4"
- localgov-version: "2.x"
drupal-version: "~9.1"
php-version: "7.4"

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 "GIT_REPO=${GITHUB_REPOSITORY}" >> $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
echo "GIT_REPO=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_ENV

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

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

- name: Cached workspace
uses: actions/cache@v2
with:
path: ./html
key: ${{ runner.os }}-localgov-build-${{ github.run_id }}
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}

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

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

- name: Create LocalGov Drupal project
run: composer create-project --stability dev localgovdrupal/localgov-project ./html

- 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_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "GIT_REPO=${GITHUB_REPOSITORY}" >> $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_BRANCH=${GITHUB_HEAD_REF}" >> $GITHUB_ENV
echo "GIT_REPO=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_ENV
composer create-project --stability dev --no-install localgovdrupal/localgov-project ./html "${{ matrix.localgov-version }}"
composer 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 install

- name: Setup package source and authentication for the test target
run: |
composer --working-dir=html config repositories.1 vcs git@github.com:${GIT_REPO}.git
composer global config github-oauth.github.com ${{ github.token }}

- name: Obtain the test target from the repo that triggered this workflow
run: composer --working-dir=html require --with-all-dependencies localgovdrupal/${{ github.event.repository.name }}:"dev-${GIT_BRANCH} as 1.0.x-dev"
run: composer --working-dir=html require --with-all-dependencies localgovdrupal/${{ github.event.repository.name }}:"${COMPOSER_REF} as ${GIT_BASE%'.x'}"

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

strategy:
fail-fast: false
matrix:
include:
- localgov-version: "1.x"
drupal-version: "~8.9"
php-version: "7.4"
- localgov-version: "2.x"
drupal-version: "~9.1"
php-version: "7.4"

steps:

- name: Cached workspace
uses: actions/cache@v2
with:
path: ./html
key: ${{ runner.os }}-localgov-build-${{ github.run_id }}
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-localgov-build-
localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -84,15 +121,26 @@ jobs:
needs: build
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
- localgov-version: "1.x"
drupal-version: "~8.9"
php-version: "7.4"
- localgov-version: "2.x"
drupal-version: "~9.1"
php-version: "7.4"

steps:

- name: Cached workspace
uses: actions/cache@v2
with:
path: ./html
key: ${{ runner.os }}-localgov-build-${{ github.run_id }}
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-localgov-build-
localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -109,6 +157,17 @@ jobs:
needs: build
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
- localgov-version: "1.x"
drupal-version: "~8.9"
php-version: "7.4"
- localgov-version: "2.x"
drupal-version: "~9.1"
php-version: "7.4"

steps:

- name: Clone drupal_container
Expand All @@ -121,9 +180,9 @@ jobs:
uses: actions/cache@v2
with:
path: ./html
key: ${{ runner.os }}-localgov-build-${{ github.run_id }}
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-localgov-build-
localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-

- name: Start Docker environment
run: docker-compose -f docker-compose.yml up -d
Expand Down
5 changes: 0 additions & 5 deletions localgov_alert_banner.services.yml

This file was deleted.

2 changes: 1 addition & 1 deletion src/AlertBannerEntityListBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function buildHeader() {
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
/* @var \Drupal\localgov_alert_banner\Entity\AlertBannerEntity $entity */
/** @var \Drupal\localgov_alert_banner\Entity\AlertBannerEntity $entity */
$row['id'] = $entity->id();
$row['title'] = Link::createFromRoute(
$entity->label(),
Expand Down
11 changes: 9 additions & 2 deletions src/Controller/AlertBannerEntityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,15 @@ public function revisionOverview(AlertBannerEntityInterface $localgov_alert_bann
$languages = $localgov_alert_banner->getTranslationLanguages();
$type_id = $localgov_alert_banner->bundle();
$has_translations = (count($languages) > 1);
$build['#title'] = $has_translations ? $this->t('@langname revisions for %title', ['@langname' => $langname, '%title' => $localgov_alert_banner->label()]) : $this->t('Revisions for %title', ['%title' => $localgov_alert_banner->label()]);

if ($has_translations) {
$build['#title'] = $this->t('@langname revisions for %title', [
'@langname' => $langname,
'%title' => $localgov_alert_banner->label(),
]);
}
else {
$build['#title'] = $this->t('Revisions for %title', ['%title' => $localgov_alert_banner->label()]);
}
$header = [$this->t('Revision'), $this->t('Operations')];
$revert_permission = (($account->hasPermission("manage all localgov alert banner entities") || $account->hasPermission('manage localgov alert banner ' . $type_id . ' entities')));
$delete_permission = (($account->hasPermission("manage all localgov alert banner entities") || $account->hasPermission('manage localgov alert banner ' . $type_id . ' entities')));
Expand Down
10 changes: 8 additions & 2 deletions src/Form/AlertBannerEntityRevisionDeleteForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,14 @@ public function buildForm(array $form, FormStateInterface $form_state, $localgov
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->AlertBannerEntityStorage->deleteRevision($this->revision->getRevisionId());

$this->logger('content')->notice('Alert banner: deleted %title revision %revision.', ['%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]);
$this->messenger()->addMessage($this->t('Revision from %revision-date of Alert banner %title has been deleted.', ['%revision-date' => $this->dateFormatter->format($this->revision->getRevisionCreationTime()), '%title' => $this->revision->label()]));
$this->logger('content')->notice('Alert banner: deleted %title revision %revision.', [
'%title' => $this->revision->label(),
'%revision' => $this->revision->getRevisionId(),
]);
$this->messenger()->addMessage($this->t('Revision from %revision-date of Alert banner %title has been deleted.', [
'%revision-date' => $this->dateFormatter->format($this->revision->getRevisionCreationTime()),
'%title' => $this->revision->label(),
]));
$form_state->setRedirect(
'entity.localgov_alert_banner.canonical',
['localgov_alert_banner' => $this->revision->id()]
Expand Down
2 changes: 1 addition & 1 deletion src/Form/AlertBannerEntitySettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Drupal\Core\Form\FormStateInterface;

/**
* Class AlertBannerEntitySettingsForm.
* Provides a form for managing alert banner settings.
*
* @ingroup localgov_alert_banner
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Form/AlertBannerEntityTypeForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Drupal\Core\Form\FormStateInterface;

/**
* Class AlertBannerEntityTypeForm.
* Provides a form for edting alert banner types.
*/
class AlertBannerEntityTypeForm extends EntityForm {

Expand Down
25 changes: 0 additions & 25 deletions src/Routing/AlertBannerRouteSubscriber.php

This file was deleted.

8 changes: 4 additions & 4 deletions tests/src/Functional/AdminViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AdminViewTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
protected static $modules = [
'localgov_alert_banner',
];

Expand All @@ -33,16 +33,16 @@ public function testLoadAdminView() {

// Check can access the admin view dashboard.
$this->drupalGet('admin/content/alert-banner');
$this->assertResponse(Response::HTTP_OK);
$this->assertSession()->statusCodeEquals(Response::HTTP_OK);

// Check this is the view by making sure certian view only text is present.
// @todo Work out how to make sure this is the view path (Kernal test?).
$this->assertRaw('Manage Alert Banners');
$this->assertSession()->responseContains('Manage Alert Banners');

// Check that loading the collection URL loads the admin dashboard.
$collectionUrl = Url::fromRoute('entity.localgov_alert_banner.collection');
$this->drupalGet($collectionUrl);
$this->assertUrl('admin/content/alert-banner');
$this->assertSession()->addressEquals('admin/content/alert-banner');
}

}
2 changes: 1 addition & 1 deletion tests/src/Functional/AlertBannerBlockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AlertBannerBlockTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
protected static $modules = [
'block',
'path',
'options',
Expand Down
Loading