Skip to content

Commit 3c21d08

Browse files
authored
Merge pull request open-cluster-management-io#86 from haoqing0110/docs/improve-onboarding-and-changelog
🌱 Improve onboarding guide and fix changelog monorepo tag filtering
2 parents 151fd1a + e3f7fa5 commit 3c21d08

2 files changed

Lines changed: 50 additions & 23 deletions

File tree

README.md

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,42 +34,53 @@ To onboard a new addon-contrib project:
3434
1. If not already discussed with maintainers, open an issue to propose your idea.
3535
1. Once acknowledged, create a folder named after your project and add your code/docs.
3636
1. Add an `OWNERS` file listing the new project's maintainers.
37-
1. Create a PR with a brief project overview and confirm the `OWNERS` file is present.
37+
1. **Register your project** in `.github/repositories.json` (see [Repository Registration](#repository-registration) below).
38+
1. **Ensure CI/CD compliance** by implementing required structure and targets (see [GitHub Actions Requirements](#github-actions-requirements) below).
39+
1. Create a PR with a brief project overview and confirm all requirements are met.
3840
1. An OCM maintainer will review and merge the PR.
3941

40-
### GitHub Actions
42+
### GitHub Actions Requirements
4143

4244
All projects must follow certain conventions to ensure compatibility with the addon-contrib repository's Github Actions workflows.
4345

4446
Refer to the [Test](./.github/workflows/test.yml) and [E2E](./.github/workflows/e2e.yml) workflows for exact details.
4547

46-
#### `make` targets
48+
#### Required `make` Targets
4749

48-
All projects must define the following `make` targets:
50+
All projects **must** define the following `make` targets in their `Makefile`:
4951

50-
- `verify`: Import statement formatting verification using `gci` and static code analysis and linting using `golangci-lint`
51-
- `build`: Compile the Go application into a statically linked binary with debug information stripped for optimal container deployment
52-
- `test-unit`: Invoke unit tests and return an exit code accordingly.
53-
- `test-chart`: Invoke scripts to verify your chart can be installed successfully.
54-
- `test-e2e`: Invoke end-to-end tests and return an exit code accordingly.
55-
- `image`: Build all container image.
56-
- `image-push`: Push all container images.
57-
- `image-manifest`: Create annotate and push multi-architecture manifests for all images.
52+
| Target | Description | Can be Stub? |
53+
|--------|-------------|--------------|
54+
| `verify` | Code verification (linting, formatting) | No - should run actual checks |
55+
| `vendor` | Update Go module dependencies | No - if Go project |
56+
| `build` | Build the application binary | No - if Go project |
57+
| `test-unit` | Run unit tests | No - should run actual tests |
58+
| `test-integration` | Run integration tests | **Yes** - can return true if not implemented |
59+
| `test-e2e` | Run end-to-end tests | **Yes** - can return true if not implemented |
60+
| `test-chart` | Test Helm chart installation | **Yes** - can return true if no chart |
61+
| `image` | Build container image | **Yes** - only if Dockerfile exists |
62+
| `image-push` | Push container image to registry | **Yes** - only if Dockerfile exists |
63+
| `image-manifest` | Create multi-arch image manifest | **Yes** - only if Dockerfile exists |
5864

59-
#### Dockerfiles
65+
#### Dockerfiles (Optional)
6066

61-
All Dockerfiles for the project must reside under `<project_name>/` and the default Dockerfile must be named `Dockerfile`.
67+
Container images are **optional**. If your addon requires a container image:
68+
69+
- Dockerfile must reside under `<project_name>/Dockerfile`
70+
- The workflow will automatically detect Dockerfile presence
71+
- If no Dockerfile exists, image build steps will be skipped
6272

6373
#### Helm Charts
6474

65-
Any projects that require a Helm chart must be structured as follows:
75+
**If** your project requires a Helm chart, it must be structured as follows:
6676

6777
```bash
6878
<project_name>
6979
└── charts
70-
└── <project_name> # chart name must match project directory name
80+
└── <project_name> # Chart name must match project directory name
7181
├── Chart.yaml
7282
├── templates
83+
│ └── *.yaml
7384
└── values.yaml
7485
```
7586

hack/changelog.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,35 @@ def section_if_present(changes: [], pr_title):
6565
repo = g.get_repo("open-cluster-management-io/addon-contrib")
6666
pulls = repo.get_pulls(state='closed', sort='created', base='main', direction='desc')
6767

68-
# get the last release tag
68+
# get the last release tag for this specific sub repo
6969
tags = repo.get_tags()
7070
if tags.totalCount == 0:
7171
print("no tags in the repo")
7272
sys.exit()
73-
elif tags.totalCount == 1:
74-
last_release_tag = tags[0].name
73+
74+
# Filter tags that match the current repo_name prefix
75+
# Use exact prefix match to avoid matching similar repo names
76+
repo_tags = []
77+
for tag in tags:
78+
if tag.name.startswith(repo_name + '/'):
79+
repo_tags.append(tag)
80+
81+
if len(repo_tags) <= 1:
82+
# First release for this repo - no previous tags to compare
83+
# (0 = not tagged yet, 1 = only current tag exists)
84+
last_release_tag = None
7585
else:
76-
last_release_tag = tags[1].name
86+
# Find the previous release tag (second in the filtered list)
87+
# repo_tags[0] is current release, repo_tags[1] is previous
88+
last_release_tag = repo_tags[1].name
7789

7890
# get related PR from the last release tag
7991
last_release_pr = 0
8092
release_word = "in"
8193

82-
if tags.totalCount > 1:
94+
if last_release_tag:
8395
release_word = "since"
96+
# Find the tag object to get its commit and associated PRs
8497
for tag in tags:
8598
if tag.name == last_release_tag:
8699
tag_pulls = tag.commit.get_pulls()
@@ -116,8 +129,11 @@ def section_if_present(changes: [], pr_title):
116129

117130
# Print
118131
print("# %s %s" % (repo_name, release_tag))
119-
print("\n**changes %s [%s](https://github.com/open-cluster-management-io/releases/%s)**\n"
120-
% (release_word, last_release_tag, last_release_tag))
132+
if last_release_tag:
133+
print("\n**changes %s [%s](https://github.com/open-cluster-management-io/releases/%s)**\n"
134+
% (release_word, last_release_tag, last_release_tag))
135+
else:
136+
print("\n**Initial release**\n")
121137
section_if_present(breakings, ":warning: Breaking Changes")
122138
section_if_present(features, ":sparkles: New Features")
123139
section_if_present(bugs, ":bug: Bug Fixes")

0 commit comments

Comments
 (0)