Skip to content

Commit

Permalink
refactor(nxext): ci setup
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikPieper committed Jun 24, 2024
1 parent b6e8e8b commit a9a8ae7
Show file tree
Hide file tree
Showing 61 changed files with 265 additions and 483 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
- main
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true

jobs:
main:
name: Nx Cloud - Main Job
Expand All @@ -17,6 +21,7 @@ jobs:
pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
parallel-commands: |
pnpm exec nx-cloud record -- pnpm exec nx format:check
pnpm exec nx affected --target=e2e
parallel-commands-on-agents: |
pnpm exec nx affected --target=lint --parallel=3
pnpm exec nx affected --target=test --parallel=3 --ci --code-coverage
Expand Down
3 changes: 3 additions & 0 deletions e2e/e2e-utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# e2e-utils

This library was generated with [Nx](https://nx.dev).
17 changes: 17 additions & 0 deletions e2e/e2e-utils/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const baseConfig = require('../../eslint.config.js');

module.exports = [
...baseConfig,
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
rules: {},
},
{
files: ['**/*.ts', '**/*.tsx'],
rules: {},
},
{
files: ['**/*.js', '**/*.jsx'],
rules: {},
},
];
12 changes: 12 additions & 0 deletions e2e/e2e-utils/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "e2e-utils",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "e2e/e2e-utils/src",
"projectType": "library",
"tags": [],
"targets": {
"lint": {
"executor": "@nx/eslint:lint"
}
}
}
4 changes: 2 additions & 2 deletions e2e/utils/index.ts → e2e/e2e-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { join, dirname } from 'path';
import { mkdirSync, rmSync } from 'fs';
import { execSync } from 'child_process';

export { runNxCommandUntil } from './run-commands-until';
export { runNxCommandUntil } from './lib/run-commands-until';

/**
* Creates a test project with create-nx-workspace and installs the plugin
Expand All @@ -22,7 +22,7 @@ export function createTestProject() {
});

execSync(
`npx --yes create-nx-workspace@latest ${projectName} --preset apps --nxCloud skip --interactive false`,
`npx --yes create-nx-workspace@latest ${projectName} --preset apps --nxCloud=skip --no-interactive`,
{
cwd: dirname(projectDirectory),
stdio: 'inherit',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function runNxCommandUntil(
criteria: (output: string) => boolean
): Promise<ChildProcess> {
const pm = getPackageManagerCommand();
const p = exec(pm.run('nx', command), {
const childProcess: ChildProcess = exec(pm.run('nx', command), {
cwd: tmpProjPath(),
env: {
...process.env,
Expand All @@ -19,21 +19,21 @@ export function runNxCommandUntil(
let output = '';
let complete = false;

function checkCriteria(c) {
function checkCriteria(c: any) {
output += c.toString();
if (criteria(stripConsoleColors(output)) && !complete) {
complete = true;
res(p);
res(childProcess);
}
}

p.stdout.on('data', checkCriteria);
p.stderr.on('data', checkCriteria);
p.on('exit', (code) => {
childProcess.stdout?.on('data', checkCriteria);
childProcess.stderr?.on('data', checkCriteria);
childProcess.on('exit', (code) => {
if (!complete) {
rej(`Exited with ${code}`);
} else {
res(p);
res(childProcess);
}
});
});
Expand Down
19 changes: 19 additions & 0 deletions e2e/e2e-utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
}
]
}
10 changes: 10 additions & 0 deletions e2e/e2e-utils/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"include": ["src/**/*.ts"],
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"]
}
3 changes: 1 addition & 2 deletions e2e/preact-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"dependsOn": ["^build"]
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
"executor": "@nx/eslint:lint"
}
},
"tags": [],
Expand Down
18 changes: 13 additions & 5 deletions e2e/preact-e2e/tests/preact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,19 @@ describe('preact e2e', () => {
});

