Skip to content

Commit

Permalink
Merge d92bf46 into 7e6c29d
Browse files Browse the repository at this point in the history
  • Loading branch information
BioPhoton authored Nov 9, 2024
2 parents 7e6c29d + d92bf46 commit c18270c
Show file tree
Hide file tree
Showing 13 changed files with 131 additions and 126 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:
- name: E2E test affected projects
run: npx nx affected -t nxv-e2e --exclude cli-e2e --parallel=1
- name: E2E test cli-e2e project (due to bugs in the setup it has to run last :( )
run: npx nx run cli-e2e:e2e-old
run: npx nx run cli-e2e:nxv-e2e

build:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ node_modules
/connect.lock
/coverage
/examples/react-todos-app/coverage
/examples/react-todos-app/package.json
/examples/react-todos-app/package-lock.json
/libpeerconnection.log
npm-debug.log
yarn-error.log
Expand Down
13 changes: 8 additions & 5 deletions e2e/cli-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@
"lintFilePatterns": ["e2e/cli-e2e/**/*.ts"]
}
},
"e2e-old": {
"nxv-env-setup": {
"options": {
"environmentRoot": "examples/react-todos-app"
}
},
"e2e": {
"executor": "@nx/vite:test",
"options": {
"configFile": "e2e/cli-e2e/vite.config.e2e.ts"
"configFile": "e2e/cli-e2e/vite.config.e2e.ts",
"environmentRoot": "examples/react-todos-app"
}
}
},
"implicitDependencies": [
"models",
"utils",
"core",
"cli",
"plugin-eslint",
"plugin-coverage",
Expand Down
35 changes: 26 additions & 9 deletions e2e/cli-e2e/tests/collect.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ describe('CLI collect', () => {

it('should run ESLint plugin and create report.json', async () => {
const { code, stderr } = await executeProcess({
command: 'code-pushup',
args: ['collect', '--no-progress', '--onlyPlugins=eslint'],
command: 'npx',
args: [
'@code-pushup/cli',
'collect',
'--no-progress',
'--onlyPlugins=eslint',
],
cwd: 'examples/react-todos-app',
});

Expand Down Expand Up @@ -83,14 +88,16 @@ describe('CLI collect', () => {
);

const { code, stderr } = await executeProcess({
command: 'code-pushup',
command: 'npx',
args: [
'@code-pushup/cli',
'collect',
'--no-progress',
`--config=${configPath}`,
'--persist.outputDir=tmp/e2e',
'--onlyPlugins=coverage',
],
cwd: 'examples/react-todos-app',
});

expect(code).toBe(0);
Expand All @@ -104,8 +111,13 @@ describe('CLI collect', () => {

it('should run Code coverage plugin that runs coverage tool and creates report.json', async () => {
const { code, stderr } = await executeProcess({
command: 'code-pushup',
args: ['collect', '--no-progress', '--onlyPlugins=coverage'],
command: 'npx',
args: [
'@code-pushup/cli',
'collect',
'--no-progress',
'--onlyPlugins=coverage',
],
cwd: 'examples/react-todos-app',
});

Expand All @@ -120,8 +132,13 @@ describe('CLI collect', () => {

it('should create report.md', async () => {
const { code, stderr } = await executeProcess({
command: 'code-pushup',
args: ['collect', '--persist.format=md', '--no-progress'],
command: 'npx',
args: [
'@code-pushup/cli',
'collect',
'--persist.format=md',
'--no-progress',
],
cwd: 'examples/react-todos-app',
});

Expand All @@ -137,8 +154,8 @@ describe('CLI collect', () => {

it('should print report summary to stdout', async () => {
const { code, stdout, stderr } = await executeProcess({
command: 'code-pushup',
args: ['collect', '--no-progress'],
command: 'npx',
args: ['@code-pushup/cli', 'collect', '--no-progress'],
cwd: 'examples/react-todos-app',
});

Expand Down
9 changes: 6 additions & 3 deletions e2e/cli-e2e/tests/compare.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ describe('CLI compare', () => {
}
await cleanTestFolder('tmp/e2e/react-todos-app');
await executeProcess({
command: 'code-pushup',
command: 'npx',
args: [
'@code-pushup/cli',
'collect',
'--persist.filename=source-report',
'--onlyPlugins=eslint',
Expand All @@ -28,8 +29,9 @@ describe('CLI compare', () => {
cwd: 'examples/react-todos-app',
});
await executeProcess({
command: 'code-pushup',
command: 'npx',
args: [
'@code-pushup/cli',
'collect',
'--persist.filename=target-report',
'--onlyPlugins=eslint',
Expand All @@ -45,8 +47,9 @@ describe('CLI compare', () => {

it('should compare report.json files and create report-diff.json and report-diff.md', async () => {
await executeProcess({
command: 'code-pushup',
command: 'npx',
args: [
'@code-pushup/cli',
'compare',
'--before=../../tmp/e2e/react-todos-app/source-report.json',
'--after=../../tmp/e2e/react-todos-app/target-report.json',
Expand Down
15 changes: 9 additions & 6 deletions e2e/cli-e2e/tests/help.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { executeProcess } from '@code-pushup/utils';
describe('CLI help', () => {
it('should print help with help command', async () => {
const { code, stdout, stderr } = await executeProcess({
command: 'code-pushup',
args: ['help'],
command: 'npx',
args: ['@code-pushup/cli', 'help'],
cwd: 'examples/react-todos-app',
});
expect(code).toBe(0);
expect(stderr).toBe('');
Expand All @@ -14,12 +15,14 @@ describe('CLI help', () => {

it('should produce the same output to stdout for both help argument and help command', async () => {
const helpArgResult = await executeProcess({
command: 'code-pushup',
args: ['help'],
command: 'npx',
args: ['@code-pushup/cli', 'help'],
cwd: 'examples/react-todos-app',
});
const helpCommandResult = await executeProcess({
command: 'code-pushup',
args: ['--help'],
command: 'npx',
args: ['@code-pushup/cli', '--help'],
cwd: 'examples/react-todos-app',
});
expect(helpArgResult.code).toBe(0);
expect(helpCommandResult.code).toBe(0);
Expand Down
22 changes: 9 additions & 13 deletions e2e/cli-e2e/tests/print-config.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,45 @@ const extensions = ['js', 'mjs', 'ts'] as const;
export const configFilePath = (ext: (typeof extensions)[number]) =>
join(process.cwd(), `e2e/cli-e2e/mocks/fixtures/code-pushup.config.${ext}`);

describe('print-config', () => {
describe('CLI print-config', () => {
it.each(extensions)(
'should load .%s config file with correct arguments',
async ext => {
const { code, stdout } = await executeProcess({
command: 'code-pushup',
command: 'npx',
args: [
'@code-pushup/cli',
'print-config',
'--no-progress',
`--config=${configFilePath(ext)}`,
'--tsconfig=tsconfig.base.json',
'--persist.outputDir=output-dir',
'--persist.format=md',
`--persist.filename=${ext}-report`,
'--onlyPlugins=coverage',
],
cwd: 'examples/react-todos-app',
});

expect(code).toBe(0);

expect(JSON.parse(stdout)).toEqual(
expect.objectContaining({
config: expect.stringContaining(`code-pushup.config.${ext}`),
tsconfig: 'tsconfig.base.json',
// filled by command options
persist: {
outputDir: 'output-dir',
filename: `${ext}-report`,
format: ['md'],
},
upload: {
organization: 'code-pushup',
project: `cli-${ext}`,
apiKey: 'e2e-api-key',
server: 'https://e2e.com/api',
},
plugins: [
plugins: expect.arrayContaining([
expect.objectContaining({
slug: 'coverage',
title: 'Code coverage',
}),
],
categories: [expect.objectContaining({ slug: 'code-coverage' })],
]),
categories: expect.arrayContaining([
expect.objectContaining({ slug: 'code-coverage' }),
]),
onlyPlugins: ['coverage'],
}),
);
Expand Down
1 change: 0 additions & 1 deletion e2e/cli-e2e/vite.config.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export default defineConfig({
},
environment: 'node',
include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
globalSetup: ['../../global-setup.e2e.ts'],
setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'],
},
});
69 changes: 0 additions & 69 deletions examples/react-todos-app/.eslintrc.js

This file was deleted.

64 changes: 64 additions & 0 deletions examples/react-todos-app/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"root": true,
"env": {
"browser": true,
"es2021": true
},
"plugins": ["react", "react-hooks"],
"overrides": [
{
"env": {
"node": true
},
"files": [".eslintrc.{js,cjs}"],
"parserOptions": {
"sourceType": "script"
}
}
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"settings": {
"react": {
"version": "detect"
}
},
"rules": {
"no-cond-assign": "warn",
"no-const-assign": "warn",
"no-debugger": "warn",
"no-invalid-regexp": "warn",
"no-undef": "warn",
"no-unreachable-loop": "warn",
"no-unsafe-negation": "warn",
"no-unsafe-optional-chaining": "warn",
"no-unused-vars": "warn",
"use-isnan": "warn",
"valid-typeof": "warn",
"arrow-body-style": "warn",
"camelcase": "warn",
"curly": "warn",
"eqeqeq": "warn",
"max-lines-per-function": "warn",
"max-lines": "warn",
"no-shadow": "warn",
"no-var": "warn",
"object-shorthand": "warn",
"prefer-arrow-callback": "warn",
"prefer-const": "warn",
"prefer-object-spread": "warn",
"yoda": "warn",
"react/jsx-key": "warn",
"react/prop-types": "warn",
"react/react-in-jsx-scope": "warn",
"react/jsx-uses-vars": "warn",
"react/jsx-uses-react": "error",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn"
}
}
Loading

0 comments on commit c18270c

Please sign in to comment.