Skip to content

Commit 5ae3593

Browse files
authored
Merge pull request #2 from miguelangaranocurrents/nx-single-project-or8n
[CSR-1881] feat: added single project for or8n
2 parents 1ccf765 + 836f7d4 commit 5ae3593

File tree

9 files changed

+143
-0
lines changed

9 files changed

+143
-0
lines changed

.github/workflows/or8n.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Run or8n Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
jobs:
13+
e2e_tests:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
shard: [1, 2, 3]
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v3
22+
23+
- name: Install Dependencies
24+
run: npm install
25+
26+
- name: Reset NX
27+
run: npx nx reset
28+
29+
- name: Run All E2E Tests
30+
env:
31+
CURRENTS_API_URL: https://cy-staging.currents.dev
32+
CURRENTS_PROJECT_ID: ${{secrets.CURRENTS_PROJECT_ID}}
33+
CURRENTS_RECORD_KEY: ${{secrets.CURRENTS_RECORD_KEY}}
34+
CURRENTS_CI_BUILD_ID: ${{ github.run_id }}-${{ github.sha }}
35+
run: npx nx run-many -t or8n --verbose --base=main~1 --head=HEAD

README.md

+22
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,25 @@ nx run-many -t e2e --parallel=2 --verbose --last-failed
9292

9393
- nx run e2e-01:e2e
9494
```
95+
96+
## Single project orchestration
97+
98+
The project named `e2e-03` has a different target than the other two projects. The target is `or8n`
99+
This target project executes `pwc-p` command. When using it in multiple machines it will execute in parallel the tests of this project.
100+
101+
```sh
102+
CURRENTS_RECORD_KEY=recordkey \
103+
CURRENTS_PROJECT_ID=projectid \
104+
CURRENTS_CI_BUILD_ID=`date +%s` \
105+
nx run-many -t or8n
106+
107+
# ...
108+
109+
NX Running target or8n for 1 project
110+
111+
⠙ nx run e2e-03:or8n
112+
```
113+
114+
The `parallel` flag is no longer needed as it is running a single nx project.
115+
116+
The `or8n.yml` file has an example for running it in Github actions.

apps/e2e-03/eslint.config.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const playwright = require('eslint-plugin-playwright');
2+
const baseConfig = require('../../eslint.config.js');
3+
4+
module.exports = [
5+
playwright.configs['flat/recommended'],
6+
7+
...baseConfig,
8+
{
9+
files: ['**/*.ts', '**/*.js'],
10+
// Override or add rules here
11+
rules: {},
12+
},
13+
];

apps/e2e-03/playwright.config.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { nxE2EPreset } from '@nx/playwright/preset';
2+
import { defineConfig, devices } from '@playwright/test';
3+
// eslint-disable-next-line @nx/enforce-module-boundaries
4+
import { reporter } from '../../playwright.config';
5+
6+
const nxConf = nxE2EPreset(__filename);
7+
export default defineConfig({
8+
...nxConf,
9+
reporter,
10+
testDir: './src',
11+
use: {
12+
trace: 'on-first-retry',
13+
},
14+
projects: [
15+
{
16+
name: 'chromium',
17+
use: { ...devices['Desktop Chrome'] },
18+
},
19+
],
20+
});

apps/e2e-03/project.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
3+
"name": "e2e-03",
4+
"projectType": "application",
5+
"sourceRoot": "apps/e2e-03/src",
6+
"targets": {
7+
"or8n": {
8+
"executor": "nx:run-commands",
9+
"options": {
10+
"config": "apps/e2e-03/playwright.config.ts",
11+
"commands": [
12+
{
13+
"command": "npx pwc-p"
14+
}
15+
]
16+
}
17+
}
18+
}
19+
}

apps/e2e-03/src/e2e-03-1.spec.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
test('e2e-03-1', async () => {
4+
expect(1).toBe(1);
5+
});

apps/e2e-03/src/e2e-03-2.spec.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
test('e2e-03-2', async () => {
4+
expect(1).toBe(1);
5+
});

apps/e2e-03/src/e2e-03.spec.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
test('e2e-03', async () => {
4+
expect(1).toBe(1);
5+
});

apps/e2e-03/tsconfig.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"allowJs": true,
5+
"outDir": "../../dist/out-tsc",
6+
"module": "commonjs",
7+
"sourceMap": false
8+
},
9+
"include": [
10+
"**/*.ts",
11+
"**/*.js",
12+
"playwright.config.ts",
13+
"src/**/*.spec.ts",
14+
"src/**/*.spec.js",
15+
"src/**/*.test.ts",
16+
"src/**/*.test.js",
17+
"src/**/*.d.ts"
18+
]
19+
}

0 commit comments

Comments
 (0)