Skip to content

Commit 4b8c03b

Browse files
authored
chore(ci): add comment to direct new plugin contributors to contributing guide (#2598)
Signed-off-by: Hope Hadfield <hhadfiel@redhat.com>
1 parent b31900f commit 4b8c03b

2 files changed

Lines changed: 110 additions & 24 deletions

File tree

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Comment on PRs that add a workspace
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
branches: [main]
7+
8+
permissions:
9+
contents: read
10+
issues: write
11+
pull-requests: write
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
comment-new-workspace:
19+
name: Notify new workspace directory
20+
if: github.repository == 'redhat-developer/rhdh-plugins' && github.event.pull_request.user.login != 'rhdh-bot'
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Harden Runner
24+
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
25+
with:
26+
egress-policy: audit
27+
28+
- name: Checkout PR head
29+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
30+
with:
31+
ref: ${{ github.event.pull_request.head.sha }}
32+
fetch-depth: 0
33+
34+
- name: Fetch base commit
35+
run: git fetch --no-tags origin ${{ github.event.pull_request.base.sha }}
36+
37+
- name: Detect new top-level directories under workspaces/
38+
id: detect
39+
env:
40+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
41+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
42+
run: |
43+
set -euo pipefail
44+
if git cat-file -e "${BASE_SHA}:workspaces" 2>/dev/null; then
45+
git ls-tree "${BASE_SHA}:workspaces" | awk '$2=="tree" {print $4}' | sort -u > /tmp/base_ws.txt
46+
else
47+
: > /tmp/base_ws.txt
48+
fi
49+
if git cat-file -e "${HEAD_SHA}:workspaces" 2>/dev/null; then
50+
git ls-tree "${HEAD_SHA}:workspaces" | awk '$2=="tree" {print $4}' | sort -u > /tmp/head_ws.txt
51+
else
52+
: > /tmp/head_ws.txt
53+
fi
54+
comm -13 /tmp/base_ws.txt /tmp/head_ws.txt > /tmp/new_ws.txt || true
55+
if [ ! -s /tmp/new_ws.txt ]; then
56+
echo "has_new=false" >> "$GITHUB_OUTPUT"
57+
else
58+
echo "has_new=true" >> "$GITHUB_OUTPUT"
59+
fi
60+
61+
- name: Post PR comment
62+
if: steps.detect.outputs.has_new == 'true'
63+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
64+
with:
65+
script: |
66+
const marker = '<!-- rhdh-new-workspace-pr-comment -->';
67+
const issue_number = context.payload.pull_request.number;
68+
const comments = await github.paginate(github.rest.issues.listComments, {
69+
owner: context.repo.owner,
70+
repo: context.repo.repo,
71+
issue_number,
72+
per_page: 100,
73+
});
74+
if (comments.some((c) => c.body?.includes(marker))) {
75+
return;
76+
}
77+
const contributing = `https://github.com/${context.repo.owner}/${context.repo.repo}/blob/main/CONTRIBUTING.md#submitting-a-pull-request-for-a-new-workspace`;
78+
const body = [
79+
marker,
80+
'',
81+
'This pull request adds a new top-level directory under `workspaces/`. Please follow **[Submitting a Pull Request for a New Workspace](' + contributing + ')** in `CONTRIBUTING.md`.',
82+
].join('\n');
83+
await github.rest.issues.createComment({
84+
owner: context.repo.owner,
85+
repo: context.repo.repo,
86+
issue_number,
87+
body,
88+
});

CONTRIBUTING.md

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The `redhat-developer/rhdh-plugins` repository is designed as a collaborative sp
2222
- [Next steps](#next-steps)
2323
- [Maintenance of older versions](#maintenance-of-older-versions)
2424
- [API Reports](#api-reports)
25-
- [Submitting a Pull Request](#submitting-a-pull-request)
25+
- [Submitting a Pull Request](#submitting-a-pull-request-for-a-new-workspace)
2626
- [Plugin Owner Responsibilities](#plugin-owner-responsibilities)
2727
- [Responsibilities](#responsibilities)
2828
- [Keeping Workspaces Up to Date with Backstage](#keeping-workspaces-up-to-date-with-backstage)
@@ -201,7 +201,6 @@ cp -r ../existing-plugins/plugins/plugin-name plugins/
201201
1. Prepare your environment by cloning a fork of both the `janus-idp/backstage-plugins` and the `backstage/rhdh-plugins` repositories
202202

203203
2. In both repositories, create a new branch:
204-
205204
- For `janus-idp/backstage-plugins`:
206205

207206
```bash
@@ -215,7 +214,6 @@ cp -r ../existing-plugins/plugins/plugin-name plugins/
215214
```
216215

217216
3. In the `backstage/rhdh-plugins` repository, execute the janus-plugin migrate command.- Usage:`yarn rhdh-cli janus-plugin migrate --monorepo-path [path_to_backstage_plugins]--workspace-name [workspace_name] --branch [branch_name] --maintainers [maintainer1],[maintainer2],[maintainer3],...`
218-
219217
- The `path_to_backstage_plugins` is the path to the `backstage-plugins` project where the plugin(s) you want to migrate live.
220218
- The `workspace-name` is the name of the workspace you wish to create in the `rhdh-plugins` project. All plugins in the `backstage-plugins` that either are exactly or start with `@janus-idp/backstage-plugin-[workspace_name]` will be migrated to this new workspace.
221219
- The `branch_name` is the name of the branch in the `backstage-plugins` project where the changes to add a deprecate note for the migrated plugins will be made.
@@ -265,35 +263,35 @@ There are two ways you can do this:
265263

266264
Each plugin/package has its own API Report which means you might see more than one file updated or created depending on your changes. These changes will then need to be committed as well.
267265

268-
## Submitting a Pull Request
266+
## Submitting a Pull Request for a New Workspace
269267

270268
When you've got your contribution working, tested, and committed to your branch it's time to create a Pull Request (PR). If you are unsure how to do this GitHub's [Creating a pull request from a fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) documentation will help you with that.
271269
272270
For new plugins, it is recommended that your initial PR simply creates the workspace for your plugins. In this PR, be sure to add maintainers to the `CODEOWNERS` file for the new workspace. This will streamline the approval process, and also ensure that you have full autonomy over further development of your plugin.
273271
274-
Please ping @rhdh-cope in #rhdh-plugins-ecosystem on Slack when the PR is ready for review. We will do our best to complete an initial review within 5 working days, and address any subsequent updates within 2 working days.
272+
Please ping @rhdh-cope in #rhdh-plugins-ecosystem on Slack when the PR is ready for review. We will do our best to complete an initial review within 5 working days, and address any subsequent updates within 2 working days. We will not begin this process until the CI is passing or CI failures are explicitly justified.
275273
276274
### Checklist to Ensure your Plugin is Ready to Merge
277275
278-
* Workspace `package.json`
279-
* `private: true`
280-
* Use the correct repository url
281-
* Keep workspace-level dependencies minimal
282-
* Plugin `package.json`
283-
* For publishable plugins:
284-
* Omit `private: true`
285-
* Set `publishConfig.access` to `"public"`
286-
* Include a valid `backstage` config with `role`, `pluginId`, and `pluginPackages`
287-
* Use the correct repository URL
288-
* Required files
289-
* Changeset is present
290-
* README files with relevant documentation
291-
* `backstage.json` specifying a compatible Backstage version
292-
* Configuration (if applicable)
293-
* Include `config.d.ts` at the package level
294-
* Add proper visibility annotations
295-
* Ownership
296-
* Update `.github/CODEOWNERS` with appropriate maintainers
276+
- Workspace `package.json`
277+
- `private: true`
278+
- Use the correct repository url
279+
- Keep workspace-level dependencies minimal
280+
- Plugin `package.json`
281+
- For publishable plugins:
282+
- Omit `private: true`
283+
- Set `publishConfig.access` to `"public"`
284+
- Include a valid `backstage` config with `role`, `pluginId`, and `pluginPackages`
285+
- Use the correct repository URL
286+
- Required files
287+
- Changeset is present
288+
- README files with relevant documentation
289+
- `backstage.json` specifying a compatible Backstage version
290+
- Configuration (if applicable)
291+
- Include `config.d.ts` at the package level
292+
- Add proper visibility annotations
293+
- Ownership
294+
- Update `.github/CODEOWNERS` with appropriate maintainers
297295
298296
## Plugin Owner Responsibilities
299297

0 commit comments

Comments
 (0)