Skip to content

Commit

Permalink
feat(misc): move ci options to configuration
Browse files Browse the repository at this point in the history
make test task depend less on jest specific options and use configuration instead to be more
inclusive

ISSUES CLOSED: #12045
  • Loading branch information
DaSchTour committed Jan 21, 2023
1 parent c6adec7 commit face364
Show file tree
Hide file tree
Showing 16 changed files with 85 additions and 13 deletions.
4 changes: 2 additions & 2 deletions docs/shared/monorepo-ci-azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- script: npx nx format:check

- script: npx nx affected --base=$(BASE_SHA) --target=lint --parallel=3
- script: npx nx affected --base=$(BASE_SHA) --target=test --parallel=3 --ci --code-coverage
- script: npx nx affected --base=$(BASE_SHA) --target=test --parallel=3 --configuration=ci
- script: npx nx affected --base=$(BASE_SHA) --target=build --parallel=3
```

Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:

- script: npx nx-cloud record -- npx nx workspace-lint
- script: npx nx-cloud record -- npx nx format:check --base=$(BASE_SHA) --head=$(HEAD_SHA)
- script: npx nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=lint --parallel=3 & npx nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=test --parallel=3 --ci --code-coverage & npx nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=build --parallel=3
- script: npx nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=lint --parallel=3 & npx nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=test --parallel=3 --configuration=ci & npx nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=build --parallel=3
```

You can also use our [ci-workflow generator](/packages/workspace/generators/ci-workflow) to generate the pipeline file.
Expand Down
4 changes: 2 additions & 2 deletions docs/shared/monorepo-ci-bitbucket-pipelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pipelines:
- npx nx workspace-lint
- npx nx format:check
- npx nx affected --target=lint --base=origin/master --parallel --max-parallel=3
- npx nx affected --target=test --base=origin/master --parallel --max-parallel=3 --ci --code-coverage
- npx nx affected --target=test --base=origin/master --parallel --max-parallel=3 --configuration=ci
- npx nx affected --target=build --base=origin/master --head=HEAD --parallel --max-parallel=3

branches:
Expand All @@ -29,7 +29,7 @@ pipelines:
- npm ci
- npx nx workspace-lint
- npx nx format:check
- npx nx affected --target=lint --base=origin/master --parallel --max-parallel=3 & npx nx affected --target=test --base=HEAD~1 --parallel --max-parallel=3 --ci --code-coverage & npx nx affected --target=build --base=HEAD~1 --parallel --max-parallel=3
- npx nx affected --target=lint --base=origin/master --parallel --max-parallel=3 & npx nx affected --target=test --base=HEAD~1 --parallel --max-parallel=3 --configuration=ci & npx nx affected --target=build --base=HEAD~1 --parallel --max-parallel=3
```

The `pull-requests` and `main` jobs implement the CI workflow.
4 changes: 2 additions & 2 deletions docs/shared/monorepo-ci-circle-ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- run: npx nx workspace-lint
- run: npx nx format:check
- run: npx nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3
- run: npx nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage
- run: npx nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --configuration=ci
- run: npx nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3
workflows:
build:
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:

- run: npx nx-cloud record -- npx nx workspace-lint
- run: npx nx-cloud record -- npx nx format:check
- run: npx nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3 & npx nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage & npx nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3
- run: npx nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3 & npx nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --configuration=ci & npx nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3
workflows:
build:
jobs:
Expand Down
4 changes: 2 additions & 2 deletions docs/shared/monorepo-ci-github-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- run: npx nx workspace-lint
- run: npx nx format:check
- run: npx nx affected --target=lint --parallel=3
- run: npx nx affected --target=test --parallel=3 --ci --code-coverage
- run: npx nx affected --target=test --parallel=3 --configuration=ci
- run: npx nx affected --target=build --parallel=3
```

Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
npx nx-cloud record -- npx nx workspace-lint
npx nx-cloud record -- npx nx format:check
parallel-commands-on-agents: |
npx nx affected --target=lint --parallel=3 & npx nx affected --target=test --parallel=3 --ci --code-coverage & npx nx affected --target=build --parallel=3
npx nx affected --target=lint --parallel=3 & npx nx affected --target=test --parallel=3 --configuration=ci & npx nx affected --target=build --parallel=3
agents:
name: Nx Cloud - Agents
Expand Down
4 changes: 2 additions & 2 deletions docs/shared/monorepo-ci-gitlab.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test:
stage: test
extends: .distributed
script:
- npx nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage
- npx nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --configuration=ci

build:
stage: build
Expand Down Expand Up @@ -120,7 +120,7 @@ nx-dte:
- yarn nx-cloud start-ci-run --stop-agents-after="build"
- yarn nx-cloud record -- yarn nx workspace-lint --base=$NX_BASE --head=$NX_HEAD
- yarn nx-cloud record -- yarn nx format:check --base=$NX_BASE --head=$NX_HEAD
- yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3 & yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage & yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=e2e --parallel=3 --ci --code-coverage & yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3
- yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3 & yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --configuration=ci & yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=e2e --parallel=3 & yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3

