From 836f7d4b81fdda13ac0e39186e3a6b83116d2fe0 Mon Sep 17 00:00:00 2001 From: miguelangarano Date: Mon, 25 Nov 2024 13:56:00 -0500 Subject: [PATCH] feat: added single project for or8n --- .github/workflows/or8n.yml | 35 ++++++++++++++++++++++++++++++++ README.md | 22 ++++++++++++++++++++ apps/e2e-03/eslint.config.js | 13 ++++++++++++ apps/e2e-03/playwright.config.ts | 20 ++++++++++++++++++ apps/e2e-03/project.json | 19 +++++++++++++++++ apps/e2e-03/src/e2e-03-1.spec.ts | 5 +++++ apps/e2e-03/src/e2e-03-2.spec.ts | 5 +++++ apps/e2e-03/src/e2e-03.spec.ts | 5 +++++ apps/e2e-03/tsconfig.json | 19 +++++++++++++++++ 9 files changed, 143 insertions(+) create mode 100644 .github/workflows/or8n.yml create mode 100644 apps/e2e-03/eslint.config.js create mode 100644 apps/e2e-03/playwright.config.ts create mode 100644 apps/e2e-03/project.json create mode 100644 apps/e2e-03/src/e2e-03-1.spec.ts create mode 100644 apps/e2e-03/src/e2e-03-2.spec.ts create mode 100644 apps/e2e-03/src/e2e-03.spec.ts create mode 100644 apps/e2e-03/tsconfig.json diff --git a/.github/workflows/or8n.yml b/.github/workflows/or8n.yml new file mode 100644 index 0000000..b530a95 --- /dev/null +++ b/.github/workflows/or8n.yml @@ -0,0 +1,35 @@ +name: Run or8n Tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + e2e_tests: + runs-on: ubuntu-latest + strategy: + matrix: + shard: [1, 2, 3] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install Dependencies + run: npm install + + - name: Reset NX + run: npx nx reset + + - name: Run All E2E Tests + env: + CURRENTS_API_URL: https://cy-staging.currents.dev + CURRENTS_PROJECT_ID: ${{secrets.CURRENTS_PROJECT_ID}} + CURRENTS_RECORD_KEY: ${{secrets.CURRENTS_RECORD_KEY}} + CURRENTS_CI_BUILD_ID: ${{ github.run_id }}-${{ github.sha }} + run: npx nx run-many -t or8n --verbose --base=main~1 --head=HEAD diff --git a/README.md b/README.md index c77f434..5485109 100644 --- a/README.md +++ b/README.md @@ -92,3 +92,25 @@ nx run-many -t e2e --parallel=2 --verbose --last-failed - nx run e2e-01:e2e ``` + +## Single project orchestration + +The project named `e2e-03` has a different target than the other two projects. The target is `or8n` +This target project executes `pwc-p` command. When using it in multiple machines it will execute in parallel the tests of this project. + +```sh +CURRENTS_RECORD_KEY=recordkey \ +CURRENTS_PROJECT_ID=projectid \ +CURRENTS_CI_BUILD_ID=`date +%s` \ +nx run-many -t or8n + +# ... + + NX Running target or8n for 1 project + + ⠙ nx run e2e-03:or8n +``` + +The `parallel` flag is no longer needed as it is running a single nx project. + +The `or8n.yml` file has an example for running it in Github actions. diff --git a/apps/e2e-03/eslint.config.js b/apps/e2e-03/eslint.config.js new file mode 100644 index 0000000..4e73819 --- /dev/null +++ b/apps/e2e-03/eslint.config.js @@ -0,0 +1,13 @@ +const playwright = require('eslint-plugin-playwright'); +const baseConfig = require('../../eslint.config.js'); + +module.exports = [ + playwright.configs['flat/recommended'], + + ...baseConfig, + { + files: ['**/*.ts', '**/*.js'], + // Override or add rules here + rules: {}, + }, +]; diff --git a/apps/e2e-03/playwright.config.ts b/apps/e2e-03/playwright.config.ts new file mode 100644 index 0000000..95d40a8 --- /dev/null +++ b/apps/e2e-03/playwright.config.ts @@ -0,0 +1,20 @@ +import { nxE2EPreset } from '@nx/playwright/preset'; +import { defineConfig, devices } from '@playwright/test'; +// eslint-disable-next-line @nx/enforce-module-boundaries +import { reporter } from '../../playwright.config'; + +const nxConf = nxE2EPreset(__filename); +export default defineConfig({ + ...nxConf, + reporter, + testDir: './src', + use: { + trace: 'on-first-retry', + }, + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] }, + }, + ], +}); diff --git a/apps/e2e-03/project.json b/apps/e2e-03/project.json new file mode 100644 index 0000000..a558283 --- /dev/null +++ b/apps/e2e-03/project.json @@ -0,0 +1,19 @@ +{ + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "name": "e2e-03", + "projectType": "application", + "sourceRoot": "apps/e2e-03/src", + "targets": { + "or8n": { + "executor": "nx:run-commands", + "options": { + "config": "apps/e2e-03/playwright.config.ts", + "commands": [ + { + "command": "npx pwc-p" + } + ] + } + } + } +} diff --git a/apps/e2e-03/src/e2e-03-1.spec.ts b/apps/e2e-03/src/e2e-03-1.spec.ts new file mode 100644 index 0000000..442abb9 --- /dev/null +++ b/apps/e2e-03/src/e2e-03-1.spec.ts @@ -0,0 +1,5 @@ +import { expect, test } from '@playwright/test'; + +test('e2e-03-1', async () => { + expect(1).toBe(1); +}); diff --git a/apps/e2e-03/src/e2e-03-2.spec.ts b/apps/e2e-03/src/e2e-03-2.spec.ts new file mode 100644 index 0000000..8a2c6b8 --- /dev/null +++ b/apps/e2e-03/src/e2e-03-2.spec.ts @@ -0,0 +1,5 @@ +import { expect, test } from '@playwright/test'; + +test('e2e-03-2', async () => { + expect(1).toBe(1); +}); diff --git a/apps/e2e-03/src/e2e-03.spec.ts b/apps/e2e-03/src/e2e-03.spec.ts new file mode 100644 index 0000000..78979fd --- /dev/null +++ b/apps/e2e-03/src/e2e-03.spec.ts @@ -0,0 +1,5 @@ +import { expect, test } from '@playwright/test'; + +test('e2e-03', async () => { + expect(1).toBe(1); +}); diff --git a/apps/e2e-03/tsconfig.json b/apps/e2e-03/tsconfig.json new file mode 100644 index 0000000..114364a --- /dev/null +++ b/apps/e2e-03/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "allowJs": true, + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "sourceMap": false + }, + "include": [ + "**/*.ts", + "**/*.js", + "playwright.config.ts", + "src/**/*.spec.ts", + "src/**/*.spec.js", + "src/**/*.test.ts", + "src/**/*.test.js", + "src/**/*.d.ts" + ] +}