Skip to content

Commit 93fc904

Browse files
authored
feat(ipa): Commit checks and IPA changelog (#852)
1 parent 6385374 commit 93fc904

File tree

10 files changed

+300
-13
lines changed

10 files changed

+300
-13
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ updates:
2828
interval: weekly
2929
day: tuesday
3030
commit-message:
31-
prefix: "chore"
31+
prefix: "chore(ipa)"
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: IPA Changelog Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, edited]
6+
paths:
7+
- 'tools/spectral/ipa/package.json'
8+
9+
jobs:
10+
check-changelog:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout Repository
15+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
16+
with:
17+
sparse-checkout: |
18+
tools/spectral/ipa
19+
20+
- name: Fetch Versions
21+
working-directory: tools/spectral/ipa
22+
id: version_check
23+
run: |
24+
current_version=$(jq '.version' package.json)
25+
echo "Current version: $current_version"
26+
27+
previous_version=$(git show origin/${{ github.event.pull_request.base.ref }}:tools/spectral/ipa/package.json | jq -r '.version')
28+
29+
if [[ -z "$previous_version" || "$previous_version" == "null" ]]; then
30+
previous_version="none"
31+
fi
32+
echo "Previous version: $previous_version"
33+
34+
- name: Check Changelog
35+
working-directory: tools/spectral/ipa
36+
env:
37+
VERSION_BUMP: ${{ steps.version_check.outputs.current_version != steps.version_check.outputs.previous_version && 'true' || 'false' }}
38+
run: |
39+
npm run gen-ipa-changelog
40+
41+
# Check for uncommitted changes specific to CHANGELOG.md
42+
uncommitted_changes=$(git status --porcelain | grep "CHANGELOG.md" || echo "")
43+
44+
if [[ "$VERSION_BUMP" == "false" && -n "$uncommitted_changes" ]]; then
45+
echo "Error: Changelog should only be updated alongside a version bump. Please restore the changelog."
46+
exit 1
47+
fi
48+
49+
if [[ "$VERSION_BUMP" == "true" && -z "$uncommitted_changes" ]]; then
50+
echo "Error: Changelog must be updated alongside a version bump. Please run 'npm run gen-ipa-changelog' from the ipa directory and commit the changes."
51+
exit 1
52+
fi
53+
exit 0

.github/workflows/ipa-commit.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: IPA Commit Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, edited]
6+
paths:
7+
- 'tools/spectral/ipa/**'
8+
9+
jobs:
10+
check-pr-title:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Validate PR Title with IPA scope
15+
env:
16+
PR_TITLE: ${{ github.event.pull_request.title }}
17+
run: |
18+
PATTERN="^[a-z]+\(ipa\): .+$"
19+
if [[ ! "$PR_TITLE" =~ $PATTERN ]]; then
20+
echo "PR title must follow the conventional commit format with (ipa) as the scope."
21+
echo "Example: feat(ipa): My New Rule"
22+
exit 1
23+
fi

.github/workflows/release-changelog.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ jobs:
121121
target_branch: ${{ inputs.branch }}
122122
run_id: ${{ github.run_id }}
123123
with:
124-
commit_message: "(${{env.target_env}}) Release API Changelog :rocket:. See https://github.com/mongodb/openapi/actions/runs/${{env.run_id}}."
124+
commit_message: "ci(${{env.target_env}}): Release API Changelog :rocket:. See https://github.com/mongodb/openapi/actions/runs/${{env.run_id}}."
125125
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
126126
branch: ${{env.target_branch}}
127127
file_pattern: "changelog/*"

.github/workflows/release-spec-v1.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
target_branch: ${{ inputs.branch }}
8484
run_id: ${{ github.run_id }}
8585
with:
86-
commit_message: "(${{env.target_env}}) Release OpenAPI Spec V1 :rocket:. See https://github.com/mongodb/openapi/actions/runs/${{env.run_id}}."
86+
commit_message: "ci(${{env.target_env}}): Release OpenAPI Spec V1 :rocket:. See https://github.com/mongodb/openapi/actions/runs/${{env.run_id}}."
8787
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
8888
branch: ${{env.target_branch}}
8989
file_pattern: "openapi/v1-deprecated/*"

.github/workflows/release-spec.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ jobs:
183183
target_branch: ${{ inputs.branch }}
184184
run_id: ${{ github.run_id }}
185185
with:
186-
commit_message: "(${{env.target_env}}) Release OpenAPI Spec :rocket:. See https://github.com/mongodb/openapi/actions/runs/${{env.run_id}}."
186+
commit_message: "ci(${{env.target_env}}): Release OpenAPI Spec :rocket:. See https://github.com/mongodb/openapi/actions/runs/${{env.run_id}}."
187187
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
188188
branch: ${{env.target_branch}}
189189
file_pattern: "openapi/*"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Semantic Commit Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, edited]
6+
7+
jobs:
8+
semantic-commit:
9+
runs-on: ubuntu-latest
10+
name: Check Semantic PRs titles
11+
steps:
12+
- name: Check PR title
13+
uses: amannn/action-semantic-pull-request@335288255954904a41ddda8947c8f2c844b8bfeb
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
with:
17+
types: |
18+
feat
19+
fix
20+
docs
21+
style
22+
refactor
23+
perf
24+
test
25+
build
26+
ci
27+
chore
28+
revert
29+
scopes: |
30+
ipa
31+
prod
32+
requireScope: false
33+
subjectPattern: "^[A-Z].+[^.]$"
34+
subjectPatternError: |
35+
The subject "{subject}" found in the pull request title "{title}"
36+
didn't match the configured pattern. Please ensure that the subject
37+
starts with an uppercase letter and doesn't end with a period.
38+
validateSingleCommit: false

tools/spectral/ipa/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### Changelog
2+
3+
All notable changes to this project will be documented in this file. Dates are displayed in UTC.
4+
5+
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

0 commit comments

Comments
 (0)