Skip to content

Commit

Permalink
Add nxProjectsFilter option
Browse files Browse the repository at this point in the history
  • Loading branch information
matejchalk committed Nov 29, 2024
1 parent b365227 commit 5a7a2a6
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 75 deletions.
45 changes: 31 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,21 @@ jobs:
The action may be customized using the following optional inputs:
| Name | Description | Default |
| :------------ | :-------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------- |
| `monorepo` | Enables [monorepo mode](#monorepo-mode) | `false` |
| `projects` | Custom projects configuration for [monorepo mode](#monorepo-mode) | none |
| `task` | Name of command to run Code PushUp per project in [monorepo mode](#monorepo-mode) | `code-pushup` |
| `token` | GitHub token for authorizing GitHub API requests | `${{ github.token }}` |
| `annotations` | Toggles if annotations should be created for relevant Code PushUp issues | `true` |
| `artifacts` | Toggles if artifacts will we uploaded/downloaded | `true` |
| `retention` | Artifact retention period in days | from repository settings |
| `directory` | Directory in which `code-pushup` should run | `process.cwd()` |
| `output` | Directory where reports will be created | `.code-pushup` |
| `config` | Path to config file (`--config` option) | see [`@code-pushup/cli` docs](https://github.com/code-pushup/cli/tree/main/packages/cli#configuration) |
| `silent` | Toggles if logs from Code PushUp CLI are printed | `false` |
| `bin` | Command for executing Code PushUp CLI | `npx --no-install code-pushup` |
| Name | Description | Default |
| :----------------- | :-------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------- |
| `monorepo` | Enables [monorepo mode](#monorepo-mode) | `false` |
| `projects` | Custom projects configuration for [monorepo mode](#monorepo-mode) | none |
| `task` | Name of command to run Code PushUp per project in [monorepo mode](#monorepo-mode) | `code-pushup` |
| `nxProjectsFilter` | CLI arguments used to filter Nx projects in [monorepo mode](#monorepo-mode) | `--with-target={task}` |
| `token` | GitHub token for authorizing GitHub API requests | `${{ github.token }}` |
| `annotations` | Toggles if annotations should be created for relevant Code PushUp issues | `true` |
| `artifacts` | Toggles if artifacts will we uploaded/downloaded | `true` |
| `retention` | Artifact retention period in days | from repository settings |
| `directory` | Directory in which `code-pushup` should run | `process.cwd()` |
| `output` | Directory where reports will be created | `.code-pushup` |
| `config` | Path to config file (`--config` option) | see [`@code-pushup/cli` docs](https://github.com/code-pushup/cli/tree/main/packages/cli#configuration) |
| `silent` | Toggles if logs from Code PushUp CLI are printed | `false` |
| `bin` | Command for executing Code PushUp CLI | `npx --no-install code-pushup` |

For example, this will run `code-pushup` commands in a non-root folder and
retain report artifacts for 30 days:
Expand Down Expand Up @@ -162,3 +163,19 @@ The `output` input supports interpolating the project name in the path using
monorepo: true
output: .code-pushup/{project}
```

In Nx monorepos, projects are listed using
`nx show projects --with-target=code-pushup` by default. The `nxProjectsFilter`
input sets the CLI arguments forwarded to
[`nx show projects`](https://nx.dev/nx-api/nx/documents/show#projects) (default
is `--with-target={task}`, with `{task}` being replaced by the `task` input
value). This gives a lot of flexibility in customizing which Nx projects should
be run:

```yml
- uses: code-pushup/github-action@v0
with:
monorepo: nx
nxProjectsFilter:
'--with-target=code-pushup --affected --projects=apps/* exclude=*-e2e'
```
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ inputs:
Dependending on what monorepo tool is being used, this task may represent a `package.json` script, binary executable, Nx target or Turbo task.
required: true
default: code-pushup
nxProjectsFilter:
description: |
CLI arguments for `nx show projects` used to list Nx projects in monorepo mode. Replaces `{task}` with `task` input.
required: true
default: --with-target={task}
bin:
description: Custom code-pushup executable
required: true
Expand Down
30 changes: 22 additions & 8 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

90 changes: 45 additions & 45 deletions package-lock.json

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

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@
"@actions/core": "^1.11.1",
"@actions/exec": "^1.1.1",
"@actions/github": "^6.0.0",
"@code-pushup/ci": "^0.55.0",
"@code-pushup/models": "^0.55.0",
"@code-pushup/utils": "^0.55.0",
"@code-pushup/ci": "^0.56.0",
"@code-pushup/models": "^0.56.0",
"@code-pushup/utils": "^0.56.0",
"better-enums": "^0.2.2",
"fast-glob": "^3.3.2",
"simple-git": "^3.27.0",
"yaml": "^2.6.1"
},
"devDependencies": {
"@code-pushup/cli": "^0.55.0",
"@code-pushup/coverage-plugin": "^0.55.0",
"@code-pushup/eslint-plugin": "^0.55.0",
"@code-pushup/js-packages-plugin": "^0.55.0",
"@code-pushup/cli": "^0.56.0",
"@code-pushup/coverage-plugin": "^0.56.0",
"@code-pushup/eslint-plugin": "^0.56.0",
"@code-pushup/js-packages-plugin": "^0.56.0",
"@code-pushup/portal-client": "^0.9.0",
"@types/jest": "^29.5.14",
"@types/node": "^22.9.3",
Expand Down
Loading

0 comments on commit 5a7a2a6

Please sign in to comment.