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

Various improvements #349

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,26 @@ runs:
exit 1
fi

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
name: Setup pnpm cache
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
path: /tmp/cache
key: |
cache-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
cache-${{ hashFiles('**/pnpm-lock.yaml') }}-
cache-
- name: Set composer cache dir
run: composer config --global cache-files-dir /tmp/cache/composer
shell: bash
- name: Set pnpm cache dir
run: pnpm config set store-dir /tmp/cache/pnpm
shell: bash
- name: Set Playwright browsers dir
run:
echo "PLAYWRIGHT_BROWSERS_PATH=/tmp/cache/playwright-browsers" >>
$GITHUB_ENV
shell: bash

- name: Install dependencies
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion apps/cms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"drush": "SB_ENVIRONMENT=1 SIMPLETEST_DB=sqlite://localhost/sites/default/files/.sqlite DRUSH_OPTIONS_URI=http://127.0.0.1:8888 vendor/bin/drush",
"silverback": "SB_ENVIRONMENT=1 SIMPLETEST_DB=sqlite://localhost/sites/default/files/.sqlite SB_ADMIN_USER=admin SB_ADMIN_PASS=admin vendor/bin/silverback",
"drupal-install": "SB_SETUP=1 pnpm silverback setup --profile minimal && pnpm content:import && pnpm drush php-eval 'node_access_rebuild();' && rm -rf install-cache.zip && pnpm fix-premissions",
"export-webforms": "pnpm turbo --filter '@custom-tests/e2e' webform-snapshots",
"export-webforms": "pnpm --filter '@custom-tests/e2e' webform-snapshots",
"start": "cd web; SB_ENVIRONMENT=1 SIMPLETEST_DB=sqlite://localhost/sites/default/files/.sqlite DRUSH_OPTIONS_URI=http://127.0.0.1:8888 php -S 0.0.0.0:8888 .ht.router.php # no drush to avoid the drush server timeout",
"dev": "pnpm start",
"clear": "pnpm drush cr",
Expand Down
17 changes: 8 additions & 9 deletions tests/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
"license": "ISC",
"type": "module",
"scripts": {
"prep": "playwright install chromium",
"test:static": "tsc --noEmit && eslint '**/*.{ts,tsx,js,jsx}' --ignore-path='./.gitignore'",
"test:integration:drupal": "playwright test --config playwright.config.drupal.ts",
"test:integration:decap": "playwright test --config playwright.config.decap.ts",
"test:headed:drupal": "playwright test --headed --config playwright.config.drupal.ts",
"test:headed:decap": "playwright test --headed --config playwright.config.decap.ts",
"dev:decap": "playwright test --ui --config playwright.config.decap.ts",
"dev:drupal": "playwright test --ui --config playwright.config.drupal.ts",
"webform-snapshots": "playwright test --config playwright.config.webforms.ts",
"webform-snapshots:headed": "playwright test --config playwright.config.webforms.ts --headed"
"test:integration:drupal": "playwright install chromium && playwright test --config playwright.config.drupal.ts",
"test:integration:decap": "playwright install chromium && playwright test --config playwright.config.decap.ts",
"test:headed:drupal": "playwright install chromium && playwright test --headed --config playwright.config.drupal.ts",
"test:headed:decap": "playwright install chromium && playwright test --headed --config playwright.config.decap.ts",
"dev:decap": "playwright install chromium && playwright test --ui --config playwright.config.decap.ts",
"dev:drupal": "playwright install chromium && playwright test --ui --config playwright.config.drupal.ts",
"webform-snapshots": "playwright install chromium && playwright test --config playwright.config.webforms.ts",
"webform-snapshots:headed": "playwright install chromium && playwright test --config playwright.config.webforms.ts --headed"
},
"devDependencies": {
"@amazeelabs/save-webpage": "^1.1.1",
Expand Down
30 changes: 2 additions & 28 deletions tests/e2e/playwright.config.decap.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import { defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
import defaults from './playwright.config.default';

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
...defaults,
testDir: './specs/decap',
webServer: [
{
Expand All @@ -18,26 +12,6 @@ export default defineConfig({
reuseExistingServer: !process.env.CI,
},
],
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Use a single worker to avoid random net::ERR_ABORTED */
workers: 1,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
Expand Down
12 changes: 12 additions & 0 deletions tests/e2e/playwright.config.default.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from '@playwright/test';

export default defineConfig({
fullyParallel: true,
retries: process.env.CI ? 2 : 0,
workers: 1,
reporter: 'html',
use: {
trace: process.env.CI ? 'retain-on-failure' : 'on',
actionTimeout: 10_000,
},
});
30 changes: 2 additions & 28 deletions tests/e2e/playwright.config.drupal.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import { defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
import defaults from './playwright.config.default';

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
...defaults,
testDir: './specs/drupal',
webServer: [
{
Expand All @@ -28,26 +22,6 @@ export default defineConfig({
reuseExistingServer: !process.env.CI,
},
],
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Use a single worker to avoid random net::ERR_ABORTED */
workers: 1,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'setup',
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/playwright.config.webforms.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { defineConfig, devices } from '@playwright/test';

import defaults from './playwright.config.drupal';
import defaults from './playwright.config.default';

export default defineConfig({
...defaults,
testDir: './webform-snapshots',
reporter: 'list',
webServer: [
{
command: 'pnpm run --filter "@custom/cms" start',
Expand Down
23 changes: 12 additions & 11 deletions tests/e2e/turbo.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
{
"extends": ["//"],
"tasks": {
"prep": {
"cache": false
},
"webform-snapshots": {
"cache": false,
"dependsOn": ["@custom/cms#prep:database", "prep"]
},
"test:integration:decap": {
"dependsOn": ["@custom/website#build", "prep"],
"dependsOn": ["@custom/website#build"],
"env": ["PLAYWRIGHT_WEBSITE_URL"],
"inputs": ["specs/decap/**", "playwright.config.decap.ts"]
"inputs": [
"specs/decap/**",
"playwright.config.decap.ts",
"playwright.config.default.ts"
]
},
"test:integration:drupal": {
"dependsOn": ["@custom/website#build", "prep"],
"dependsOn": ["@custom/website#build"],
"env": ["PLAYWRIGHT_WEBSITE_URL", "PLAYWRIGHT_CMS_URL"],
"inputs": ["specs/drupal/**", "playwright.config.drupal.ts"]
"inputs": [
"specs/drupal/**",
"playwright.config.drupal.ts",
"playwright.config.default.ts"
]
}
}
}
1 change: 1 addition & 0 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"$schema": "https://turborepo.org/schema.json",
"globalPassThroughEnv": [
"PLAYWRIGHT_BROWSERS_PATH",
// Workaround for https://github.com/jetify-com/devbox/issues/1415
"PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS",
// Env vars provided by devbox
Expand Down
Loading