Skip to content

Commit

Permalink
Merge branch 'master' into feat/add-bun-packagemanager
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan-Hall authored Sep 11, 2023
2 parents 75bab7f + 2283937 commit 6b7fa77
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 106 deletions.
131 changes: 104 additions & 27 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,91 @@ commands:
- ~/.pnpm-store
- ~/.cache/Cypress
- node_modules

setup:
parameters:
os:
type: string
steps:
- checkout
- when:
condition:
equal: [<< parameters.os >>, macos]
steps:
- restore_cache:
name: Restore Homebrew packages
keys:
- nrwl-nx-homebrew-packages
- run:
name: Configure Detox Environment, Install applesimutils
command: |
HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew install applesimutils >/dev/null
xcrun simctl shutdown all && xcrun simctl erase all
no_output_timeout: 20m
- save_cache:
name: Save Homebrew Cache
key: nrwl-nx-homebrew-packages
paths:
- /usr/local/Homebrew
- ~/Library/Caches/Homebrew
- when:
condition:
equal: [<< parameters.os >>, linux]
steps:
- run:
command: |
sudo apt-get update
sudo apt-get install -y ca-certificates lsof
- browser-tools/install-chrome
- browser-tools/install-chromedriver
- run-pnpm-install:
os: << parameters.os >>

# -------------------------
# JOBS
# -------------------------
jobs:
# -------------------------
# JOBS: Agent
# -------------------------
agent:
parameters:
os:
type: string
default: 'linux'
pm:
type: string
default: 'pnpm'
executor: << parameters.os >>
environment:
GIT_AUTHOR_EMAIL: [email protected]
GIT_AUTHOR_NAME: Test
GIT_COMMITTER_EMAIL: [email protected]
GIT_COMMITTER_NAME: Test
NX_E2E_CI_CACHE_KEY: e2e-circleci-<< parameters.os >>
SELECTED_PM: << parameters.pm >>
NX_E2E_RUN_E2E: 'true'
NX_VERBOSE_LOGGING: 'false'
NX_NATIVE_LOGGING: 'false'
NX_PERF_LOGGING: 'false'
steps:
- run:
name: Configure git metadata (needed for lerna smoke tests)
command: |
git config --global user.email [email protected]
git config --global user.name "Test Test"
- run:
name: Set dynamic nx run variable
command: |
echo "export NX_CI_EXECUTION_ENV=\"<< parameters.os >>\";" >> $BASH_ENV
- setup:
os: << parameters.os >>
- run:
name: Agent
command: pnpm nx-cloud start-agent
no_output_timeout: 60m

# -------------------------
# JOBS: Main Linux
# -------------------------
Expand All @@ -84,21 +165,16 @@ jobs:
NX_DAEMON: 'true'
NX_PERF_LOGGING: 'false'
NX_NATIVE_LOGGING: 'false'
NX_E2E_RUN_E2E: 'true'
NX_CI_EXECUTION_ENV: 'linux'
steps:
- checkout
- run: npx nx-cloud@next start-ci-run --stop-agents-after="e2e"
- run:
name: Set dynamic nx run variable
command: |
sudo apt-get update
sudo apt-get install -y ca-certificates lsof
- browser-tools/install-chrome
- browser-tools/install-chromedriver
- run-pnpm-install:
echo "export NX_CI_EXECUTION_ENV=\"linux\";" >> $BASH_ENV
- setup:
os: linux
- nx/set-shas:
main-branch-name: 'master'
- run: pnpm nx-cloud start-ci-run --stop-agents-after="e2e"
- run:
name: Check Documentation
command: pnpm nx documentation --no-dte
Expand Down Expand Up @@ -134,28 +210,13 @@ jobs:
environment:
NX_E2E_CI_CACHE_KEY: e2e-circleci-macos
NX_PERF_LOGGING: 'false'
NX_CI_EXECUTION_ENV: 'macos'
SELECTED_PM: 'npm' # explicitly define npm for macOS tests
steps:
- checkout
- restore_cache:
name: Restore Homebrew packages
keys:
- nrwl-nx-homebrew-packages
- run:
name: Configure Detox Environment, Install applesimutils
name: Set dynamic nx run variable
command: |
HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew install applesimutils >/dev/null
xcrun simctl shutdown all && xcrun simctl erase all
no_output_timeout: 20m
- save_cache:
name: Save Homebrew Cache
key: nrwl-nx-homebrew-packages
paths:
- /usr/local/Homebrew
- ~/Library/Caches/Homebrew
- run-pnpm-install:
echo "export NX_CI_EXECUTION_ENV=\"macos\";" >> $BASH_ENV
- setup:
os: macos
- rust/install
- nx/set-shas:
Expand All @@ -174,6 +235,22 @@ workflows:

build:
jobs:
- agent:
name: 'agent1'
- agent:
name: 'agent2'
- agent:
name: 'agent3'
- agent:
name: 'agent4'
- agent:
name: 'agent5'
- agent:
name: 'agent6'
- agent:
name: 'agent7'
- agent:
name: 'agent8'
- main-linux
- mainmacos:
name: main-macos-e2e
13 changes: 1 addition & 12 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,8 @@ CHANGELOG.md
# Local dev files
.env
.bashrc
.nx

*.node

# Fix for issue when working on the repo in a dev container
.pnpm-store
.nx/cache

