diff --git a/.circleci/config.yml b/.circleci/config.yml index ab30b199593f89..5496c37351a6d1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -115,7 +115,7 @@ jobs: pids+=($!) (pnpm nx affected --targets=lint,test,build --base=$NX_BASE --head=$NX_HEAD --parallel=3 && - pnpm nx affected --target=e2e --base=$NX_BASE --head=$NX_HEAD --parallel=1) & + pnpm nx affected --targets=e2e,e2e-ci --base=$NX_BASE --head=$NX_HEAD --parallel=1) & pids+=($!) for pid in "${pids[@]}"; do diff --git a/nx-dev/nx-dev-e2e/playwright.config.ts b/nx-dev/nx-dev-e2e/playwright.config.ts index f13fec3217d653..2cac5b883afc83 100644 --- a/nx-dev/nx-dev-e2e/playwright.config.ts +++ b/nx-dev/nx-dev-e2e/playwright.config.ts @@ -1,13 +1,8 @@ import { defineConfig, devices } from '@playwright/test'; -import { nxE2EPreset } from '@nx/playwright/preset'; // nx-ignore-next-line -import { workspaceRoot } from '@nx/devkit'; - // For CI, you may want to set BASE_URL to the deployed application. const baseURL = process.env['BASE_URL'] || 'http://localhost:4200'; - -const preset = nxE2EPreset(__filename, { testDir: './src' }); /** * Read environment variables from file. * https://github.com/motdotla/dotenv @@ -18,10 +13,18 @@ const preset = nxE2EPreset(__filename, { testDir: './src' }); * See https://playwright.dev/docs/test-configuration. */ export default defineConfig({ - ...preset, - // CI default is 'dot', which doesn't show error output in CI. - // use list so errors are visible in CI logs - reporter: process.env.CI ? 'list' : preset.reporter, + testDir: './src', + outputDir: '../../dist/.playwright/nx-dev-e2e/test-output', + /* 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, + /* Opt out of parallel tests on CI. */ + workers: process.env.CI ? 1 : undefined, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: 'list', // how long the entire suite can run, prevent CI from timing out globalTimeout: process.env.CI ? 1_800_000 : undefined, /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ @@ -34,25 +37,14 @@ export default defineConfig({ }, /* Run your local dev server before starting the tests */ webServer: { - command: 'pnpm exec nx run nx-dev:serve:production', + command: 'pnpm exec nx run nx-dev:next-start', url: 'http://localhost:4200', reuseExistingServer: !process.env.CI, - cwd: workspaceRoot, }, projects: [ { name: 'chromium', use: { ...devices['Desktop Chrome'] }, }, - - { - name: 'firefox', - use: { ...devices['Desktop Firefox'] }, - }, - - { - name: 'webkit', - use: { ...devices['Desktop Safari'] }, - }, ], }); diff --git a/nx-dev/nx-dev-e2e/project.json b/nx-dev/nx-dev-e2e/project.json index a56c512397c161..eb05668bbd6216 100644 --- a/nx-dev/nx-dev-e2e/project.json +++ b/nx-dev/nx-dev-e2e/project.json @@ -4,21 +4,7 @@ "sourceRoot": "nx-dev/nx-dev-e2e/src", "projectType": "application", "targets": { - "lint": {}, - "e2e": { - "dependsOn": [ - { - "target": "build-base", - "dependencies": true - } - ], - "executor": "@nx/playwright:playwright", - "outputs": ["{workspaceRoot}/dist/.playwright/nx-dev/nx-dev-e2e"], - "options": { - "config": "nx-dev/nx-dev-e2e/playwright.config.ts", - "project": ["chromium"] - } - } + "lint": {} }, "tags": ["scope:nx-dev", "type:e2e"], "implicitDependencies": ["nx-dev"] diff --git a/nx-dev/nx-dev/next-sitemap.config.js b/nx-dev/nx-dev/next-sitemap.config.js index 2815b1a32e313c..0a2caa2fe5a179 100644 --- a/nx-dev/nx-dev/next-sitemap.config.js +++ b/nx-dev/nx-dev/next-sitemap.config.js @@ -1,4 +1,4 @@ -const path = require('path'); +const path = require('node:path'); module.exports = { siteUrl: process.env.SITE_URL || 'https://nx.dev', diff --git a/nx-dev/nx-dev/next.config.js b/nx-dev/nx-dev/next.config.js index 2880cb7382d74f..d02801b7a13c4d 100644 --- a/nx-dev/nx-dev/next.config.js +++ b/nx-dev/nx-dev/next.config.js @@ -3,6 +3,8 @@ const { withNx } = require('@nx/next/plugins/with-nx'); const redirectRules = require('./redirect-rules'); module.exports = withNx({ + // This is technically invalid, but we need to update our Vercel setting it order to change this. + distDir: '../../dist/nx-dev/nx-dev/.next', // For both client and server env: { VERCEL: process.env.VERCEL, diff --git a/nx-dev/nx-dev/project.json b/nx-dev/nx-dev/project.json index 5c6685b8c6fcd3..766cfc20d46ed3 100644 --- a/nx-dev/nx-dev/project.json +++ b/nx-dev/nx-dev/project.json @@ -4,15 +4,25 @@ "sourceRoot": "nx-dev/nx-dev", "projectType": "application", "targets": { + "next-build": { + "dependsOn": ["copy-docs"] + }, + "next-dev": { + "dependsOn": ["copy-docs"], + "options": { + "args": "--port 4200" + } + }, + "next-start": { + "options": { + "args": "--port 4200" + } + }, "build": { - "dependsOn": [ - { - "target": "build-base" - } - ], "executor": "nx:run-commands", "options": { "commands": [ + "nx run nx-dev:build", "nx run nx-dev:sitemap", "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/documentation/internal-link-checker.ts" ], @@ -23,10 +33,10 @@ "^production", "{workspaceRoot}/scripts/tsconfig.scripts.json", "{workspaceRoot}/scripts/documentation/internal-link-checker.ts" - ], - "outputs": ["{workspaceRoot}/dist/nx-dev/nx-dev"] + ] }, "sitemap": { + "dependsOn": ["next-build"], "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/dist/nx-dev/nx-dev/public"], "options": { @@ -47,21 +57,6 @@ "command": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/documentation/open-graph/generate-images.ts" } }, - "build-base": { - "executor": "@nx/next:build", - "dependsOn": ["copy-docs"], - "outputs": ["{options.outputPath}"], - "options": { - "root": "nx-dev/nx-dev", - "outputPath": "dist/nx-dev/nx-dev" - }, - "configurations": { - "development": { - "outputPath": "nx-dev/nx-dev" - }, - "production": {} - } - }, "copy-docs": { "inputs": ["{workspaceRoot}/docs/**/*"], "outputs": ["{projectRoot}/public/documentation"], @@ -75,30 +70,11 @@ "options": { "commands": [ "nx watch --projects=docs -- nx run nx-dev:copy-docs", - "nx run nx-dev:serve" + "nx run nx-dev:next-dev" ], "parallel": true } }, - "serve": { - "executor": "@nx/next:server", - "dependsOn": ["copy-docs"], - "options": { - "buildTarget": "nx-dev:build-base", - "dev": true - }, - "configurations": { - "production": { - "buildTarget": "nx-dev:build-base:production", - "dev": false - }, - "development": { - "buildTarget": "nx-dev:build-base:development", - "dev": true - } - }, - "defaultConfiguration": "development" - }, "deploy-build": { "executor": "nx:run-commands", "outputs": ["{projectRoot}/public/documentation"], @@ -129,12 +105,6 @@ "parallel": false } }, - "export": { - "executor": "@nx/next:export", - "options": { - "buildTarget": "nx-dev:build:production" - } - }, "lint": {}, "test": {} }, diff --git a/nx.json b/nx.json index 615a24406cc229..c84790c1b82202 100644 --- a/nx.json +++ b/nx.json @@ -210,7 +210,24 @@ } } }, - "plugins": ["@monodon/rust"], + "plugins": [ + "@monodon/rust", + { + "plugin": "@nx/next/plugin", + "options": { + "buildTargetName": "next-build", + "devTargetName": "next-dev", + "startTargetName": "next-start" + } + }, + { + "plugin": "@nx/playwright/plugin", + "options": { + "targetName": "pw-e2e", + "ciTargetName": "e2e-ci" + } + } + ], "nxCloudAccessToken": "YmZiOWQyNzctOThiZC00MjYwLWI3YTAtZDA3MDg4YWY1YTExfHJlYWQ=", "nxCloudUrl": "https://staging.nx.app", "parallel": 1,