Skip to content

Commit

Permalink
Merge branch 'master' into next-component-testing-compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
erenken authored Nov 2, 2023
2 parents adf5ae0 + b0d1799 commit 17b3e01
Showing 86 changed files with 1,678 additions and 776 deletions.
5 changes: 0 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -161,11 +161,6 @@ jobs:
command: |
pnpm nx affected -t e2e-macos --parallel=1 --base=$NX_BASE --head=$NX_HEAD
no_output_timeout: 45m
- run:
name: Close CI group
command: |
pnpm nx-cloud stop-all-agents
no_output_timeout: 45m

# -------------------------
# WORKFLOWS(JOBS)
6 changes: 6 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -234,6 +234,12 @@ jobs:
git checkout -b publish/$GITHUB_REF_NAME
npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN
pnpm nx-release --local=false $GITHUB_REF_NAME
- name: Trigger Docs Release
if: ${{ !github.event.release.prerelease }}
run: |
# We force recreate the branch in order to always be up to date and avoid merge conflicts within the automated workflow
git branch -f website
git push -f origin website
env:
GH_TOKEN: ${{ github.token }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
12 changes: 6 additions & 6 deletions docs/generated/packages/angular/generators/federate-module.json
Original file line number Diff line number Diff line change
@@ -15,19 +15,19 @@
],
"type": "object",
"properties": {
"path": {
"type": "string",
"$default": { "$source": "argv", "index": 0 },
"description": "The path to locate the federated module.",
"x-prompt": "What is the path to the module to be federated?"
},
"name": {
"description": "The name of the module.",
"type": "string",
"$default": { "$source": "argv", "index": 0 },
"x-prompt": "What name would you like to use for the module?",
"pattern": "^[a-zA-Z][^:]*$",
"x-priority": "important"
},
"path": {
"type": "string",
"description": "The path to locate the federated module.",
"x-prompt": "What is the path to the module to be federated?"
},
"remote": {
"type": "string",
"description": "The name of the remote.",
12 changes: 6 additions & 6 deletions docs/generated/packages/react/generators/federate-module.json
Original file line number Diff line number Diff line change
@@ -15,19 +15,19 @@
],
"type": "object",
"properties": {
"path": {
"type": "string",
"$default": { "$source": "argv", "index": 0 },
"description": "The path to locate the federated module. This path should be relative to the workspace root and the file should exist.",
"x-prompt": "What is the path to the module to be federated?"
},
"name": {
"description": "The name of the module.",
"type": "string",
"$default": { "$source": "argv", "index": 0 },
"x-prompt": "What name would you like to use for the module?",
"pattern": "^[a-zA-Z][^:]*$",
"x-priority": "important"
},
"path": {
"type": "string",
"description": "The path to locate the federated module. This path should be relative to the workspace root and the file should exist.",
"x-prompt": "What is the path to the module to be federated?"
},
"remote": {
"type": "string",
"description": "The name of the remote.",
2 changes: 1 addition & 1 deletion docs/generated/packages/vue/generators/application.json
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@
},
"unitTestRunner": {
"type": "string",
"enum": ["jest", "vitest", "none"],
"enum": ["vitest", "none"],
"description": "Test runner to use for unit tests.",
"x-prompt": "Which unit test runner would you like to use?",
"default": "vitest"
6 changes: 0 additions & 6 deletions docs/generated/packages/vue/generators/component.json
Original file line number Diff line number Diff line change
@@ -100,12 +100,6 @@
"type": "boolean",
"default": false,
"x-priority": "internal"
},
"unitTestRunner": {
"type": "string",
"enum": ["vitest", "jest", "none"],
"description": "Test runner to use for unit tests.",
"x-prompt": "What unit test runner should be used?"
}
},
"required": ["name"],
2 changes: 1 addition & 1 deletion docs/generated/packages/vue/generators/library.json
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@
},
"unitTestRunner": {
"type": "string",
"enum": ["vitest", "jest", "none"],
"enum": ["vitest", "none"],
"description": "Test runner to use for unit tests.",
"x-prompt": "What unit test runner should be used?"
},
20 changes: 8 additions & 12 deletions docs/shared/monorepo-ci-circle-ci.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# Configuring CI Using CircleCI and Nx