.cargo/.package-cache
.cargo/bin/
.cargo/env
.cargo/registry/
.local/
.npm/
.profile
.rustup/
.pnpm-store
58 changes: 0 additions & 58 deletions .nx/workflows/agents.yaml

This file was deleted.

24 changes: 24 additions & 0 deletions docs/generated/devkit/parseTargetString.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,27 @@ parseTargetString('proj:test:production', graph); // returns { project: "proj",
#### Returns

[`Target`](../../devkit/documents/Target)

**parseTargetString**(`targetString`, `ctx`): [`Target`](../../devkit/documents/Target)

Parses a target string into {project, target, configuration}. Passing a full
[ExecutorContext](../../devkit/documents/ExecutorContext) enables the targetString to reference the current project.

Examples:

```typescript
parseTargetString('test', executorContext); // returns { project: "proj", target: "test" }
parseTargetString('proj:test', executorContext); // returns { project: "proj", target: "test" }
parseTargetString('proj:test:production', executorContext); // returns { project: "proj", target: "test", configuration: "production" }
```

#### Parameters

| Name | Type |
| :------------- | :---------------------------------------------------------- |
| `targetString` | `string` |
| `ctx` | [`ExecutorContext`](../../devkit/documents/ExecutorContext) |

#### Returns

[`Target`](../../devkit/documents/Target)
2 changes: 1 addition & 1 deletion e2e/esbuild/src/esbuild.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('EsBuild Plugin', () => {

afterEach(() => cleanupProject());

xit('should setup and build projects using build', async () => {
it('should setup and build projects using build', async () => {
const myPkg = uniq('my-pkg');
runCLI(`generate @nx/js:lib ${myPkg} --bundler=esbuild`);
updateFile(`libs/${myPkg}/src/index.ts`, `console.log('Hello');\n`);
Expand Down
6 changes: 3 additions & 3 deletions e2e/nx-misc/src/watch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function writeFileForWatcher(path: string, content: string) {
await wait(10);
}

xdescribe('Nx Commands', () => {
describe('Nx Commands', () => {
let proj1 = uniq('proj1');
let proj2 = uniq('proj2');
let proj3 = uniq('proj3');
Expand All @@ -33,7 +33,7 @@ xdescribe('Nx Commands', () => {

afterAll(() => cleanupProject());

xit('should watch for project changes', async () => {
it('should watch for project changes', async () => {
const getOutput = await runWatch(
`--projects=${proj1} -- echo \\$NX_PROJECT_NAME`
);
Expand All @@ -46,7 +46,7 @@ xdescribe('Nx Commands', () => {
expect(await getOutput()).toEqual([proj1]);
});

xit('should watch for all projects and output the project name', async () => {
it('should watch for all projects and output the project name', async () => {
const getOutput = await runWatch(`--all -- echo \\$NX_PROJECT_NAME`);
await writeFileForWatcher(`libs/${proj1}/newfile.txt`, 'content');
await writeFileForWatcher(`libs/${proj2}/newfile.txt`, 'content');
Expand Down
3 changes: 1 addition & 2 deletions e2e/utils/get-env-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ export function ensureCypressInstallation() {
}

export function ensurePlaywrightBrowsersInstallation() {
const playwrightInstallArgs = process.env.PLAYWRIGHT_INSTALL_ARGS || '';
execSync(`npx playwright install ${playwrightInstallArgs}`, {
execSync('npx playwright install --with-deps --force', {
stdio: isVerbose() ? 'inherit' : 'pipe',
encoding: 'utf-8',
cwd: tmpProjPath(),
Expand Down
41 changes: 41 additions & 0 deletions packages/devkit/src/executors/parse-target-string.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { parseTargetString, targetToTargetString } from './parse-target-string';

import * as splitTarget from 'nx/src/utils/split-target';
import { ExecutorContext } from 'nx/src/devkit-exports';

const cases = [
{ input: 'one:two', expected: { project: 'one', target: 'two' } },
Expand All @@ -15,12 +16,52 @@ const cases = [
];

describe('parseTargetString', () => {
const mockContext: ExecutorContext = {
projectName: 'my-project',
cwd: '/virtual',
root: '/virtual',
isVerbose: false,
projectGraph: {
nodes: {
'my-project': {
type: 'lib',
name: 'my-project',
data: { root: '/packages/my-project' },
},
'other-project': {
type: 'lib',
name: 'other-project',
data: { root: '/packages/other-project' },
},
},
dependencies: {},
externalNodes: {},
version: '',
},
};

it.each(cases)('$input -> $expected', ({ input, expected }) => {
jest
.spyOn(splitTarget, 'splitTarget')
.mockReturnValueOnce(Object.values(expected) as [string]);
expect(parseTargetString(input, null)).toEqual(expected);
});

it('should support reading project from ExecutorContext', () => {
expect(parseTargetString('build', mockContext)).toEqual({
project: 'my-project',
target: 'build',
});
expect(parseTargetString('build:production', mockContext)).toEqual({
project: 'my-project',
target: 'build',
configuration: 'production',
});
expect(parseTargetString('other-project:build', mockContext)).toEqual({
project: 'other-project',
target: 'build',
});
});
});

describe('targetToTargetString', () => {
Expand Down
Loading

0 comments on commit 6b7fa77

Please sign in to comment.