From 4351d64921bef92f39b4523dd326b75df322eda6 Mon Sep 17 00:00:00 2001 From: Andy Broomfield Date: Tue, 11 May 2021 00:46:36 +0100 Subject: [PATCH 1/8] Delete AlertBannerRouteSubscriber.php Fix #93 --- src/Routing/AlertBannerRouteSubscriber.php | 25 ---------------------- 1 file changed, 25 deletions(-) delete mode 100644 src/Routing/AlertBannerRouteSubscriber.php diff --git a/src/Routing/AlertBannerRouteSubscriber.php b/src/Routing/AlertBannerRouteSubscriber.php deleted file mode 100644 index 36cf44eb..00000000 --- a/src/Routing/AlertBannerRouteSubscriber.php +++ /dev/null @@ -1,25 +0,0 @@ -get('entity.alert_banner.canonical')) { - // Change the access permission for the alert banner access page. - $route->setRequirement('_custom_access', 'localgov_alert_banner.alert_banner_entity_page_access::access'); - } - - } - -} From d15a4be23b6b3d15289a5c623723c45199e212d5 Mon Sep 17 00:00:00 2001 From: Stephen Cox Date: Tue, 11 May 2021 07:39:45 +0100 Subject: [PATCH 2/8] Code fixes for Drupal 9 (#131) (#132) --- src/AlertBannerEntityListBuilder.php | 2 +- .../AlertBannerEntityController.php | 11 +++- .../AlertBannerEntityRevisionDeleteForm.php | 10 +++- src/Form/AlertBannerEntitySettingsForm.php | 2 +- src/Form/AlertBannerEntityTypeForm.php | 2 +- tests/src/Functional/AdminViewTest.php | 8 +-- tests/src/Functional/AlertBannerBlockTest.php | 2 +- .../src/Functional/AlertConfirmationTest.php | 26 ++++---- tests/src/Functional/PermissionsTest.php | 60 +++++++++---------- tests/src/Functional/ViewsStatusLinkTest.php | 4 +- .../AlertBannerHideTest.php | 2 +- .../src/Kernel/AlertBannerBlockOrderTest.php | 4 +- 12 files changed, 74 insertions(+), 59 deletions(-) diff --git a/src/AlertBannerEntityListBuilder.php b/src/AlertBannerEntityListBuilder.php index a1ce7b77..1c13042f 100644 --- a/src/AlertBannerEntityListBuilder.php +++ b/src/AlertBannerEntityListBuilder.php @@ -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(), diff --git a/src/Controller/AlertBannerEntityController.php b/src/Controller/AlertBannerEntityController.php index 58dc58e5..00cb4067 100644 --- a/src/Controller/AlertBannerEntityController.php +++ b/src/Controller/AlertBannerEntityController.php @@ -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'))); diff --git a/src/Form/AlertBannerEntityRevisionDeleteForm.php b/src/Form/AlertBannerEntityRevisionDeleteForm.php index 6b5dd954..edad52ca 100644 --- a/src/Form/AlertBannerEntityRevisionDeleteForm.php +++ b/src/Form/AlertBannerEntityRevisionDeleteForm.php @@ -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()] diff --git a/src/Form/AlertBannerEntitySettingsForm.php b/src/Form/AlertBannerEntitySettingsForm.php index faff0e56..78df63e5 100644 --- a/src/Form/AlertBannerEntitySettingsForm.php +++ b/src/Form/AlertBannerEntitySettingsForm.php @@ -6,7 +6,7 @@ use Drupal\Core\Form\FormStateInterface; /** - * Class AlertBannerEntitySettingsForm. + * Provides a form for managing alert banner settings. * * @ingroup localgov_alert_banner */ diff --git a/src/Form/AlertBannerEntityTypeForm.php b/src/Form/AlertBannerEntityTypeForm.php index df95a62a..59498fc4 100644 --- a/src/Form/AlertBannerEntityTypeForm.php +++ b/src/Form/AlertBannerEntityTypeForm.php @@ -6,7 +6,7 @@ use Drupal\Core\Form\FormStateInterface; /** - * Class AlertBannerEntityTypeForm. + * Provides a form for edting alert banner types. */ class AlertBannerEntityTypeForm extends EntityForm { diff --git a/tests/src/Functional/AdminViewTest.php b/tests/src/Functional/AdminViewTest.php index ca74d875..4bfc47d5 100644 --- a/tests/src/Functional/AdminViewTest.php +++ b/tests/src/Functional/AdminViewTest.php @@ -19,7 +19,7 @@ class AdminViewTest extends BrowserTestBase { /** * {@inheritdoc} */ - public static $modules = [ + protected static $modules = [ 'localgov_alert_banner', ]; @@ -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'); } } diff --git a/tests/src/Functional/AlertBannerBlockTest.php b/tests/src/Functional/AlertBannerBlockTest.php index f89bb064..398bdc11 100644 --- a/tests/src/Functional/AlertBannerBlockTest.php +++ b/tests/src/Functional/AlertBannerBlockTest.php @@ -18,7 +18,7 @@ class AlertBannerBlockTest extends BrowserTestBase { /** * {@inheritdoc} */ - public static $modules = [ + protected static $modules = [ 'block', 'path', 'options', diff --git a/tests/src/Functional/AlertConfirmationTest.php b/tests/src/Functional/AlertConfirmationTest.php index 594c50d5..c2b0f2ef 100644 --- a/tests/src/Functional/AlertConfirmationTest.php +++ b/tests/src/Functional/AlertConfirmationTest.php @@ -20,14 +20,14 @@ class AlertConfirmationTest extends BrowserTestBase { /** * {@inheritdoc} */ - public static $modules = [ + protected static $modules = [ 'localgov_alert_banner', ]; /** * {@inheritdoc} */ - public function setUp() { + public function setUp(): void { parent::setUp(); $emergencyPublisherUser = $this->createUser(); @@ -84,9 +84,8 @@ public function testAlertConfirmation() { // Go to the alert confirmation page, tick the unpublish others. // Verifiy that the alert 2 banner is unpublished. - $this->drupalPostForm($alert->toUrl('status-form')->toString(), [ - 'edit-unpublish-others' => 1, - ], 'Confirm'); + $this->drupalGet($alert->toUrl('status-form')->toString()); + $this->submitForm(['edit-unpublish-others' => 1], 'Confirm'); // Check for the presence of the Put banner live link. $this->drupalGet($alert_2->toUrl('canonical')->toString()); @@ -94,9 +93,8 @@ public function testAlertConfirmation() { // Go to the second alert confirmation page, do not unpublih others. // Verifiy that the alert banner remains published. - $this->drupalPostForm($alert_2->toUrl('status-form')->toString(), [ - 'edit-unpublish-others' => 0, - ], 'Confirm'); + $this->drupalGet($alert_2->toUrl('status-form')->toString()); + $this->submitForm(['edit-unpublish-others' => 0], 'Confirm'); // Check for the presence of the Remove banner link. $this->drupalGet($alert->toUrl('canonical')->toString()); @@ -125,7 +123,8 @@ public function testSaveAlertRedirect() { $form_vars = [ 'status-change' => 1, ]; - $this->drupalPostForm($edit_url, $form_vars, 'Save'); + $this->drupalGet($edit_url); + $this->submitForm($form_vars, 'Save'); $this->assertSession()->addressEquals($alert->toUrl('status-form')->toString()); $this->getSession()->getPage()->pressButton('Confirm'); @@ -135,7 +134,8 @@ public function testSaveAlertRedirect() { $form_vars = [ 'status-change' => 1, ]; - $this->drupalPostForm($edit_url, $form_vars, 'Save'); + $this->drupalGet($edit_url); + $this->submitForm($form_vars, 'Save'); $this->assertSession()->addressEquals($alert->toUrl('status-form')->toString()); $this->getSession()->getPage()->pressButton('Confirm'); @@ -145,7 +145,8 @@ public function testSaveAlertRedirect() { $form_vars = [ 'status-change' => 0, ]; - $this->drupalPostForm($edit_url, $form_vars, 'Save'); + $this->drupalGet($edit_url); + $this->submitForm($form_vars, 'Save'); $this->assertSession()->addressNotEquals($alert->toUrl('status-form')->toString()); // Change the status of the banner with a destination paremeter and verify @@ -159,7 +160,8 @@ public function testSaveAlertRedirect() { $form_vars = [ 'status-change' => 1, ]; - $this->drupalPostForm($edit_url, $form_vars, 'Save', $options); + $this->drupalGet($edit_url, $options); + $this->submitForm($form_vars, 'Save'); $this->assertSession()->addressEquals($alert->toUrl('status-form')->toString()); $this->getSession()->getPage()->pressButton('Confirm'); $this->assertSession()->addressEquals('/admin'); diff --git a/tests/src/Functional/PermissionsTest.php b/tests/src/Functional/PermissionsTest.php index d74f9c73..446a6bca 100644 --- a/tests/src/Functional/PermissionsTest.php +++ b/tests/src/Functional/PermissionsTest.php @@ -18,14 +18,14 @@ class PermissionsTest extends BrowserTestBase { /** * {@inheritdoc} */ - public static $modules = [ + protected static $modules = [ 'localgov_alert_banner', ]; /** * {@inheritdoc} */ - public function setUp() { + public function setUp(): void { parent::setUp(); @@ -51,50 +51,50 @@ public function testAlertBannerUserAccess() { // Check that anonymous user cannot access to the overview page. $this->drupalGet('admin/content/alert-banner'); - $this->assertResponse(Response::HTTP_FORBIDDEN); + $this->assertSession()->statusCodeEquals(Response::HTTP_FORBIDDEN); // Check that anonymous user does not have CRUD page access. $this->drupalGet('admin/content/alert-banner/add/localgov_alert_banner'); - $this->assertResponse(Response::HTTP_FORBIDDEN); + $this->assertSession()->statusCodeEquals(Response::HTTP_FORBIDDEN); $this->drupalGet('admin/content/alert-banner/1/edit'); - $this->assertResponse(Response::HTTP_FORBIDDEN); + $this->assertSession()->statusCodeEquals(Response::HTTP_FORBIDDEN); $this->drupalGet('admin/content/alert-banner/1/revisions'); - $this->assertResponse(Response::HTTP_FORBIDDEN); + $this->assertSession()->statusCodeEquals(Response::HTTP_FORBIDDEN); $this->drupalGet('admin/content/alert-banner/1/delete'); - $this->assertResponse(Response::HTTP_FORBIDDEN); + $this->assertSession()->statusCodeEquals(Response::HTTP_FORBIDDEN); // Check that anonymous user cannot view the alert banner main page. $this->drupalGet('admin/content/alert-banner/1'); - $this->assertResponse(Response::HTTP_FORBIDDEN); + $this->assertSession()->statusCodeEquals(Response::HTTP_FORBIDDEN); // Check that anonymous user cannot access the alert banner types. $this->drupalGet('admin/structure/alert-banner-types/localgov_alert_banner_type'); - $this->assertResponse(Response::HTTP_FORBIDDEN); + $this->assertSession()->statusCodeEquals(Response::HTTP_FORBIDDEN); $normalAdminUser = $this->createUser(['access administration pages']); $this->drupalLogin($normalAdminUser); // Check that authenticated user cannot access to the overview page. $this->drupalGet('admin/content/alert-banner'); - $this->assertResponse(Response::HTTP_FORBIDDEN); + $this->assertSession()->statusCodeEquals(Response::HTTP_FORBIDDEN); // Check that authenticated user does not have CRUD page access. $this->drupalGet('admin/content/alert-banner/add/localgov_alert_banner'); - $this->assertResponse(Response::HTTP_FORBIDDEN); + $this->assertSession()->statusCodeEquals(Response::HTTP_FORBIDDEN); $this->drupalGet('admin/content/alert-banner/1/edit'); - $this->assertResponse(Response::HTTP_FORBIDDEN); + $this->assertSession()->statusCodeEquals(Response::HTTP_FORBIDDEN); $this->drupalGet('admin/content/alert-banner/1/revisions'); - $this->assertResponse(Response::HTTP_FORBIDDEN); + $this->assertSession()->statusCodeEquals(Response::HTTP_FORBIDDEN); $this->drupalGet('admin/content/alert-banner/1/delete'); - $this->assertResponse(Response::HTTP_FORBIDDEN); + $this->assertSession()->statusCodeEquals(Response::HTTP_FORBIDDEN); // Check that authenticated user cannot view the alert banner main page. $this->drupalGet('admin/content/alert-banner/1'); - $this->assertResponse(Response::HTTP_FORBIDDEN); + $this->assertSession()->statusCodeEquals(Response::HTTP_FORBIDDEN); // Check that authenticated user cannot access the alert banner types. $this->drupalGet('admin/structure/alert-banner-types/localgov_alert_banner_type'); - $this->assertResponse(Response::HTTP_FORBIDDEN); + $this->assertSession()->statusCodeEquals(Response::HTTP_FORBIDDEN); $this->drupalLogout(); @@ -105,25 +105,25 @@ public function testAlertBannerUserAccess() { // Check that emergency publisher user has access to the overview page. $this->drupalGet('admin/content/alert-banner'); - $this->assertResponse(Response::HTTP_OK); + $this->assertSession()->statusCodeEquals(Response::HTTP_OK); // Check that emergency publisher user has CRUD page access. $this->drupalGet('admin/content/alert-banner/add/localgov_alert_banner'); - $this->assertResponse(Response::HTTP_OK); + $this->assertSession()->statusCodeEquals(Response::HTTP_OK); $this->drupalGet('admin/content/alert-banner/1/edit'); - $this->assertResponse(Response::HTTP_OK); + $this->assertSession()->statusCodeEquals(Response::HTTP_OK); $this->drupalGet('admin/content/alert-banner/1/revisions'); - $this->assertResponse(Response::HTTP_OK); + $this->assertSession()->statusCodeEquals(Response::HTTP_OK); $this->drupalGet('admin/content/alert-banner/1/delete'); - $this->assertResponse(Response::HTTP_OK); + $this->assertSession()->statusCodeEquals(Response::HTTP_OK); // Check that emergency publisher user can view the alert banner main page. $this->drupalGet('admin/content/alert-banner/1'); - $this->assertResponse(Response::HTTP_OK); + $this->assertSession()->statusCodeEquals(Response::HTTP_OK); // Check that emergency publisher user cannot access the alert banner types. $this->drupalGet('admin/structure/alert-banner-types/localgov_alert_banner_type'); - $this->assertResponse(Response::HTTP_FORBIDDEN); + $this->assertSession()->statusCodeEquals(Response::HTTP_FORBIDDEN); $this->drupalLogout(); @@ -138,21 +138,21 @@ public function testAlertBannerUserAccess() { // Check that emergency publisher user has access to the overview page. $this->drupalGet('admin/content/alert-banner'); - $this->assertResponse(Response::HTTP_OK); + $this->assertSession()->statusCodeEquals(Response::HTTP_OK); // Check that emergency publisher user has CRUD page access. $this->drupalGet('admin/content/alert-banner/add/localgov_alert_banner'); - $this->assertResponse(Response::HTTP_OK); + $this->assertSession()->statusCodeEquals(Response::HTTP_OK); $this->drupalGet('admin/content/alert-banner/1/edit'); - $this->assertResponse(Response::HTTP_OK); + $this->assertSession()->statusCodeEquals(Response::HTTP_OK); $this->drupalGet('admin/content/alert-banner/1/revisions'); - $this->assertResponse(Response::HTTP_OK); + $this->assertSession()->statusCodeEquals(Response::HTTP_OK); $this->drupalGet('admin/content/alert-banner/1/delete'); - $this->assertResponse(Response::HTTP_OK); + $this->assertSession()->statusCodeEquals(Response::HTTP_OK); // Check that emergency publisher user can view the alert banner main page. $this->drupalGet('admin/content/alert-banner/1'); - $this->assertResponse(Response::HTTP_OK); + $this->assertSession()->statusCodeEquals(Response::HTTP_OK); $this->drupalLogout(); @@ -165,7 +165,7 @@ public function testAlertBannerUserAccess() { // Check that the admin user can access the alert banner types. $this->drupalGet('admin/structure/alert-banner-types/localgov_alert_banner_type'); - $this->assertResponse(Response::HTTP_OK); + $this->assertSession()->statusCodeEquals(Response::HTTP_OK); } } diff --git a/tests/src/Functional/ViewsStatusLinkTest.php b/tests/src/Functional/ViewsStatusLinkTest.php index bd7d72d6..6537d70b 100644 --- a/tests/src/Functional/ViewsStatusLinkTest.php +++ b/tests/src/Functional/ViewsStatusLinkTest.php @@ -22,7 +22,7 @@ class ViewsStatusLinkTest extends BrowserTestBase { /** * {@inheritdoc} */ - public static $modules = ['localgov_alert_banner']; + protected static $modules = ['localgov_alert_banner']; /** * {@inheritdoc} @@ -32,7 +32,7 @@ class ViewsStatusLinkTest extends BrowserTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $emergencyPublisherUser = $this->createUser(); diff --git a/tests/src/FunctionalJavascript/AlertBannerHideTest.php b/tests/src/FunctionalJavascript/AlertBannerHideTest.php index 230cdf7f..22da97ea 100644 --- a/tests/src/FunctionalJavascript/AlertBannerHideTest.php +++ b/tests/src/FunctionalJavascript/AlertBannerHideTest.php @@ -22,7 +22,7 @@ class AlertBannerHideTest extends WebDriverTestBase { /** * {@inheritdoc} */ - public static $modules = [ + protected static $modules = [ 'localgov_alert_banner', ]; diff --git a/tests/src/Kernel/AlertBannerBlockOrderTest.php b/tests/src/Kernel/AlertBannerBlockOrderTest.php index 10718c7d..599c46c0 100644 --- a/tests/src/Kernel/AlertBannerBlockOrderTest.php +++ b/tests/src/Kernel/AlertBannerBlockOrderTest.php @@ -18,7 +18,7 @@ class AlertBannerBlockOrderTest extends KernelTestBase { * * @var array */ - public static $modules = [ + protected static $modules = [ 'system', 'field', 'text', @@ -33,7 +33,7 @@ class AlertBannerBlockOrderTest extends KernelTestBase { /** * {@inheritdoc} */ - public function setUp() { + public function setUp(): void { parent::setup(); $this->installEntitySchema('user'); From 5a82586e64f5b1e3e168ddc1616010daa70d3490 Mon Sep 17 00:00:00 2001 From: Andy Broomfield Date: Tue, 11 May 2021 08:42:43 +0100 Subject: [PATCH 3/8] Delete localgov_alert_banner.services.yml As the route subscriber was the only service, there is nothing in this file now. --- localgov_alert_banner.services.yml | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 localgov_alert_banner.services.yml diff --git a/localgov_alert_banner.services.yml b/localgov_alert_banner.services.yml deleted file mode 100644 index ee542550..00000000 --- a/localgov_alert_banner.services.yml +++ /dev/null @@ -1,5 +0,0 @@ -services: - localgov_alert_banner.route_subscriber: - class: Drupal\localgov_alert_banner\Routing\AlertBannerRouteSubscriber - tags: - - { name: event_subscriber } From a2664b59a457da6f78937c380366f59c4640f75b Mon Sep 17 00:00:00 2001 From: Stephen Cox Date: Tue, 18 May 2021 14:49:00 +0100 Subject: [PATCH 4/8] Updated Github CI to run 1.x branch against Drupal 8 and 9 (#140) --- .github/workflows/test.yml | 99 +++++++++++++++++++++++++++++--------- 1 file changed, 75 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c7655c5f..a9504ffd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,9 +2,11 @@ name: Test LocalGov Drupal Alert Banner on: push: - branches: [ master ] + branches: + - '1.x' pull_request: - branches: [ master ] + branches: + - '1.x' jobs: @@ -12,39 +14,55 @@ jobs: 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: 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: | @@ -52,22 +70,33 @@ jobs: 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 }}:"dev-${GIT_BRANCH} 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 @@ -84,15 +113,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 @@ -109,6 +149,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 @@ -121,9 +172,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 From b3eee8c6a192814c60ca089351b12ca81e59340c Mon Sep 17 00:00:00 2001 From: Stephen Cox Date: Tue, 18 May 2021 15:17:29 +0100 Subject: [PATCH 5/8] Check which branch is being merged and configure composer accordinglg in Github CI --- .github/workflows/test.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a9504ffd..f2851e36 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,6 +40,16 @@ jobs: 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.base_ref, ".x") + run: | + echo "COMPOSER_REF=${GIT_BRANCH}-dev" >> $GITHUB_ENV + + - name: Set composer branch reference for main version branches + if: ! endsWith(github.base_ref, ".x") + run: | + echo "COMPOSER_REF=dev-${GIT_BRANCH}" >> $GITHUB_ENV - name: Cached workspace uses: actions/cache@v2 @@ -70,7 +80,7 @@ jobs: 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 ${GIT_BASE%'.x'}" + 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 From 5d30974d8cc92bde17b2615d15486970bf0422c2 Mon Sep 17 00:00:00 2001 From: Stephen Cox Date: Tue, 18 May 2021 15:19:21 +0100 Subject: [PATCH 6/8] Update test.yml --- .github/workflows/test.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f2851e36..c5a4ae65 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,13 +43,11 @@ jobs: - name: Set composer branch reference for main version branches if: endsWith(github.base_ref, ".x") - run: | - echo "COMPOSER_REF=${GIT_BRANCH}-dev" >> $GITHUB_ENV + run: echo "COMPOSER_REF=${GIT_BRANCH}-dev" >> $GITHUB_ENV - name: Set composer branch reference for main version branches - if: ! endsWith(github.base_ref, ".x") - run: | - echo "COMPOSER_REF=dev-${GIT_BRANCH}" >> $GITHUB_ENV + if: endsWith(github.base_ref, ".x") == false + run: echo "COMPOSER_REF=dev-${GIT_BRANCH}" >> $GITHUB_ENV - name: Cached workspace uses: actions/cache@v2 From 03622798917eab3344e2e9695bce6c84b7fea2bd Mon Sep 17 00:00:00 2001 From: Stephen Cox Date: Tue, 18 May 2021 15:20:29 +0100 Subject: [PATCH 7/8] Update test.yml --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c5a4ae65..86ae6eab 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,11 +42,11 @@ jobs: 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.base_ref, ".x") + if: endsWith(github.base_ref, '.x') run: echo "COMPOSER_REF=${GIT_BRANCH}-dev" >> $GITHUB_ENV - name: Set composer branch reference for main version branches - if: endsWith(github.base_ref, ".x") == false + if: endsWith(github.base_ref, '.x') == false run: echo "COMPOSER_REF=dev-${GIT_BRANCH}" >> $GITHUB_ENV - name: Cached workspace From ee7fafe8c896ba2af7524193163653dd7522177f Mon Sep 17 00:00:00 2001 From: Stephen Cox Date: Tue, 18 May 2021 15:22:39 +0100 Subject: [PATCH 8/8] Update test.yml --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 86ae6eab..fc260e6a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,11 +42,11 @@ jobs: 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.base_ref, '.x') + 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.base_ref, '.x') == false + if: endsWith(github.ref, '.x') == false run: echo "COMPOSER_REF=dev-${GIT_BRANCH}" >> $GITHUB_ENV - name: Cached workspace