Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .cursor/rules/vitest.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ On this project, we distinguish three types of functional tests by scope - unit
## Integration tests
- Their scope refers to a bigger unit of code in isolation or an integration with a 3rd-party tool.
- Aim to test the output of the unit as a whole. When communicating with a 3rd-party tool, only tests its usage in CodePushup.
- These tests are also located **next to their production code counterpart** and have the `.integration.test.ts` suffix.
- Run integration tests for a given package via `npx nx run <package>:integration-test`
- Run all integration tests via `npx nx run-many -t integration-test`
- These tests are also located **next to their production code counterpart** and have the `.int.test.ts` suffix.
- Run integration tests for a given package via `npx nx run <package>:int-test`
- Run all integration tests via `npx nx run-many -t int-test`

# Automation

Expand Down
132 changes: 110 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,127 @@
name: CI
permissions:
contents: read

on:
push:
branches:
- main
branches: [main]
pull_request:
branches: [main]

permissions:
actions: read
contents: read
env:
NX_NON_NATIVE_HASHER: true

jobs:
main:
format:
runs-on: ubuntu-latest
name: Format check
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- name: Set base and head for Nx affected commands
uses: nrwl/nx-set-shas@v4
- name: Install dependencies
run: npm ci
- name: Check formatting of affected files
run: npx nx format:check

# This enables task distribution via Nx Cloud
# Run this command as early as possible, before dependencies are installed
# Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
# Uncomment this line to enable task distribution
# - run: npx nx-cloud start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="build"
unit-test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
name: Unit tests
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- name: Set base and head for Nx affected commands
uses: nrwl/nx-set-shas@v4
- name: Install dependencies
run: npm ci
- name: Unit test affected projects
run: npx nx affected -t unit-test --parallel=3

# Cache node_modules
- uses: actions/setup-node@v4
integration-test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
name: Integration tests
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
node-version: 20
cache: 'npm'
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- name: Set base and head for Nx affected commands
uses: nrwl/nx-set-shas@v4
- name: Install dependencies
run: npm ci
- name: Integration test affected projects
run: npx nx affected -t int-test --parallel=3

- run: npm ci --legacy-peer-deps
- uses: nrwl/nx-set-shas@v4
e2e:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
name: E2E tests
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- name: Set base and head for Nx affected commands
uses: nrwl/nx-set-shas@v4
- name: Install dependencies
run: npm ci
- name: E2E test affected projects
run: npx nx affected -t e2e-test --parallel=1 --exclude="**/dummy/**"

# Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud
# - run: npx nx-cloud record -- echo Hello World
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected
- run: npx nx affected -t lint test build
build:
runs-on: ubuntu-latest
name: Build
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- name: Set base and head for Nx affected commands
uses: nrwl/nx-set-shas@v4
- name: Install dependencies
run: npm ci
- name: Build all projects # affected is not used to be able to test-release packages
run: npx nx run-many --target=build --parallel=3
#- name: Test-release packages
# run: npx pkg-pr-new publish "packages/**/dist"
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24.1.0
6 changes: 5 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Add files here to ignore them from prettier formatting
/dist
**/docs/**/*.json
**/*.cpuprofile
**/fixtures/**/*.json
**/.prettierignore
/coverage
/.nx/cache
/.nx/workspace-data
/__snapshots__
**/__snapshots__
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

This package provides tools for Node.js CPU profiling. It allows users to collect and merge CPU profiles, and visualize them as Chrome trace files. Key features include smart defaults for easier profiling, intuitive error messages, the ability to merge multiple CPU profile files, and a TypeScript API for programmatic access. It offers CLI commands like `measure` to collect profiles and `merge` to combine them. It aims to simplify the usage of Node.js's built-in `--cpu-prof` capabilities and centralizes profile output.

### **⚠️ DEPRECATED** [@push-based/nx-perf](./packages/nx-perf/README.md)
### **⚠️ DEPRECATED** [@push-based/nx-perf](./packages/nx-perf/README.md)

This tool focuses on visualizingexisting performance marks specifically for Nx CLI commands. It aims to provide more detailed insights than the default Nx performance logging. It generates flame graphs viewable in Chrome DevTools, showing time spent in functions and call stacks, including those from child processes.

Expand Down
24 changes: 0 additions & 24 deletions dummy/app-0-e2e/jest.config.ts

This file was deleted.

2 changes: 0 additions & 2 deletions dummy/app-0-e2e/src/support/global-teardown.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable */

module.exports = async function () {
// Put clean up logic here (e.g. stopping services, docker-compose, etc.).
// Hint: `globalThis` is shared between setup and teardown.
Expand Down
1 change: 0 additions & 1 deletion dummy/app-0-e2e/src/support/test-setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
import axios from 'axios';

module.exports = async function () {
Expand Down
21 changes: 0 additions & 21 deletions dummy/app-0/jest.config.ts

This file was deleted.

8 changes: 4 additions & 4 deletions dummy/app-0/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"defaultConfiguration": "production",
"options": {
"platform": "node",
"outputPath": "packages/app-0/dist",
"outputPath": "dummy/app-0/dist",
"format": [
"cjs"
],
"bundle": false,
"main": "packages/app-0/src/main.ts",
"tsConfig": "packages/app-0/tsconfig.app.json",
"main": "dummy/app-0/src/main.ts",
"tsConfig": "dummy/app-0/tsconfig.app.json",
"assets": [
"packages/app-0/src/assets"
"dummy/app-0/src/assets"
],
"esbuildOptions": {
"sourcemap": true,
Expand Down
7 changes: 4 additions & 3 deletions dummy/app-1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
"options": {
"command": "webpack-cli build",
"args": [
"node-env=production"
]
"--node-env=production"
],
"cwd": "dummy/app-1"
},
"configurations": {
"development": {
"args": [
"node-env=development"
"--node-env=development"
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion dummy/app-1/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { NxAppWebpackPlugin } = require('@nx/webpack/app-plugin');
const { join } = require('path');
const { join } = require('node:path');

module.exports = {
output: {
Expand Down
21 changes: 0 additions & 21 deletions dummy/pkg-0/jest.config.ts

This file was deleted.

4 changes: 3 additions & 1 deletion dummy/pkg-0/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
"default": "./dist/index.js"
}
},
"dependencies": {}
"dependencies": {
"tslib": "^2.3.0"
}
}
2 changes: 1 addition & 1 deletion dummy/pkg-0/src/lib/pkg-0.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { pkg0 } from './pkg-0.js';

describe('pkg0', () => {
it('should work', () => {
expect(pkg0()).toEqual('pkg-0');
expect(pkg0()).toBe('pkg-0');
});
});
2 changes: 1 addition & 1 deletion dummy/pkg-0/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference types='vitest' />
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
import * as path from 'path';
import * as path from 'node:path';

export default defineConfig(() => ({
root: __dirname,
Expand Down
2 changes: 1 addition & 1 deletion dummy/pkg-1/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './lib/pkg-1';
export * from './lib/pkg-1.js';
4 changes: 2 additions & 2 deletions dummy/pkg-1/src/lib/pkg-1.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { pkg1 } from './pkg-1';
import { pkg1 } from './pkg-1.js';

describe('pkg1', () => {
it('should work', () => {
expect(pkg1()).toEqual('pkg-1');
expect(pkg1()).toBe('pkg-1');
});
});
21 changes: 0 additions & 21 deletions dummy/pkg-2/jest.config.ts

This file was deleted.

Loading
Loading