Skip to content

Commit d9aa80b

Browse files
authored
feat: support arbitrary path exports (#38)
* fix: make lsp not yell at me * feat: add arbitrary metadata * feat: add tests * chore: refine input name and description * feat: namespace additional exports under 'exports' key * chore: update readme
1 parent ef9ef74 commit d9aa80b

File tree

14 files changed

+543
-353
lines changed

14 files changed

+543
-353
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This action aims to help you eliminate (or at least reduce) the amount of custom
1212
- **root-dir**: Directory root for where to begin recursively searching for projects.
1313
Python projects contained in this directory or lower will be discovered. Defaults to your repository's root directory.
1414

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".
1516

1617
## Outputs
1718
- **paths**: JSON array of found project path strings
@@ -39,6 +40,8 @@ These are the fields for `project` objects in the output:
3940
- **commands**: Object with keys for each discovered command and the shell command as the value.
4041
This is dynamically constructed from the `pyproject.toml` content.
4142

43+
- **exports**: Object with keys specified by the `additional-export-paths` input, and the structured TOML data (parsed as JSON) as the values.
44+
4245

4346
## Project Commands
4447
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.
@@ -79,4 +82,4 @@ https://stackoverflow.com/questions/70386944/how-should-poetry-scripts-used-in-t
7982
https://github.com/python-poetry/poetry/issues/3386
8083

8184
## Example Workflow
82-
[.github/workflows/examples/example.yml](.github/workflows/examples/example.yml)
85+
[.github/workflows/examples/example.yml](.github/workflows/examples/example.yml)

__snapshots__/find-python-projects.test.js.snap

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,53 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`find-python-projects Exports keys as instructed 1`] = `
4+
{
5+
"paths": [
6+
"test-fixtures/project-with-exports/pyproject.toml",
7+
],
8+
"projects": [
9+
{
10+
"buildBackend": "poetry.core.masonry.api",
11+
"commands": {
12+
"install": "poetry install",
13+
},
14+
"directory": "test-fixtures/project-with-exports",
15+
"exports": {
16+
"tool.export.me.please": {
17+
"foo": "bar",
18+
"one": 1,
19+
"true": true,
20+
},
21+
},
22+
"name": "single-project",
23+
"path": "test-fixtures/project-with-exports/pyproject.toml",
24+
"pythonVersion": "^3.9",
25+
},
26+
],
27+
"projects-by-command": {
28+
"install": [
29+
{
30+
"buildBackend": "poetry.core.masonry.api",
31+
"commands": {
32+
"install": "poetry install",
33+
},
34+
"directory": "test-fixtures/project-with-exports",
35+
"exports": {
36+
"tool.export.me.please": {
37+
"foo": "bar",
38+
"one": 1,
39+
"true": true,
40+
},
41+
},
42+
"name": "single-project",
43+
"path": "test-fixtures/project-with-exports/pyproject.toml",
44+
"pythonVersion": "^3.9",
45+
},
46+
],
47+
},
48+
}
49+
`;
50+
351
exports[`find-python-projects finds projects 1`] = `
452
{
553
"paths": [
@@ -16,6 +64,7 @@ exports[`find-python-projects finds projects 1`] = `
1664
"install": "poetry install",
1765
},
1866
"directory": "test-fixtures/multi-project/project-1",
67+
"exports": {},
1968
"name": "sub-project-1",
2069
"path": "test-fixtures/multi-project/project-1/pyproject.toml",
2170
"pythonVersion": "^3.9",
@@ -29,6 +78,7 @@ exports[`find-python-projects finds projects 1`] = `
2978
"test": "poetry run pytest",
3079
},
3180
"directory": "test-fixtures/multi-project/project-2",
81+
"exports": {},
3282
"name": "sub-project-2",
3383
"path": "test-fixtures/multi-project/project-2/pyproject.toml",
3484
"pythonVersion": "^3.9",
@@ -38,6 +88,7 @@ exports[`find-python-projects finds projects 1`] = `
3888
"install": null,
3989
},
4090
"directory": "test-fixtures/multi-project/project-4",
91+
"exports": {},
4192
"name": "sub-project-4",
4293
"path": "test-fixtures/multi-project/project-4/pyproject.toml",
4394
"pythonVersion": "^3.9",
@@ -49,6 +100,7 @@ exports[`find-python-projects finds projects 1`] = `
49100
"test": "pdm run test",
50101
},
51102
"directory": "test-fixtures/multi-project/project-5",
103+
"exports": {},
52104
"name": "project-5",
53105
"path": "test-fixtures/multi-project/project-5/pyproject.toml",
54106
"pythonVersion": "==3.12.*",
@@ -60,6 +112,7 @@ exports[`find-python-projects finds projects 1`] = `
60112
"test": "poe test",
61113
},
62114
"directory": "test-fixtures/multi-project/project-6",
115+
"exports": {},
63116
"name": "sub-project-6",
64117
"path": "test-fixtures/multi-project/project-6/pyproject.toml",
65118
"pythonVersion": "^3.9",
@@ -73,6 +126,7 @@ exports[`find-python-projects finds projects 1`] = `
73126
"install": "poetry install",
74127
},
75128
"directory": "test-fixtures/multi-project/project-1",
129+
"exports": {},
76130
"name": "sub-project-1",
77131
"path": "test-fixtures/multi-project/project-1/pyproject.toml",
78132
"pythonVersion": "^3.9",
@@ -86,6 +140,7 @@ exports[`find-python-projects finds projects 1`] = `
86140
"test": "poetry run pytest",
87141
},
88142
"directory": "test-fixtures/multi-project/project-2",
143+
"exports": {},
89144
"name": "sub-project-2",
90145
"path": "test-fixtures/multi-project/project-2/pyproject.toml",
91146
"pythonVersion": "^3.9",
@@ -97,6 +152,7 @@ exports[`find-python-projects finds projects 1`] = `
97152
"test": "pdm run test",
98153
},
99154
"directory": "test-fixtures/multi-project/project-5",
155+
"exports": {},
100156
"name": "project-5",
101157
"path": "test-fixtures/multi-project/project-5/pyproject.toml",
102158
"pythonVersion": "==3.12.*",
@@ -108,6 +164,7 @@ exports[`find-python-projects finds projects 1`] = `
108164
"test": "poe test",
109165
},
110166
"directory": "test-fixtures/multi-project/project-6",
167+
"exports": {},
111168
"name": "sub-project-6",
112169
"path": "test-fixtures/multi-project/project-6/pyproject.toml",
113170
"pythonVersion": "^3.9",
@@ -123,6 +180,7 @@ exports[`find-python-projects finds projects 1`] = `
123180
"test": "poetry run pytest",
124181
},
125182
"directory": "test-fixtures/multi-project/project-2",
183+
"exports": {},
126184
"name": "sub-project-2",
127185
"path": "test-fixtures/multi-project/project-2/pyproject.toml",
128186
"pythonVersion": "^3.9",
@@ -138,6 +196,7 @@ exports[`find-python-projects finds projects 1`] = `
138196
"test": "poetry run pytest",
139197
},
140198
"directory": "test-fixtures/multi-project/project-2",
199+
"exports": {},
141200
"name": "sub-project-2",
142201
"path": "test-fixtures/multi-project/project-2/pyproject.toml",
143202
"pythonVersion": "^3.9",
@@ -153,6 +212,7 @@ exports[`find-python-projects finds projects 1`] = `
153212
"test": "poetry run pytest",
154213
},
155214
"directory": "test-fixtures/multi-project/project-2",
215+
"exports": {},
156216
"name": "sub-project-2",
157217
"path": "test-fixtures/multi-project/project-2/pyproject.toml",
158218
"pythonVersion": "^3.9",
@@ -164,6 +224,7 @@ exports[`find-python-projects finds projects 1`] = `
164224
"test": "pdm run test",
165225
},
166226
"directory": "test-fixtures/multi-project/project-5",
227+
"exports": {},
167228
"name": "project-5",
168229
"path": "test-fixtures/multi-project/project-5/pyproject.toml",
169230
"pythonVersion": "==3.12.*",
@@ -175,6 +236,7 @@ exports[`find-python-projects finds projects 1`] = `
175236
"test": "poe test",
176237
},
177238
"directory": "test-fixtures/multi-project/project-6",
239+
"exports": {},
178240
"name": "sub-project-6",
179241
"path": "test-fixtures/multi-project/project-6/pyproject.toml",
180242
"pythonVersion": "^3.9",

action.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ inputs:
99
root-dir:
1010
description: Directory root for where to begin recursively searching for projects. Python projects contained in this directory or lower will be discovered.
1111
required: false
12-
default: '.'
12+
default: "."
13+
additional-export-paths:
14+
description: Additional TOML keys to export as part of the projects object. Specify them as json path strings, separated by commas. For example, "tool.upside.foo,bar.baz".
15+
required: false
16+
default: ""
1317

1418
outputs:
1519
paths:
@@ -25,5 +29,5 @@ outputs:
2529
description: JSON array of all found projects (`project` object) that implement a `package` command
2630

2731
runs:
28-
using: 'node20'
29-
main: 'dist/index.js'
32+
using: "node20"
33+
main: "dist/index.js"

0 commit comments

Comments
 (0)