it('should generate app into directory', async () => {
await runNxCommandAsync(`generate @nxext/preact:app project/ui`);
await runNxCommandAsync(
`generate @nxext/preact:app ui --directory apps/project`
);
expect(() =>
checkFilesExist(`apps/project/ui/src/App.tsx`)
).not.toThrow();
});

it('should be able to run linter', async () => {
const plugin = uniq('preactlint');
await runNxCommandAsync(`generate @nxext/preact:app ${plugin}`);
await runNxCommandAsync(
`generate @nxext/preact:app ${plugin} --directory apps`
);

const result = await runNxCommandAsync(`lint ${plugin}`);
expect(result.stdout).toContain('All files pass linting');
Expand All @@ -47,21 +51,25 @@ describe('preact e2e', () => {

describe('preact lib', () => {
it('should generate lib into directory', async () => {
await runNxCommandAsync(`generate @nxext/preact:lib project/uilib`);
await runNxCommandAsync(
`generate @nxext/preact:lib uilib --directory libs/project`
);
expect(() =>
checkFilesExist(`libs/project/uilib/src/index.ts`)
).not.toThrow();
});

it('should be able to run linter', async () => {
const plugin = uniq('preactliblint');
await runNxCommandAsync(`generate @nxext/preact:lib ${plugin}`);
await runNxCommandAsync(
`generate @nxext/preact:lib ${plugin} --directory libs`
);

const result = await runNxCommandAsync(`lint ${plugin}`);
expect(result.stdout).toContain('All files pass linting');
});

it('should be able build lib if buildable', async () => {
xit('should be able build lib if buildable', async () => {
const plugin = uniq('preactlib');
await runNxCommandAsync(
`generate @nxext/preact:lib ${plugin} --buildable`
Expand Down
10 changes: 5 additions & 5 deletions e2e/solid-e2e/tests/solid.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('solid e2e', () => {
it('should build solid application', async () => {
const plugin = uniq('solid');
await runNxCommandAsync(
`generate @nxext/solid:app ${plugin} --e2eTestRunner='none' --junitTestRunner='none'`
`generate @nxext/solid:app ${plugin} --directory=apps --e2eTestRunner='none' --junitTestRunner='none'`
);

const result = await runNxCommandAsync(`build ${plugin}`);
Expand All @@ -34,7 +34,7 @@ describe('solid e2e', () => {
it('should be able to run linter', async () => {
const plugin = uniq('solidlint');
await runNxCommandAsync(
`generate @nxext/solid:app ${plugin} --e2eTestRunner='none' --junitTestRunner='none'`
`generate @nxext/solid:app ${plugin} --directory=apps --e2eTestRunner='none' --junitTestRunner='none'`
);

const result = await runNxCommandAsync(`lint ${plugin}`);
Expand All @@ -45,7 +45,7 @@ describe('solid e2e', () => {
describe('solid lib', () => {
it('should generate lib into directory', async () => {
await runNxCommandAsync(
`generate @nxext/solid:lib project/uilib --e2eTestRunner='none' --junitTestRunner='none'`
`generate @nxext/solid:lib uilib --directory=libs/project --e2eTestRunner='none' --junitTestRunner='none'`
);
expect(() =>
checkFilesExist(`libs/project/uilib/src/index.ts`)
Expand All @@ -55,7 +55,7 @@ describe('solid e2e', () => {
it('should be able to run linter', async () => {
const plugin = uniq('solidliblint');
await runNxCommandAsync(
`generate @nxext/solid:lib ${plugin} --e2eTestRunner='none' --junitTestRunner='none'`
`generate @nxext/solid:lib ${plugin} --directory=libs --e2eTestRunner='none' --junitTestRunner='none'`
);

const result = await runNxCommandAsync(`lint ${plugin}`);
Expand All @@ -65,7 +65,7 @@ describe('solid e2e', () => {
it('should be able build lib if buildable', async () => {
const plugin = uniq('solidlib');
await runNxCommandAsync(
`generate @nxext/solid:lib ${plugin} --buildable --e2eTestRunner='none' --junitTestRunner='none'`
`generate @nxext/solid:lib ${plugin} --directory=libs --buildable --e2eTestRunner='none' --junitTestRunner='none'`
);

const result = await runNxCommandAsync(`build ${plugin}`);
Expand Down
18 changes: 9 additions & 9 deletions e2e/svelte-e2e/tests/application.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('svelte e2e', () => {
it('should build svelte application', async () => {
const plugin = uniq('svelte');
await runNxCommandAsync(
`generate @nxext/svelte:app ${plugin} --e2eTestRunner='none' --unitTestRunner='none'`
`generate @nxext/svelte:app ${plugin} --directory=apps --e2eTestRunner='none' --unitTestRunner='none'`
);

const result = await runNxCommandAsync(`build ${plugin}`);
Expand All @@ -44,15 +44,15 @@ describe('svelte e2e', () => {
it('should add tags to project', async () => {
const plugin = uniq('sveltetags');
await runNxCommandAsync(
`generate @nxext/svelte:app ${plugin} --tags e2etag,e2ePackage --e2eTestRunner='none' --unitTestRunner='none'`
`generate @nxext/svelte:app ${plugin} --directory=apps --tags e2etag,e2ePackage --e2eTestRunner='none' --unitTestRunner='none'`
);
const project = readJson(`apps/${plugin}/project.json`);
expect(project.tags).toEqual(['e2etag', 'e2ePackage']);
});

it('should generate app into directory', async () => {
await runNxCommandAsync(
`generate @nxext/svelte:app project/ui --e2eTestRunner='none' --unitTestRunner='none'`
`generate @nxext/svelte:app ui --directory=apps/project --e2eTestRunner='none' --unitTestRunner='none'`
);
expect(() =>
checkFilesExist(`apps/project/ui/src/main.ts`)
Expand All @@ -62,7 +62,7 @@ describe('svelte e2e', () => {
it('should be able to run linter', async () => {
const plugin = uniq('sveltelint');
await runNxCommandAsync(
`generate @nxext/svelte:app ${plugin} --e2eTestRunner='none' --unitTestRunner='none'`
`generate @nxext/svelte:app ${plugin} --directory=apps --e2eTestRunner='none' --unitTestRunner='none'`
);

const result = await runNxCommandAsync(`lint ${plugin}`);
Expand All @@ -72,7 +72,7 @@ describe('svelte e2e', () => {
it('should be able to run check', async () => {
const plugin = uniq('svelteappcheck');
await runNxCommandAsync(
`generate @nxext/svelte:app ${plugin} --e2eTestRunner='none' --unitTestRunner='none'`
`generate @nxext/svelte:app ${plugin} --directory=apps --e2eTestRunner='none' --unitTestRunner='none'`
);

const result = await runNxCommandAsync(`check ${plugin}`);
Expand All @@ -85,7 +85,7 @@ describe('svelte e2e', () => {
it('with jest', async () => {
const plugin = uniq('svelteapptests');
await runNxCommandAsync(
`generate @nxext/svelte:app ${plugin} --unitTestRunner='jest' --e2eTestRunner='none'`
`generate @nxext/svelte:app ${plugin} --directory=apps --unitTestRunner='jest' --e2eTestRunner='none'`
);
await runNxCommandAsync(
`generate @nxext/svelte:component test --project=${plugin}`
Expand All @@ -100,7 +100,7 @@ describe('svelte e2e', () => {
it('with vitest', async () => {
const plugin = uniq('svelteapptests');
await runNxCommandAsync(
`generate @nxext/svelte:app ${plugin} --unitTestRunner='vitest' --e2eTestRunner='none'`
`generate @nxext/svelte:app ${plugin} --directory=apps --unitTestRunner='vitest' --e2eTestRunner='none'`
);
await runNxCommandAsync(
`generate @nxext/svelte:component test --project=${plugin}`
Expand All @@ -118,11 +118,11 @@ describe('svelte e2e', () => {
it('should build svelte application with dependencies', async () => {
const appName = 'svelteappwithdeps';
await runNxCommandAsync(
`generate @nxext/svelte:app ${appName} --e2eTestRunner='none' --unitTestRunner='none'`
`generate @nxext/svelte:app ${appName} --directory=apps --e2eTestRunner='none' --unitTestRunner='none'`
);
const libName = uniq('sveltelib');
await runNxCommandAsync(
`generate @nxext/svelte:lib ${libName} --e2eTestRunner='none' --unitTestRunner='none'`
`generate @nxext/svelte:lib ${libName} --directory=libs --e2eTestRunner='none' --unitTestRunner='none'`
);
await runNxCommandAsync(
`generate @nxext/svelte:c testcomp --project=${libName}`
Expand Down
12 changes: 6 additions & 6 deletions e2e/svelte-e2e/tests/library.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('svelte e2e', () => {
it('should be able to run linter', async () => {
const plugin = uniq('svelteliblint');
await runNxCommandAsync(
`generate @nxext/svelte:lib ${plugin} --e2eTestRunner='none' --junitTestRunner='none'`
`generate @nxext/svelte:lib ${plugin} --directory=libs --e2eTestRunner='none' --junitTestRunner='none'`
);

const result = await runNxCommandAsync(`lint ${plugin}`);
Expand All @@ -33,7 +33,7 @@ describe('svelte e2e', () => {
it('should be able to run check', async () => {
const plugin = uniq('sveltelibcheck');
await runNxCommandAsync(
`generate @nxext/svelte:lib ${plugin} --e2eTestRunner='none' --junitTestRunner='none'`
`generate @nxext/svelte:lib ${plugin} --directory=libs --e2eTestRunner='none' --junitTestRunner='none'`
);

const result = await runNxCommandAsync(`check ${plugin}`);
Expand All @@ -45,7 +45,7 @@ describe('svelte e2e', () => {
it('should be able build lib if buildable', async () => {
const plugin = uniq('sveltelib');
await runNxCommandAsync(
`generate @nxext/svelte:lib ${plugin} --buildable --e2eTestRunner='none' --junitTestRunner='none'`
`generate @nxext/svelte:lib ${plugin} --directory=libs --buildable --e2eTestRunner='none' --junitTestRunner='none'`
);

const result = await runNxCommandAsync(`build ${plugin}`);
Expand All @@ -58,7 +58,7 @@ describe('svelte e2e', () => {
it('with jest', async () => {
const plugin = uniq('jest');
await runNxCommandAsync(
`generate @nxext/svelte:lib ${plugin} --unitTestRunner=jest --e2eTestRunner='none'`
`generate @nxext/svelte:lib ${plugin} --directory=libs --unitTestRunner=jest --e2eTestRunner='none'`
);
await runNxCommandAsync(
`generate @nxext/svelte:component test --project=${plugin}`
Expand All @@ -73,7 +73,7 @@ describe('svelte e2e', () => {
it('with vitest', async () => {
const plugin = uniq('vitest');
await runNxCommandAsync(
`generate @nxext/svelte:lib ${plugin} --unitTestRunner=vitest --e2eTestRunner='none'`
`generate @nxext/svelte:lib ${plugin} --directory=libs --unitTestRunner=vitest --e2eTestRunner='none'`
);
await runNxCommandAsync(
`generate @nxext/svelte:component test --project=${plugin}`
Expand All @@ -89,7 +89,7 @@ describe('svelte e2e', () => {
it('should be able to run storybook', async () => {
const plugin = uniq('sveltestories');
await runNxCommandAsync(
`generate @nxext/svelte:lib ${plugin} --unitTestRunner='none' --e2eTestRunner='none'`
`generate @nxext/svelte:lib ${plugin} --directory=libs --unitTestRunner='none' --e2eTestRunner='none'`
);
await runNxCommandAsync(
`generate @nxext/svelte:storybook-configuration ${plugin}`
Expand Down
21 changes: 0 additions & 21 deletions e2e/vue-e2e/eslint.config.js

This file was deleted.

Loading

0 comments on commit a9a8ae7

Please sign in to comment.