diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 50d09230f..848960229 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['8.1'] + php-versions: ['8.3'] container: image: ghcr.io/city-of-helsinki/drupal-php-docker:${{ matrix.php-versions }}-alpine steps: diff --git a/.github/workflows/pr-close-cleanup.yml b/.github/workflows/pr-close-cleanup.yml index 555254f6f..6b1e2013c 100644 --- a/.github/workflows/pr-close-cleanup.yml +++ b/.github/workflows/pr-close-cleanup.yml @@ -3,6 +3,9 @@ on: pull_request: types: [closed] +concurrency: + group: visual-regression + jobs: delete_folder: runs-on: ubuntu-latest diff --git a/.github/workflows/visual.yml b/.github/workflows/visual.yml index b13229348..0efe94fb3 100644 --- a/.github/workflows/visual.yml +++ b/.github/workflows/visual.yml @@ -1,19 +1,26 @@ on: pull_request: - types: [opened, reopened, synchronize] + types: [opened, reopened, synchronize, ready_for_review] + branches-ignore: + - 'renovate/**' push: branches: - main env: SIMPLETEST_DB: mysql://drupal:drupal@db:3306/drupal name: Visual regression tests + +concurrency: + group: visual-regression + jobs: tests: + if: github.event.pull_request.draft == false runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: - fetch-depth: 1 + fetch-depth: 0 - name: Set variables run: echo "DRUPAL_ROOT=$HOME/drupal" >> $GITHUB_ENV @@ -43,7 +50,7 @@ jobs: COMPOSER_MIRROR_PATH_REPOS: 1 run: | composer config repositories.5 path $GITHUB_WORKSPACE - composer require drupal/$THEME_NAME -W + composer require drupal/redis drupal/$THEME_NAME -W # We use COMPOSER_MIRROR_PATH_REPOS=1 to mirror local repository # instead of symlinking it to make sure the code is available inside # the app container. @@ -77,6 +84,7 @@ jobs: if: steps.drupal-cache.outputs.cache-hit != 'true' run: | docker compose exec app bash -c "drush si minimal -y" + docker compose exec app bash -c "drush en redis -y" docker compose exec app bash -c "drush en helfi_test_content -y" docker compose exec app bash -c "drush sql-dump --result-file=/app/public/sites/default/files/latest.sql" @@ -134,7 +142,7 @@ jobs: run: docker compose logs app > /tmp/container.log - name: Deploy to PR preview - uses: peaceiris/actions-gh-pages@v3 + uses: peaceiris/actions-gh-pages@v4 if: github.ref != 'refs/heads/main' with: github_token: ${{ secrets.GITHUB_TOKEN }} @@ -142,14 +150,11 @@ jobs: destination_dir: pull/${{github.event.number}} - name: Update comment - uses: hasura/comment-progress@v2.3.0 if: github.ref != 'refs/heads/main' + uses: thollander/actions-comment-pull-request@v2 with: - github-token: ${{ secrets.GITHUB_TOKEN }} - repository: ${{ github.repository }} - number: ${{ github.event.number }} - id: deploy-preview - recreate: true + comment_tag: status + pr_number: ${{ github.event.number }} message: "${{join(steps.run-tests.outputs.*, ' ')}}" - name: Upload container logs diff --git a/hdbt.theme b/hdbt.theme index 7b8f7a8e8..37f1b699e 100644 --- a/hdbt.theme +++ b/hdbt.theme @@ -509,6 +509,15 @@ function hdbt_preprocess_input__submit(&$variables): void { * Implements hook_preprocess_HOOK(). */ function hdbt_preprocess_menu(&$variables): void { + // Menu, mobile menu, fallback menu and sidebar menu tree depth. + // Counting from "instance", "main level", "level 3", "level 4", "level 5"... + $menu_depth = 5; + $variables['menu_depth'] = $menu_depth; + $variables['#attached']['drupalSettings']['menu_depth'] = $menu_depth; + + if (isset($variables['attributes']['block_id']) && str_starts_with('external_menu_', $variables['attributes']['block_id'])) { + return; + } $apply_lang_attribute = array_key_exists('menu_type', $variables); if ( @@ -521,12 +530,6 @@ function hdbt_preprocess_menu(&$variables): void { foreach ($variables['items'] as &$item) { _hdbt_menu_item_apply_attributes($item, $apply_lang_attribute); } - - // Menu, mobile menu, fallback menu and sidebar menu tree depth. - // Counting from "instance", "main level", "level 3", "level 4", "level 5"... - $menu_depth = 5; - $variables['menu_depth'] = $menu_depth; - $variables['#attached']['drupalSettings']['menu_depth'] = $menu_depth; } /** @@ -569,25 +572,15 @@ function _hdbt_menu_item_apply_attributes(array &$item, bool $apply_lang_attribu array_key_exists('original_link', $item) && $item['original_link'] instanceof MenuLinkContent ) { - // MenuLinkContent::getEntity() has protected visibility and cannot be used - // to directly fetch the entity. - $metadata = $item['original_link']->getMetaData(); - - if (!empty($metadata['entity_id'])) { - $entity_type_manager = Drupal::entityTypeManager(); - $menu_link_content = $entity_type_manager - ->getStorage('menu_link_content') - ->load($metadata['entity_id']); + $menu_link_content = $item['original_link']->getEntity(); - // Add the possible lang attribute to menu item attributes. - if ( - !empty($menu_link_content) && - $menu_link_content->hasField('lang_attribute') && - !$menu_link_content->get('lang_attribute')->isEmpty() - ) { - $lang_attribute = $menu_link_content->get('lang_attribute')->value; - $item['attributes']->setAttribute('lang', $lang_attribute); - } + // Add the possible lang attribute to menu item attributes. + if ( + $menu_link_content->hasField('lang_attribute') && + !$menu_link_content->get('lang_attribute')->isEmpty() + ) { + $lang_attribute = $menu_link_content->get('lang_attribute')->value; + $item['attributes']->setAttribute('lang', $lang_attribute); } } }