The `CircleCI` can track the last successful run on the `main` branch and use this as a reference point for the `BASE`. The `Nx Orb` provides a convenient implementation of this functionality which you can drop into your existing CI config.
To understand why knowing the last successful build is important for the affected command, check out the [in-depth explanation in Orb's docs](https://github.com/nrwl/nx-orb#background).

Below is an example of a Circle CI setup for an Nx workspace - building and testing only what is affected. For more details on how the orb is used, head over to the [official docs](https://circleci.com/developer/orbs/orb/nrwl/nx).
Below is an example of a Circle CI setup for an Nx workspace - building and testing only what is affected. For more details on how the Nx orb is used, head over to the [official docs](https://circleci.com/developer/orbs/orb/nrwl/nx).

```yaml
```yaml {% fileName=".circleci/config.yml" %}
version: 2.1
orbs:
nx: nrwl/nx@1.5.1
@@ -19,18 +16,17 @@ jobs:
- nx/set-shas

- run: npx nx format:check
- run: npx nx affected --base=$NX_BASE --head=$NX_HEAD -t lint --parallel=3
- run: npx nx affected --base=$NX_BASE --head=$NX_HEAD -t test --parallel=3 --configuration=ci
- run: npx nx affected --base=$NX_BASE --head=$NX_HEAD -t build --parallel=3
- run: npx nx affected --base=$NX_BASE --head=$NX_HEAD -t lint,test,build --parallel=3 --configuration=ci
workflows:
build:
jobs:
- main
```
The `pr` and `main` jobs implement the CI workflow.
`CircleCI` can track the last successful run on the `main` branch and use this as a reference point for the `BASE`. The `Nx Orb` provides a convenient implementation of this functionality which you can drop into your existing CI config.
To understand why knowing the last successful build is important for the affected command, check out the [in-depth explanation in Orb's docs](https://github.com/nrwl/nx-orb#background).

### Using CircleCI on the private repository
### Using CircleCI in a private repository

To use the [Nx Orb](https://github.com/nrwl/nx-orb) with a private repository on your main branch, you need to grant the orb access to your CircleCI API. You can do this by creating an environment variable called `CIRCLE_API_TOKEN` in the context or the project.

@@ -42,7 +38,7 @@ It should be a user token, not the project token.

Read more about [Distributed Task Execution (DTE)](/core-features/distribute-task-execution).

```yaml
```yaml {% fileName=".circleci/config.yml" %}
version: 2.1
orbs:
nx: nrwl/nx@1.5.1
@@ -69,7 +65,7 @@ jobs:
- run: npx nx-cloud start-ci-run --stop-agents-after="build"
- run: npx nx-cloud record -- npx nx format:check
- run: npx nx affected --base=$NX_BASE --head=$NX_HEAD -t lint --parallel=3 & npx nx affected --base=$NX_BASE --head=$NX_HEAD -t test --parallel=3 --configuration=ci & npx nx affected --base=$NX_BASE --head=$NX_HEAD -t build --parallel=3
- run: npx nx affected --base=$NX_BASE --head=$NX_HEAD -t lint,test,build --parallel=3 --configuration=ci
workflows:
build:
jobs:
70 changes: 29 additions & 41 deletions docs/shared/monorepo-ci-github-actions.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# Configuring CI Using GitHub Actions and Nx

`GitHub` can track the last successful run on the `main` branch and use this as a reference point for the `BASE`. The `Nx Set SHAs` provides a convenient implementation of this functionality which you can drop into your existing CI config.
To understand why knowing the last successful build is important for the affected command, check out the [in-depth explanation in Actions's docs](https://github.com/marketplace/actions/nx-set-shas#background).

Below is an example of a GitHub setup for an Nx workspace - building and testing only what is affected. For more details on how the action is used, head over to the [official docs](https://github.com/marketplace/actions/nx-set-shas).

```yaml
```yaml {% fileName=".github/workflows/ci.yml" %}
name: CI
on:
push:
@@ -17,31 +14,29 @@ jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: nrwl/nx-set-shas@v3
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
- run: npm ci
- uses: nrwl/nx-set-shas@v3
- run: git branch --track main origin/main

- run: npx nx format:check
- run: npx nx affected -t lint --parallel=3
- run: npx nx affected -t test --parallel=3
- run: npx nx affected -t build --parallel=3
- run: npx nx affected -t lint,test,build --parallel=3
```
The `pr` and `main` jobs implement the CI workflow. Setting `timeout-minutes` is needed only if you have very slow tasks.

{% callout type="note" title="Tracking the origin branch" %}

If you're using this action in the context of a branch you may need to add `run: "git branch --track main origin/main"` before running the `nx affected` command since `origin/main` won't exist.

{% /callout %}
`GitHub` can track the last successful run on the `main` branch and use this as a reference point for the `BASE`. The `Nx Set SHAs` provides a convenient implementation of this functionality which you can drop into your existing CI config.
To understand why knowing the last successful build is important for the affected command, check out the [in-depth explanation in Actions's docs](https://github.com/marketplace/actions/nx-set-shas#background).

## Distributed Task Execution with Nx Cloud

Read more about [Distributed Task Execution (DTE)](/core-features/distribute-task-execution).
Read more about [Distributed Task Execution (DTE)](/core-features/distribute-task-execution). Use this [reusable GitHub workflow](https://github.com/nrwl/ci) to quickly set up DTE for your organization.

```yaml
```yaml {% fileName=".github/workflows/ci.yml" %}
name: CI
on:
push:
@@ -58,7 +53,7 @@ jobs:
parallel-commands: |
npx nx-cloud record -- npx nx format:check
parallel-commands-on-agents: |
npx nx affected -t lint --parallel=3 & npx nx affected -t test --parallel=3 --configuration=ci & npx nx affected -t build --parallel=3
npx nx affected -t lint,test,build --parallel=3
agents:
name: Nx Cloud - Agents
@@ -73,9 +68,9 @@ You can also use our [ci-workflow generator](/nx-api/workspace/generators/ci-wor

Our [reusable GitHub workflow](https://github.com/nrwl/ci) represents a good set of defaults that works for a large number of our users. However, reusable GitHub workflows come with their [limitations](https://docs.github.com/en/actions/using-workflows/reusing-workflows).

If the existing workflow doesn't satisfy your needs you should create your custom workflow. This is what the above config roughly encapsulates:
If the reusable workflow above doesn't satisfy your needs you should create a custom workflow. This is what the GitHub workflow above roughly encapsulates:

```yaml
```yaml {% fileName=".github/workflows/ci.yml" %}
name: CI
on:
push:
@@ -95,7 +90,7 @@ jobs:
name: Nx Cloud - Main Job
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
name: Checkout [Pull Request]
if: ${{ github.event_name == 'pull_request' }}
with:
@@ -104,7 +99,7 @@ jobs:
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0
- uses: actions/checkout@v3
- uses: actions/checkout@v4
name: Checkout [Default Branch]
if: ${{ github.event_name != 'pull_request' }}
with:
@@ -117,16 +112,17 @@ jobs:
package-json-path: '${{ github.workspace }}/package.json'
- name: Use the package manager cache if available
uses: actions/cache@v3
uses: actions/setup-node@v3
with:
path: ~/.npm
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-
node-version: 20
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Check out the default branch
run: git branch --track main origin/main
- name: Initialize the Nx Cloud distributed CI run
run: npx nx-cloud start-ci-run
@@ -137,13 +133,7 @@ jobs:
NX_CLOUD_DISTRIBUTED_EXECUTION=false npx nx-cloud record -- npx nx format:check & pids+=($!)
# list of commands to be run on agents
npx nx affected -t lint --parallel=3 &
pids+=($!)
npx nx affected -t test --parallel=3 &
pids+=($!)
npx nx affected -t build --parallel=3 &
npx nx affected -t lint,test,build --parallel=3 &
pids+=($!)
# run all commands in parallel and bail if one of them fails
@@ -168,20 +158,18 @@ jobs:
agent: [1, 2, 3]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
# Set node/npm/yarn versions using volta
- uses: volta-cli/action@v4
with:
package-json-path: '${{ github.workspace }}/package.json'
- name: Use the package manager cache if available
uses: actions/cache@v3
uses: actions/setup-node@v3
with:
path: ~/.npm
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-
node-version: 20
cache: 'npm'
- name: Install dependencies
run: npm ci
4 changes: 2 additions & 2 deletions docs/shared/recipes/module-federation/federate-a-module.md
Original file line number Diff line number Diff line change
@@ -46,14 +46,14 @@ Now that we have created the module, we need to configure it to be federated.
{%tab label="React"%}

```shell
nx generate @nx/react:federate-module Hello --remote=greeting --path=hello/src/index.ts --projectNameAndRootFormat=as-provided
nx generate @nx/react:federate-module hello/src/index.ts --name=hello --remote=greeting --projectNameAndRootFormat=as-provided
```

{% /tab %}
{%tab label="Angular"%}

```shell
nx generate @nx/angular:federate-module Hello --remote=greeting --path=hello/src/index.ts --projectNameAndRootFormat=as-provided
nx generate @nx/angular:federate-module hello/src/index.ts --name=hello --remote=greeting --projectNameAndRootFormat=as-provided
```

{% /tab %}
4 changes: 2 additions & 2 deletions e2e/angular-core/src/module-federation.test.ts
Original file line number Diff line number Diff line change
@@ -326,7 +326,7 @@ describe('Angular Module Federation', () => {

// Federate Module
runCLI(
`generate @nx/angular:federate-module ${module} --remote=${remote} --path=${lib}/src/index.ts --no-interactive`
`generate @nx/angular:federate-module ${lib}/src/index.ts --name=${module} --remote=${remote} --no-interactive`
);

updateFile(`${lib}/src/index.ts`, `export { isEven } from './lib/${lib}';`);
@@ -403,7 +403,7 @@ describe('Angular Module Federation', () => {

// Federate Module
runCLI(
`generate @nx/angular:federate-module ${module} --remote=${childRemote} --path=${lib}/src/index.ts --no-interactive`
`generate @nx/angular:federate-module ${lib}/src/index.ts --name=${module} --remote=${childRemote} --no-interactive`
);

updateFile(`${lib}/src/index.ts`, `export { isEven } from './lib/${lib}';`);
11 changes: 2 additions & 9 deletions e2e/eslint/src/linter.test.ts
Original file line number Diff line number Diff line change
@@ -17,13 +17,6 @@ import {
} from '@nx/e2e/utils';
import * as ts from 'typescript';

/**
* Importing this helper from @typescript-eslint/type-utils to ensure
* compatibility with TS < 4.8 due to the API change in TS4.8.
* This helper allows for support of TS <= 4.8.
*/
import { getModifiers } from '@typescript-eslint/type-utils';

describe('Linter', () => {
describe('Integrated', () => {
const myapp = uniq('myapp');
@@ -494,7 +487,7 @@ describe('Linter', () => {
`libs/${mylib}/src/lib/${mylib}.ts`,
(content) =>
`import { names } from '@nx/devkit';\n\n` +
content.replace(/return .*;/, `return names(${mylib}).className;`)
content.replace(/=> .*;/, `=> names(${mylib}).className;`)
);

// output should now report missing dependency
@@ -847,7 +840,7 @@ function updateGeneratedRuleImplementation(
) {
return ts.factory.updateMethodDeclaration(
node,
getModifiers(node),
node.modifiers,
node.asteriskToken,
node.name,
node.questionToken,
Loading

0 comments on commit 17b3e01

Please sign in to comment.