Skip to content

Commit 06c57ca

Browse files
[INFRAHELP-2529] feat: add exclude-commands (#73)
* Bump actions/checkout from 4 to 5 Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v4...v5) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Bump eslint from 9.26.0 to 9.34.0 Bumps [eslint](https://github.com/eslint/eslint) from 9.26.0 to 9.34.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](eslint/eslint@v9.26.0...v9.34.0) --- updated-dependencies: - dependency-name: eslint dependency-version: 9.34.0 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Bump jest from 29.7.0 to 30.1.3 Bumps [jest](https://github.com/jestjs/jest/tree/HEAD/packages/jest) from 29.7.0 to 30.1.3. - [Release notes](https://github.com/jestjs/jest/releases) - [Changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md) - [Commits](https://github.com/jestjs/jest/commits/v30.1.3/packages/jest) --- updated-dependencies: - dependency-name: jest dependency-version: 30.1.3 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Bump actions/setup-python from 5 to 6 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5 to 6. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](actions/setup-python@v5...v6) --- updated-dependencies: - dependency-name: actions/setup-python dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Bump actions/setup-node from 4.4.0 to 5.0.0 Bumps [actions/setup-node](https://github.com/actions/setup-node) from 4.4.0 to 5.0.0. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](actions/setup-node@v4.4.0...v5.0.0) --- updated-dependencies: - dependency-name: actions/setup-node dependency-version: 5.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * refactor: move from .eslintrc.json to eslint.config.cjs due to deprecation * chore: clean unused codepaths * feat: add determineSkips function * feat: add determineSkips tests * feat: incorporate determineSkips * feat: add tests for action-level skipCommands * feat: add exclude-commands input to action * chore: update readme --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent fc4c6a7 commit 06c57ca

17 files changed

Lines changed: 27526 additions & 5280 deletions

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/check-dist.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
runs-on: ubuntu-latest
2222

2323
steps:
24-
- uses: actions/checkout@v4
24+
- uses: actions/checkout@v5
2525

2626
- name: Setup Node.js
27-
uses: actions/setup-node@v4.4.0
27+
uses: actions/setup-node@v5.0.0
2828
with:
2929
node-version-file: package.json
3030
cache: npm

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
steps:
4040
- name: Checkout repository
41-
uses: actions/checkout@v4
41+
uses: actions/checkout@v5
4242

4343
# Initializes the CodeQL tools for scanning.
4444
- name: Initialize CodeQL

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ jobs:
1111
units:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v4
14+
- uses: actions/checkout@v5
1515
- run: npm ci
1616
- run: npm test
1717

1818
# test action works running from the graph
1919
test:
2020
runs-on: ubuntu-latest
2121
steps:
22-
- uses: actions/checkout@v4
22+
- uses: actions/checkout@v5
2323
- uses: ./
2424
id: discover
2525
with:
@@ -42,14 +42,14 @@ jobs:
4242

4343
steps:
4444
- name: Check out code
45-
uses: actions/checkout@v4
45+
uses: actions/checkout@v5
4646

4747
- name: Dump project object
4848
run: |
4949
echo '${{ toJson(matrix.project) }}'
5050
5151
- name: Setup Python
52-
uses: actions/setup-python@v5
52+
uses: actions/setup-python@v6
5353
with:
5454
python-version-file: ${{ matrix.project.path }}
5555

README.md

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,38 @@
11
# find-python-projects-action
2-
Github Action for dynamically discovering Python projects in a repository and making available some helpful values from `pyproject.toml`, including CI/CD commands like `test`, for each project it finds.
2+
GitHub Action for dynamically discovering Python projects in a repository and making available some helpful values from `pyproject.toml`, including CI/CD commands like `test`, for each project it finds.
33

44
Python projects are identified by the presence of `pyproject.toml`.
55
Various pieces of information about each project are parsed from `pyproject.toml` and returned in the action outputs as JSON strings, including shell commands for additional CI type operations like `test` and `package`.
6-
This is meant to faciliate downstream actions or workflows such as matrix builds for parallel builds of each project.
6+
This is meant to facilitate downstream actions or workflows such as matrix builds for parallel builds of each project.
77

88
This action aims to help you eliminate (or at least reduce) the amount of customization needed in your GHA workflows by pushing your project-specific stuff into `pyproject.toml`.
99

10-
1110
## Inputs
12-
- **root-dir**: Directory root for where to begin recursively searching for projects.
13-
Python projects contained in this directory or lower will be discovered. Defaults to your repository's root directory.
14-
15-
- **additional-export-paths**: Additional TOML keys to export as part of the projects object. Specify them as json path strings, separated by commas. For example, "tool.foo.bar,baz.qux".
1611

17-
## Outputs
18-
- **paths**: JSON array of found project path strings
12+
> `List` type is a newline-delimited string
13+
> ```yaml
14+
> exclude-commands: |
15+
> project=my-package-1,command=test
16+
> project=my-package-2,command=lint
17+
> ```
1918
20-
- **projects**: JSON array of all found projects ([project object](#project-object-output-shape))
19+
> `CSV` type is a comma-delimited string
20+
> ```yaml
21+
> additional-export-paths: tool.foo.bar,baz.qux
22+
> ```
2123
22-
- **projects-by-command**: JSON object with keys corresponding to the name of discovered commands
23-
(eg `install`, `test`, `package`, etc.) in all projects, with an array value containing each
24-
[project object](#project-object-output-shape) that implements the command.
24+
| Input | Type | Description |
25+
|---------------------------|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
26+
| `root-dir` | string | Directory root for where to begin recursively searching for projects. Python projects contained in this directory or lower will be discovered. Defaults to your repository's root directory. |
27+
| `additional-export-paths` | CSV | Additional TOML keys to export as part of the projects object. Specify them as JSON path strings, separated by commas. For example, `"tool.foo.bar,baz.qux"`. |
28+
| `exclude-commands` | string/List | Commands to exclude from processing during project discovery. Any plain string will be parsed as a command. For instance, passing "test" will cause the action to not export any information about "test" commands found in the repo. For project-specific overrides, pass a string of form `project=<name>,command=<name>`. For instance, a value of `project=one,command=lint` would cause the `lint` command to be excluded for a project named `one`, if such a project is discovered. Global and project-specific excludes can be freely mixed. |
2529
30+
## Outputs
31+
| Output | Type | Description |
32+
|-----------------------|-------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
33+
| `paths` | JSON array<string> | JSON array of found project path strings. |
34+
| `projects` | JSON array<project> | JSON array of all found projects (see [project object](#project-object-output-shape)). |
35+
| `projects-by-command` | JSON object<string, project[]> | JSON object with keys corresponding to the name of discovered commands (e.g., `install`, `test`, `package`, etc.) in all projects, with an array value containing each [project object](#project-object-output-shape) that implements the command. |
2636
2737
## Project object output shape
2838
These are the fields for `project` objects in the output:
@@ -42,12 +52,10 @@ This is dynamically constructed from the `pyproject.toml` content.
4252
4353
- **exports**: Object with keys specified by the `additional-export-paths` input, and the structured TOML data (parsed as JSON) as the values.
4454
45-
4655
## Project Commands
4756
In the absence of Python standards for expressing internal project CI/CD/Dev operations, this action tries to unify the various known ways in the wild.
4857
49-
This action will surface any command you specify in the pyproject.toml files. Typically you'll
50-
want to define one or more of the following for your CI/CD system::
58+
This action will surface any command you specify in the pyproject.toml files. Typically you'll want to define one or more of the following for your CI/CD system:
5159
5260
- `test`
5361
- `package`
@@ -61,7 +69,7 @@ This action will pull the command from the first entry it finds in any of the fo
6169
- `[tool.poe.tasks]`: [poethepoet](https://github.com/nat-n/poethepoet)
6270
6371
### The `install` command
64-
This action perfoms special treatment for surfacing the `install` command. Namely, if it is not explicitly specified, the action will attempt to generate a default based on the packaging backend (eg Poetry, PDM) that it discovers.
72+
This action performs special treatment for surfacing the `install` command. Namely, if it is not explicitly specified, the action will attempt to generate a default based on the packaging backend (eg Poetry, PDM) that it discovers.
6573
The intent is that you do not need to specify an `install` command in your pyproject.toml, but you can if necessary.
6674
6775
### Where is the support for `[tool.poetry.scripts]`?
@@ -71,15 +79,11 @@ can leverage a task runner tool like [Poe](https://github.com/nat-n/poethepoet)
7179
7280
*If Poetry ever adds support for internal project (CI/CD/Dev) commands separate from published commands, then it will be added to this action.*
7381
74-
7582
### Relevant References / Discussions
76-
https://discuss.python.org/t/a-new-pep-to-specify-dev-scripts-and-or-dev-scripts-providers-in-pyproject-toml/11457
77-
78-
https://discuss.python.org/t/proposal-for-tests-entry-point-in-pyproject-toml/2077
79-
80-
https://stackoverflow.com/questions/70386944/how-should-poetry-scripts-used-in-the-build-process-be-stored-in-the-project
81-
82-
https://github.com/python-poetry/poetry/issues/3386
83+
- https://discuss.python.org/t/a-new-pep-to-specify-dev-scripts-and-or-dev-scripts-providers-in-pyproject-toml/11457
84+
- https://discuss.python.org/t/proposal-for-tests-entry-point-in-pyproject-toml/2077
85+
- https://stackoverflow.com/questions/70386944/how-should-poetry-scripts-used-in-the-build-process-be-stored-in-the-project
86+
- https://github.com/python-poetry/poetry/issues/3386
8387
8488
## Example Workflow
8589
[.github/workflows/examples/example.yml](.github/workflows/examples/example.yml)

0 commit comments

Comments
 (0)