Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parallel input #109

Merged
merged 1 commit into from
Dec 20, 2024
Merged
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
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ The action may be customized using the following optional inputs:
| Name | Description | Default |
| :----------------- | :-------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------- |
| `monorepo` | Enables [monorepo mode](#monorepo-mode) | `false` |
| `parallel` | Configured parallel execution in [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}` |
Expand All @@ -68,7 +69,6 @@ The action may be customized using the following optional inputs:
| `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` |
Expand Down Expand Up @@ -153,17 +153,6 @@ can override the name using the optional `task` input:
task: analyze # custom Nx target
```

For caching purposes, you may prefer to separate output directories per project.
The `output` input supports interpolating the project name in the path using
`{project}` syntax:

```yml
- uses: code-pushup/github-action@v0
with:
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
Expand All @@ -179,3 +168,26 @@ be run:
nxProjectsFilter:
'--with-target=code-pushup --affected --projects=apps/* exclude=*-e2e'
```

### Parallel tasks

By default, tasks are run sequentially for each project in the monorepo. The
`parallel` input enables parallel execution for tools which support it (Nx,
Turborepo, PNPM, Yarn 2+).

```yml
- uses: code-pushup/github-action@v0
with:
monorepo: true
parallel: true
```

The maximum number of concurrent tasks can be set by passing in a number instead
of a boolean:

```yml
- uses: code-pushup/github-action@v0
with:
monorepo: true
parallel: 3
```
4 changes: 2 additions & 2 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('code-pushup action', () => {
process.env['INPUT_TOKEN'] = '<mock-github-token>'
process.env['INPUT_BIN'] = 'npx code-pushup'
process.env['INPUT_DIRECTORY'] = workDir
process.env['INPUT_OUTPUT'] = '.code-pushup'
process.env['INPUT_PARALLEL'] = 'false'
process.env['INPUT_RETENTION'] = '14'
process.env['INPUT_TASK'] = 'code-pushup'
process.env['INPUT_SILENT'] = 'true'
Expand Down Expand Up @@ -148,7 +148,7 @@ describe('code-pushup action', () => {
expect.stringContaining('report.json'),
expect.stringContaining('report.md')
]),
expect.stringContaining('.code-pushup'),
process.cwd(),
{ retentionDays: 14 }
)

Expand Down
14 changes: 9 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ inputs:
- `pnpm`: PNPM workspaces
required: true
default: false
parallel:
description: |
Configures parallel execution in monorepo mode. Possibly values are:

- `false`: sequential (default)
- `true`: parallel with default number of jobs (depends on monorepo tool)
- integer which sets the number of concurrent jobs
required: true
default: false
projects:
description: |
Project folders for custom monorepo setup.
Expand Down Expand Up @@ -48,11 +57,6 @@ inputs:
directory:
description: Custom working directory
required: false
output:
description:
Custom report output directory (use '{project}'-syntax in monorepo mode)
required: false
default: .code-pushup
silent:
description: Silence logs from Code Pushup CLI
required: true
Expand Down
Loading
Loading