Skip to content
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# for uploading to portal
# Example environment variables
# These are for reference only - use .env.local for local development

# For uploading to Code PushUp portal
CP_API_KEY=

# Note: For local development with tsx/TypeScript execution,
# copy .env.local.example to .env.local and configure NODE_OPTIONS there
12 changes: 12 additions & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Local development environment variables
# Copy this to .env.local (gitignored) and customize for your setup

# Enable tsx for TypeScript execution in Nx
# This allows running local generator/executor directly as .ts files without pre-compilation
# This allowes the local plugins to import files with .js extensions (same as the packages in the repository)
NODE_OPTIONS=--import tsx
# This is used to resolve the paths in the local generator/executor so local packages can be imported as path aliases
TSX_TSCONFIG_PATH=tsconfig.base.json

# Local API keys (optional - only if testing upload features)
# CP_API_KEY=your_api_key_here
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Install dependencies
run: npm ci
- name: Check formatting of affected files
run: npx nx format:check
run: npm run ci:nx -- format:check

lint:
runs-on: ubuntu-latest
Expand All @@ -49,7 +49,7 @@ jobs:
- name: Install dependencies
run: npm ci
- name: Lint affected projects
run: npx nx affected -t lint --parallel=3
run: npm run ci:nx -- affected -t lint --parallel=3

unit-test:
strategy:
Expand All @@ -73,7 +73,7 @@ jobs:
- name: Install dependencies
run: npm ci
- name: Unit test affected projects
run: npx nx affected -t unit-test --parallel=3
run: npm run ci:nx -- affected -t unit-test --parallel=3

integration-test:
strategy:
Expand All @@ -97,7 +97,7 @@ jobs:
- name: Install dependencies
run: npm ci
- name: Integration test affected projects
run: npx nx affected -t int-test --parallel=3
run: npm run ci:nx -- affected -t int-test --parallel=3

e2e:
strategy:
Expand All @@ -121,7 +121,7 @@ jobs:
- name: Install dependencies
run: npm ci
- name: E2E test affected projects
run: npx nx affected -t e2e-test --parallel=1
run: npm run ci:nx -- affected -t e2e-test --parallel=1

build:
runs-on: ubuntu-latest
Expand All @@ -141,6 +141,6 @@ jobs:
- name: Install dependencies
run: npm ci
- name: Build all projects # affected is not used to be able to test-releae packages
run: npx nx run-many --target=build --parallel=3
run: npm run ci:nx -- run-many --target=build --parallel=3
- name: Test-release packages
run: npx pkg-pr-new publish "packages/**/dist"
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: List packages using Nx CLI
id: list-packages
run: |
matrix=$(node tools/scripts/create-codecov-matrix.js)
matrix=$(npm run ci:node -- tools/scripts/create-codecov-matrix.js)
echo "matrix=$matrix" >> $GITHUB_OUTPUT
outputs:
matrix: ${{ steps.list-packages.outputs.matrix }}
Expand All @@ -48,7 +48,7 @@ jobs:
- name: Install dependencies
run: npm ci
- name: Execute tests with coverage
run: npx nx run ${{ matrix.project }}:${{ matrix.target }}
run: npm run ci:nx -- run ${{ matrix.project }}:${{ matrix.target }}
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ jobs:
- name: Install dependencies
run: npm ci
- name: Publish packages to npm
run: npx nx release publish
run: npm run ci:nx -- release publish
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ jobs:
- name: Install dependencies
run: npm ci
- name: Version, release and generate changelog
run: npx nx release --skip-publish
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: npm run ci:nx -- release --skip-publish
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

.env
.env.local
.npmrc

# compiled output
Expand Down
1 change: 0 additions & 1 deletion examples/plugins/src/package-json/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ You can configure the plugin with the following options:
1. If you haven't already, install [@code-pushup/cli](../cli/README.md) and create a configuration file.

2. Copy the [plugin source](../package-json) as is into your project

1. Add this plugin to the `plugins` array in your Code PushUp CLI config file (e.g. `code-pushup.config.js`).

Pass in the path or the directory to crawl (relative to `process.cwd()`).
Expand Down
26 changes: 26 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"scripts": {
"prepare": "husky install",
"commit": "git-cz",
"knip": "knip"
"knip": "knip",
"ci:nx": "node tools/scripts/ci-tsx.js nx",
"ci:node": "node tools/scripts/ci-tsx.js node"
},
"private": true,
"dependencies": {
Expand Down Expand Up @@ -86,6 +88,7 @@
"chromium": "^3.0.3",
"commitizen": "^4.3.1",
"commitlint-plugin-tense": "^1.0.3",
"cross-env": "^10.1.0",
"dotenv": "^16.4.5",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-functional": "^7.1.0",
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-eslint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ Detected ESLint rules are mapped to Code PushUp audits. Audit reports are calcul
```

If you're using an Nx monorepo, additional helper functions are provided to simplify your configuration:

- If you wish to combine all projects in your workspace into one report, use the `eslintConfigFromAllNxProjects` helper:

```js
Expand Down
48 changes: 48 additions & 0 deletions tools/scripts/ci-tsx.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// @ts-check
import { spawn } from 'node:child_process';
import { resolve } from 'node:path';

// Determine the workspace root (GITHUB_WORKSPACE or current working directory)
const workspaceRoot = process.env.GITHUB_WORKSPACE || process.cwd();
const tsconfigPath = resolve(workspaceRoot, 'tsconfig.base.json');

// Set up environment variables
const env = {
...process.env,
NODE_OPTIONS: '--import tsx',
TSX_TSCONFIG_PATH: tsconfigPath,
};

// Get the command and its arguments from the command line
const [command, ...args] = process.argv.slice(2);

if (!command) {
console.error('Usage: node ci-tsx.js <command> [args...]');
console.error('Example: node ci-tsx.js nx affected -t test');
process.exit(1);
}

// Log the command being executed
console.log(`> ${command} ${args.join(' ')}`);

// Spawn the command with the configured environment
const child = spawn(command, args, {
env,
stdio: 'inherit',
shell: true,
});

// Forward exit code
child.on('exit', (code, signal) => {
if (signal) {
process.kill(process.pid, signal);
} else {
process.exit(code ?? 0);
}
});

// Handle errors
child.on('error', error => {
console.error('Failed to start child process:', error);
process.exit(1);
});
Loading