diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 0af50a712d..2ecc109360 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -28,4 +28,4 @@ updates: interval: weekly day: tuesday commit-message: - prefix: "chore" + prefix: "chore(ipa)" diff --git a/.github/workflows/ipa-changelog.yml b/.github/workflows/ipa-changelog.yml new file mode 100644 index 0000000000..8b5227d49a --- /dev/null +++ b/.github/workflows/ipa-changelog.yml @@ -0,0 +1,53 @@ +name: IPA Changelog Check + +on: + pull_request: + types: [opened, synchronize, reopened, edited] + paths: + - 'tools/spectral/ipa/package.json' + +jobs: + check-changelog: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + with: + sparse-checkout: | + tools/spectral/ipa + + - name: Fetch Versions + working-directory: tools/spectral/ipa + id: version_check + run: | + current_version=$(jq '.version' package.json) + echo "Current version: $current_version" + + previous_version=$(git show origin/${{ github.event.pull_request.base.ref }}:tools/spectral/ipa/package.json | jq -r '.version') + + if [[ -z "$previous_version" || "$previous_version" == "null" ]]; then + previous_version="none" + fi + echo "Previous version: $previous_version" + + - name: Check Changelog + working-directory: tools/spectral/ipa + env: + VERSION_BUMP: ${{ steps.version_check.outputs.current_version != steps.version_check.outputs.previous_version && 'true' || 'false' }} + run: | + npm run gen-ipa-changelog + + # Check for uncommitted changes specific to CHANGELOG.md + uncommitted_changes=$(git status --porcelain | grep "CHANGELOG.md" || echo "") + + if [[ "$VERSION_BUMP" == "false" && -n "$uncommitted_changes" ]]; then + echo "Error: Changelog should only be updated alongside a version bump. Please restore the changelog." + exit 1 + fi + + if [[ "$VERSION_BUMP" == "true" && -z "$uncommitted_changes" ]]; then + 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." + exit 1 + fi + exit 0 \ No newline at end of file diff --git a/.github/workflows/ipa-commit.yml b/.github/workflows/ipa-commit.yml new file mode 100644 index 0000000000..84ea0ab8c7 --- /dev/null +++ b/.github/workflows/ipa-commit.yml @@ -0,0 +1,23 @@ +name: IPA Commit Check + +on: + pull_request: + types: [opened, synchronize, reopened, edited] + paths: + - 'tools/spectral/ipa/**' + +jobs: + check-pr-title: + runs-on: ubuntu-latest + + steps: + - name: Validate PR Title with IPA scope + env: + PR_TITLE: ${{ github.event.pull_request.title }} + run: | + PATTERN="^[a-z]+\(ipa\): .+$" + if [[ ! "$PR_TITLE" =~ $PATTERN ]]; then + echo "PR title must follow the conventional commit format with (ipa) as the scope." + echo "Example: feat(ipa): My New Rule" + exit 1 + fi \ No newline at end of file diff --git a/.github/workflows/release-changelog.yml b/.github/workflows/release-changelog.yml index 1e8046eb01..92ba7ff0f8 100644 --- a/.github/workflows/release-changelog.yml +++ b/.github/workflows/release-changelog.yml @@ -121,7 +121,7 @@ jobs: target_branch: ${{ inputs.branch }} run_id: ${{ github.run_id }} with: - commit_message: "(${{env.target_env}}) Release API Changelog :rocket:. See https://github.com/mongodb/openapi/actions/runs/${{env.run_id}}." + commit_message: "ci(${{env.target_env}}): Release API Changelog :rocket:. See https://github.com/mongodb/openapi/actions/runs/${{env.run_id}}." commit_author: "github-actions[bot] " branch: ${{env.target_branch}} file_pattern: "changelog/*" diff --git a/.github/workflows/release-spec-v1.yml b/.github/workflows/release-spec-v1.yml index 4b88c2ae63..65d7fa6e9c 100644 --- a/.github/workflows/release-spec-v1.yml +++ b/.github/workflows/release-spec-v1.yml @@ -83,7 +83,7 @@ jobs: target_branch: ${{ inputs.branch }} run_id: ${{ github.run_id }} with: - commit_message: "(${{env.target_env}}) Release OpenAPI Spec V1 :rocket:. See https://github.com/mongodb/openapi/actions/runs/${{env.run_id}}." + commit_message: "ci(${{env.target_env}}): Release OpenAPI Spec V1 :rocket:. See https://github.com/mongodb/openapi/actions/runs/${{env.run_id}}." commit_author: "github-actions[bot] " branch: ${{env.target_branch}} file_pattern: "openapi/v1-deprecated/*" diff --git a/.github/workflows/release-spec.yml b/.github/workflows/release-spec.yml index dc64297df2..c199dcedef 100644 --- a/.github/workflows/release-spec.yml +++ b/.github/workflows/release-spec.yml @@ -183,7 +183,7 @@ jobs: target_branch: ${{ inputs.branch }} run_id: ${{ github.run_id }} with: - commit_message: "(${{env.target_env}}) Release OpenAPI Spec :rocket:. See https://github.com/mongodb/openapi/actions/runs/${{env.run_id}}." + commit_message: "ci(${{env.target_env}}): Release OpenAPI Spec :rocket:. See https://github.com/mongodb/openapi/actions/runs/${{env.run_id}}." commit_author: "github-actions[bot] " branch: ${{env.target_branch}} file_pattern: "openapi/*" diff --git a/.github/workflows/semantic-commit.yml b/.github/workflows/semantic-commit.yml new file mode 100644 index 0000000000..1323e24e79 --- /dev/null +++ b/.github/workflows/semantic-commit.yml @@ -0,0 +1,38 @@ +name: Semantic Commit Check + +on: + pull_request: + types: [opened, synchronize, reopened, edited] + +jobs: + semantic-commit: + runs-on: ubuntu-latest + name: Check Semantic PRs titles + steps: + - name: Check PR title + uses: amannn/action-semantic-pull-request@335288255954904a41ddda8947c8f2c844b8bfeb + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + types: | + feat + fix + docs + style + refactor + perf + test + build + ci + chore + revert + scopes: | + ipa + prod + requireScope: false + subjectPattern: "^[A-Z].+[^.]$" + subjectPatternError: | + The subject "{subject}" found in the pull request title "{title}" + didn't match the configured pattern. Please ensure that the subject + starts with an uppercase letter and doesn't end with a period. + validateSingleCommit: false \ No newline at end of file diff --git a/tools/spectral/ipa/CHANGELOG.md b/tools/spectral/ipa/CHANGELOG.md new file mode 100644 index 0000000000..bd48566089 --- /dev/null +++ b/tools/spectral/ipa/CHANGELOG.md @@ -0,0 +1,5 @@ +### Changelog + +All notable changes to this project will be documented in this file. Dates are displayed in UTC. + +Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). diff --git a/tools/spectral/ipa/package-lock.json b/tools/spectral/ipa/package-lock.json index de0782355c..8f2e7cbd5c 100644 --- a/tools/spectral/ipa/package-lock.json +++ b/tools/spectral/ipa/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mongodb-js/ipa-validation-ruleset", - "version": "1.0.0", + "version": "0.0.1-dev1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@mongodb-js/ipa-validation-ruleset", - "version": "1.0.0", + "version": "0.0.1-dev1", "license": "Apache-2.0", "dependencies": { "@stoplight/spectral-cli": "6.15.0", @@ -14,6 +14,9 @@ "@stoplight/spectral-functions": "1.10.1", "inflection": "3.0.2" }, + "devDependencies": { + "auto-changelog": "2.5.0" + }, "engines": { "node": ">=20.0.0" } @@ -874,6 +877,27 @@ "node": ">= 0.4" } }, + "node_modules/auto-changelog": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/auto-changelog/-/auto-changelog-2.5.0.tgz", + "integrity": "sha512-UTnLjT7I9U2U/xkCUH5buDlp8C7g0SGChfib+iDrJkamcj5kaMqNKHNfbKJw1kthJUq8sUo3i3q2S6FzO/l/wA==", + "dev": true, + "license": "MIT", + "dependencies": { + "commander": "^7.2.0", + "handlebars": "^4.7.7", + "import-cwd": "^3.0.0", + "node-fetch": "^2.6.1", + "parse-github-url": "^1.0.3", + "semver": "^7.3.5" + }, + "bin": { + "auto-changelog": "src/index.js" + }, + "engines": { + "node": ">=8.3" + } + }, "node_modules/available-typed-arrays": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", @@ -1015,6 +1039,16 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "license": "MIT" }, + "node_modules/commander": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", + "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 10" + } + }, "node_modules/commondir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", @@ -1615,6 +1649,28 @@ "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", "license": "ISC" }, + "node_modules/handlebars": { + "version": "4.7.8", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz", + "integrity": "sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "minimist": "^1.2.5", + "neo-async": "^2.6.2", + "source-map": "^0.6.1", + "wordwrap": "^1.0.0" + }, + "bin": { + "handlebars": "bin/handlebars" + }, + "engines": { + "node": ">=0.4.7" + }, + "optionalDependencies": { + "uglify-js": "^3.1.4" + } + }, "node_modules/has-bigints": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.1.0.tgz", @@ -1721,6 +1777,32 @@ "url": "https://opencollective.com/immer" } }, + "node_modules/import-cwd": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/import-cwd/-/import-cwd-3.0.0.tgz", + "integrity": "sha512-4pnzH16plW+hgvRECbDWpQl3cqtvSofHWh44met7ESfZ8UZOWWddm8hEyDTqREJ9RbYHY8gi8DqmaelApoOGMg==", + "dev": true, + "license": "MIT", + "dependencies": { + "import-from": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/import-from": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/import-from/-/import-from-3.0.0.tgz", + "integrity": "sha512-CiuXOFFSzkU5x/CR0+z7T91Iht4CXgfCxVOFRhh2Zyhg5wOpWvvDLQUsWl+gcN+QscYBjez8hDCt85O7RLDttQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/inflection": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/inflection/-/inflection-3.0.2.tgz", @@ -2281,6 +2363,23 @@ "node": "*" } }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/neo-async": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", + "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", + "dev": true, + "license": "MIT" + }, "node_modules/nimma": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/nimma/-/nimma-0.2.3.tgz", @@ -2400,6 +2499,19 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/parse-github-url": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/parse-github-url/-/parse-github-url-1.0.3.tgz", + "integrity": "sha512-tfalY5/4SqGaV/GIGzWyHnFjlpTPTNpENR9Ea2lLldSJ8EWXMsvacWucqY3m3I4YPtas15IxTLQVQ5NSYXPrww==", + "dev": true, + "license": "MIT", + "bin": { + "parse-github-url": "cli.js" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -2559,6 +2671,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/reusify": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", @@ -2665,6 +2787,19 @@ "integrity": "sha512-ERq4hUjKDbJfE4+XtZLFPCDi8Vb1JqaxAPTxWFLBx8XcAlf9Bda/ZJdVezs/NAfsMQScyIlUMx+Yeu7P7rx5jw==", "license": "MIT" }, + "node_modules/semver": { + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/set-function-length": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", @@ -3053,6 +3188,20 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/uglify-js": { + "version": "3.19.3", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz", + "integrity": "sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==", + "dev": true, + "license": "BSD-2-Clause", + "optional": true, + "bin": { + "uglifyjs": "bin/uglifyjs" + }, + "engines": { + "node": ">=0.8.0" + } + }, "node_modules/unbox-primitive": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.1.0.tgz", @@ -3211,6 +3360,13 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==", + "dev": true, + "license": "MIT" + }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", diff --git a/tools/spectral/ipa/package.json b/tools/spectral/ipa/package.json index e9c5c03611..4a467a12c5 100644 --- a/tools/spectral/ipa/package.json +++ b/tools/spectral/ipa/package.json @@ -18,14 +18,26 @@ "license": "Apache-2.0", "author": "MongoDB", "main": "ipa-spectral.yaml", + "scripts" : { + "gen-ipa-changelog" : "npx auto-changelog" + }, "dependencies": { - "@stoplight/spectral-cli": "6.15.0", - "@stoplight/spectral-core": "1.20.0", - "@stoplight/spectral-functions": "1.10.1", - "inflection": "3.0.2" + "@stoplight/spectral-cli": "6.15.0", + "@stoplight/spectral-core": "1.20.0", + "@stoplight/spectral-functions": "1.10.1", + "inflection": "3.0.2" }, "engineStrict": false, - "engines": { - "node": ">=20.0.0" - } + "engines": { + "node": ">=20.0.0" + }, + "devDependencies": { + "auto-changelog": "2.5.0" + }, + "auto-changelog" : { + "package" : true, + "commitPattern" : "[a-z]+(ipa): ", + "startingVersion" : "0.1.0", + "hideEmptyReleases" : true + } }