From 117a5a5a442e511618bbea19d6aa56302a910f92 Mon Sep 17 00:00:00 2001 From: Alex Tkachev Date: Thu, 7 Mar 2024 17:12:11 +0400 Subject: [PATCH] chore(SLB-261): high volume content test --- .github/workflows/high_content_volume.yml | 50 +++++++++ .../create-100-pages.php | 99 ++++++++++++++++++ .../scripts/create-lots-of-content/run.php | 21 ++++ .../scripts/create-lots-of-content/tiny.png | Bin 0 -> 103 bytes 4 files changed, 170 insertions(+) create mode 100644 .github/workflows/high_content_volume.yml create mode 100644 apps/cms/scripts/create-lots-of-content/create-100-pages.php create mode 100644 apps/cms/scripts/create-lots-of-content/run.php create mode 100644 apps/cms/scripts/create-lots-of-content/tiny.png diff --git a/.github/workflows/high_content_volume.yml b/.github/workflows/high_content_volume.yml new file mode 100644 index 000000000..2accff98f --- /dev/null +++ b/.github/workflows/high_content_volume.yml @@ -0,0 +1,50 @@ +name: High Content Volume +on: + workflow_dispatch: + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Setup + uses: ./.github/actions/setup + + - name: TurboRepo local server + uses: felixmosh/turborepo-gh-artifacts@v2 + with: + server-token: 'local' + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Prepare + run: pnpm turbo:prep + env: + TURBO_API: 'http://127.0.0.1:9080' + TURBO_TOKEN: 'local' + TURBO_TEAM: 'local' + + - name: 'Drupal: Start' + run: pnpm --filter "@custom/cms" drush start & + + - name: 'Gatsby: Clean' + run: pnpm --filter "@custom/website" gatsby clean + + - name: 'Drupal: Create content' + run: pnpm --filter "@custom/cms" drush php:script scripts/create-lots-of-content/run.php + + - name: 'Gatsby: Full build' + run: pnpm --filter "@custom/website" gatsby build + + - name: 'Gatsby: Incremental build without new content' + run: pnpm --filter "@custom/website" gatsby build + + - name: 'Drupal: Create more content' + run: pnpm --filter "@custom/cms" drush php:script scripts/create-lots-of-content/create-100-pages.php + + - name: 'Gatsby: Incremental build with new content' + run: pnpm --filter "@custom/website" gatsby build diff --git a/apps/cms/scripts/create-lots-of-content/create-100-pages.php b/apps/cms/scripts/create-lots-of-content/create-100-pages.php new file mode 100644 index 000000000..a204b13c9 --- /dev/null +++ b/apps/cms/scripts/create-lots-of-content/create-100-pages.php @@ -0,0 +1,99 @@ +writeData($imageData, "public://" . $random->machineName(32) . ".png"); + } + + // Prepare image media entities. + /** @var \Drupal\media\MediaInterface[] $media */ + $media = []; + foreach ($images as $i => $image) { + $media[$i] = Media::create([ + 'name' => $random->name(), + 'bundle' => 'image', + 'uid' => 1, + 'status' => TRUE, + 'field_media_image' => [ + 'target_id' => $image->id(), + 'alt' => 'Alt text', + 'title' => 'Title text', + ], + ]); + $media[$i]->save(); + } + $mediaIds = array_map(fn ($media) => $media->id(), $media); + + // Create a page. + $title = $random->name(); + $node = Node::create([ + 'type' => 'page', + 'status' => TRUE, + 'uid' => 1, + 'title' => $title, + 'moderation_state' => 'published', + 'body' => [ + 'value' => pageBody($mediaIds, FALSE), + 'format' => 'gutenberg', + 'summary' => '', + ], + ]); + $node->addTranslation('de', [ + 'title' => $title . ' DE', + 'uid' => 1, + 'body' => [ + 'value' => pageBody($mediaIds, TRUE), + 'format' => 'gutenberg', + 'summary' => '', + ], + ]); + $node->save(); +} + +function pageBody(array $mediaIds, bool $isGerman): string { + $suffix = $isGerman ? ' DE' : ''; + return << + + + +

Some content$suffix

+ + + + + +

Some content$suffix

+ + + + + +

Some content$suffix

+ + + + + +

+ + +EOT; +} + + diff --git a/apps/cms/scripts/create-lots-of-content/run.php b/apps/cms/scripts/create-lots-of-content/run.php new file mode 100644 index 000000000..d284a93f5 --- /dev/null +++ b/apps/cms/scripts/create-lots-of-content/run.php @@ -0,0 +1,21 @@ +Z@7O_`AuDqv< tV@O8h+k=d}K;EGR-~Ds>%ohNeV6cx@5vYGw!o#Z|uBWS?%Q~loCIC3R7svnr literal 0 HcmV?d00001