# Create as many agents as you want
nx-dte-agent1:
Expand Down
6 changes: 3 additions & 3 deletions docs/shared/monorepo-ci-jenkins.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pipeline {
sh "npx nx workspace-lint"
sh "npx nx format:check"
sh "npx nx affected --base origin/${env.CHANGE_TARGET} --target=lint --parallel=3"
sh "npx nx affected --base origin/${env.CHANGE_TARGET} --target=test --parallel=3 --ci --code-coverage"
sh "npx nx affected --base origin/${env.CHANGE_TARGET} --target=test --parallel=3 --configuration=ci"
sh "npx nx affected --base origin/${env.CHANGE_TARGET} --target=build --parallel=3"
}
}
Expand Down Expand Up @@ -78,7 +78,7 @@ pipeline {
sh "npx nx-cloud start-ci-run --stop-agents-after='build'"
sh "npx nx workspace-lint"
sh "npx nx format:check"
sh "npx nx affected --base=HEAD~1 --target=lint --parallel=3 & npx nx affected --base=HEAD~1 --target=test --parallel=3 --ci --code-coverage & npx nx affected --base=HEAD~1 --target=build --parallel=3"
sh "npx nx affected --base=HEAD~1 --target=lint --parallel=3 & npx nx affected --base=HEAD~1 --target=test --parallel=3 --configuration=ci & npx nx affected --base=HEAD~1 --target=build --parallel=3"
}
}
stage('PR') {
Expand All @@ -91,7 +91,7 @@ pipeline {
sh "npx nx-cloud start-ci-run --stop-agents-after='build'"
sh "npx nx workspace-lint"
sh "npx nx format:check"
sh "npx nx affected --base origin/${env.CHANGE_TARGET} --target=lint --parallel=3 & npx nx affected --base origin/${env.CHANGE_TARGET} --target=test --parallel=3 --ci --code-coverage & npx nx affected --base origin/${env.CHANGE_TARGET} --target=build --parallel=3"
sh "npx nx affected --base origin/${env.CHANGE_TARGET} --target=lint --parallel=3 & npx nx affected --base origin/${env.CHANGE_TARGET} --target=test --parallel=3 --configuration=ci & npx nx affected --base origin/${env.CHANGE_TARGET} --target=build --parallel=3"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ Object {
},
"test": Object {
"builder": "@nrwl/jest:jest",
"configurations": Object {
"ci": Object {
"ci": true,
"codeCoverage": true,
},
},
"options": Object {
"jestConfig": "apps/my-dir/my-app/jest.config.ts",
"passWithNoTests": true,
Expand Down Expand Up @@ -380,6 +386,12 @@ Object {
},
"test": Object {
"builder": "@nrwl/jest:jest",
"configurations": Object {
"ci": Object {
"ci": true,
"codeCoverage": true,
},
},
"options": Object {
"jestConfig": "apps/my-app/jest.config.ts",
"passWithNoTests": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ Object {
},
"test": Object {
"builder": "@nrwl/jest:jest",
"configurations": Object {
"ci": Object {
"ci": true,
"codeCoverage": true,
},
},
"options": Object {
"jestConfig": "apps/my-dir/my-app/jest.config.ts",
"passWithNoTests": true,
Expand Down Expand Up @@ -388,6 +394,12 @@ Object {
},
"test": Object {
"builder": "@nrwl/jest:jest",
"configurations": Object {
"ci": Object {
"ci": true,
"codeCoverage": true,
},
},
"options": Object {
"jestConfig": "apps/my-app/jest.config.ts",
"passWithNoTests": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ export default {

exports[`jestProject should use jest.config.js in project config with --js flag 1`] = `
Object {
"configurations": Object {
"ci": Object {
"ci": true,
"codeCoverage": true,
},
},
"executor": "@nrwl/jest:jest",
"options": Object {
"jestConfig": "libs/lib1/jest.config.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ describe('jestProject', () => {
jestConfig: 'libs/lib1/jest.config.ts',
passWithNoTests: true,
},
configurations: {
ci: {
ci: true,
codeCoverage: true,
},
},
});
expect(lib1.targets.lint.options.tsConfig).toContain(
'libs/lib1/tsconfig.spec.json'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export function updateWorkspace(tree: Tree, options: JestProjectSchema) {
),
passWithNoTests: true,
},
configurations: {
ci: {
ci: true,
codeCoverage: true,
},
},
};

const isUsingTSLint =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ describe('@nrwl/linter:workspace-rules-project', () => {
"sourceRoot": "tools/eslint-rules",
"targets": Object {
"test": Object {
"configurations": Object {
"ci": Object {
"ci": true,
"codeCoverage": true,
},
},
"executor": "@nrwl/jest:jest",
"options": Object {
"jestConfig": "tools/eslint-rules/jest.config.ts",
Expand Down
6 changes: 6 additions & 0 deletions packages/nest/src/generators/library/library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ describe('lib', () => {
jestConfig: `libs/${libFileName}/jest.config.ts`,
passWithNoTests: true,
},
configurations: {
ci: {
ci: true,
codeCoverage: true,
},
},
});
});

Expand Down
6 changes: 6 additions & 0 deletions packages/node/src/generators/library/library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ describe('lib', () => {
jestConfig: 'libs/my-lib/jest.config.ts',
passWithNoTests: true,
},
configurations: {
ci: {
ci: true,
codeCoverage: true,
},
},
});
});

Expand Down
6 changes: 6 additions & 0 deletions packages/nx-plugin/src/generators/plugin/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ describe('NxPlugin Plugin Generator', () => {
jestConfig: 'libs/my-plugin/jest.config.ts',
passWithNoTests: true,
},
configurations: {
ci: {
ci: true,
codeCoverage: true,
},
},
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ Object {
},
},
"test": Object {
"configurations": Object {
"ci": Object {
"ci": true,
"codeCoverage": true,
},
},
"executor": "@nrwl/jest:jest",
"options": Object {
"jestConfig": "libs/test-ui-lib/jest.config.ts",
Expand Down

0 comments on commit face364

Please sign in to comment.