Re: [PR] ci: add GitHub Action to check CHANGELOG consistency with PRs [apisix]

2025-06-19 Thread via GitHub


LiteSun merged PR #12347:
URL: https://github.com/apache/apisix/pull/12347


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] ci: add GitHub Action to check CHANGELOG consistency with PRs [apisix]

2025-06-19 Thread via GitHub


LiteSun commented on code in PR #12347:
URL: https://github.com/apache/apisix/pull/12347#discussion_r2157921129


##
.github/workflows/check-changelog.yml:
##
@@ -0,0 +1,24 @@
+name: Check Changelog
+
+on:
+  push:

Review Comment:
   > I'm wondering if we should just listen for changes in the CHANGEsLOG file?
   
   we actually need to detect any missing changelog updates as early as 
possible when a PR is created. I just tested it and found that the push event 
does not trigger the CI when the PR is first submitted.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] ci: add GitHub Action to check CHANGELOG consistency with PRs [apisix]

2025-06-19 Thread via GitHub


Baoyuantop commented on code in PR #12347:
URL: https://github.com/apache/apisix/pull/12347#discussion_r2157916324


##
.github/workflows/check-changelog.yml:
##
@@ -0,0 +1,24 @@
+name: Check Changelog
+
+on:
+  push:
+paths:
+  - 'CHANGELOG.md'
+  pull_request:
+paths:
+  - 'CHANGELOG.md'
+
+jobs:
+  check-changelog:
+runs-on: ubuntu-latest
+steps:
+  - uses: actions/checkout@v4
+with:
+  fetch-depth: 0
+
+  - name: Run check_changelog_prs script
+working-directory: ci
+run: |
+  curl -fsSL https://bun.sh/install | bash

Review Comment:
   Looks like it ran successfully?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] ci: add GitHub Action to check CHANGELOG consistency with PRs [apisix]

2025-06-19 Thread via GitHub


SkyeYoung commented on code in PR #12347:
URL: https://github.com/apache/apisix/pull/12347#discussion_r2157898527


##
.github/workflows/check-changelog.yml:
##
@@ -0,0 +1,24 @@
+name: Check Changelog
+
+on:
+  push:
+paths:
+  - 'CHANGELOG.md'
+  pull_request:
+paths:
+  - 'CHANGELOG.md'
+
+jobs:
+  check-changelog:
+runs-on: ubuntu-latest
+steps:
+  - uses: actions/checkout@v4
+with:
+  fetch-depth: 0
+
+  - name: Run check_changelog_prs script
+working-directory: ci
+run: |
+  curl -fsSL https://bun.sh/install | bash

Review Comment:
   check here 
https://github.com/apache/infrastructure-actions/blob/main/actions.yml



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] ci: add GitHub Action to check CHANGELOG consistency with PRs [apisix]

2025-06-19 Thread via GitHub


SkyeYoung commented on code in PR #12347:
URL: https://github.com/apache/apisix/pull/12347#discussion_r2157896710


##
.github/workflows/check-changelog.yml:
##
@@ -0,0 +1,24 @@
+name: Check Changelog
+
+on:
+  push:
+paths:
+  - 'CHANGELOG.md'
+  pull_request:
+paths:
+  - 'CHANGELOG.md'
+
+jobs:
+  check-changelog:
+runs-on: ubuntu-latest
+steps:
+  - uses: actions/checkout@v4
+with:
+  fetch-depth: 0
+
+  - name: Run check_changelog_prs script
+working-directory: ci
+run: |
+  curl -fsSL https://bun.sh/install | bash

Review Comment:
   We can't use these directly.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] ci: add GitHub Action to check CHANGELOG consistency with PRs [apisix]

2025-06-19 Thread via GitHub


juzhiyuan commented on code in PR #12347:
URL: https://github.com/apache/apisix/pull/12347#discussion_r2157880927


##
.github/workflows/check-changelog.yml:
##
@@ -0,0 +1,24 @@
+name: Check Changelog
+
+on:
+  push:

Review Comment:
   I'm wondering if we should just listen for changes in the CHANGEsLOG file?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] ci: add GitHub Action to check CHANGELOG consistency with PRs [apisix]

2025-06-19 Thread via GitHub


Baoyuantop commented on code in PR #12347:
URL: https://github.com/apache/apisix/pull/12347#discussion_r2157864960


##
.github/workflows/check-changelog.yml:
##
@@ -0,0 +1,24 @@
+name: Check Changelog
+
+on:
+  push:
+paths:
+  - 'CHANGELOG.md'
+  pull_request:
+paths:
+  - 'CHANGELOG.md'
+
+jobs:
+  check-changelog:
+runs-on: ubuntu-latest
+steps:
+  - uses: actions/checkout@v4
+with:
+  fetch-depth: 0
+
+  - name: Run check_changelog_prs script
+working-directory: ci
+run: |
+  curl -fsSL https://bun.sh/install | bash

Review Comment:
   use https://github.com/oven-sh/setup-bun



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] ci: add GitHub Action to check CHANGELOG consistency with PRs [apisix]

2025-06-19 Thread via GitHub


LiteSun commented on code in PR #12347:
URL: https://github.com/apache/apisix/pull/12347#discussion_r2157836873


##
ci/check_changelog_prs.ts:
##
@@ -0,0 +1,235 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { execSync } from 'child_process';
+import { readFileSync } from 'fs';
+import { join } from 'path';
+
+// Types
+interface Version {
+tag: string;
+ref: string;
+}
+
+interface PR {
+number: number;
+title: string;
+commit: string;
+}
+
+// Configuration
+const IGNORE_TYPES = [
+'docs',
+'chore',
+'test',
+'ci'
+];
+
+const IGNORE_PRS = [
+// 3.9.0
+10655, 10857, 10858, 10887, 10959, 11029, 11041, 11053, 11055, 11061, 
10976, 10984, 11025,
+// 3.10.0
+11105, 11128, 11169, 11171, 11280, 11333, 11081, 11202, 11469,
+// 3.11.0
+11463, 11570,
+// 3.12.0
+11769, 11816, 11881, 11905, 11924, 11926, 11973, 11991, 11992, 11829
+];
+
+
+function getGitRef(version: string): string {
+try {
+execSync(`git rev-parse ${version}`, { stdio: 'ignore' });
+return version;
+} catch {
+return 'HEAD';
+}
+}
+
+function extractVersionsFromChangelog(): Version[] {
+const changelogPath = join(process.cwd(), '..', 'CHANGELOG.md');
+const content = readFileSync(changelogPath, 'utf-8');
+const versionRegex = /^## ([0-9]+\.[0-9]+\.[0-9]+)/gm;
+const versions: Version[] = [];
+let match;
+
+while ((match = versionRegex.exec(content)) !== null) {
+const tag = match[1];
+versions.push({
+tag,
+ref: getGitRef(tag)
+});
+}
+
+return versions;
+}
+
+function extractPRsFromChangelog(startTag: string, endTag: string): number[] {
+const changelogPath = join(process.cwd(), '..', 'CHANGELOG.md');
+const content = readFileSync(changelogPath, 'utf-8');
+const lines = content.split('\n');
+let inRange = false;
+const prs: number[] = [];
+
+for (const line of lines) {
+if (line.startsWith(`## ${startTag}`)) {
+inRange = true;
+continue;
+}
+if (inRange && line.startsWith(`## ${endTag}`)) {
+break;
+}
+if (inRange) {
+const match = line.match(/#(\d+)/);
+if (match) {
+prs.push(parseInt(match[1], 10));
+}
+}
+}
+
+return prs.sort((a, b) => a - b);
+}
+
+
+function shouldIgnoreCommitMessage(message: string): boolean {
+// Extract the commit message part (remove the commit hash)
+const messagePart = message.split(' ').slice(1).join(' ');
+
+// Check if the message starts with any of the ignored types
+for (const type of IGNORE_TYPES) {
+// Check simple format: "type: message"
+if (messagePart.startsWith(`${type}:`)) {
+return true;
+}
+// Check format with scope: "type(scope): message"
+if (messagePart.startsWith(`${type}(`)) {
+const closingBracketIndex = messagePart.indexOf('):');
+if (closingBracketIndex !== -1) {
+return true;
+}
+}
+}
+return false;
+}
+
+function extractPRsFromGitLog(oldRef: string, newRef: string): PR[] {
+const log = execSync(`git log ${oldRef}..${newRef} --oneline`, { encoding: 
'utf-8' });
+const prs: PR[] = [];
+
+for (const line of log.split('\n')) {
+if (!line.trim()) continue;
+
+// Check if this commit should be ignored
+if (shouldIgnoreCommitMessage(line)) continue;
+
+// Find PR number
+const prMatch = line.match(/#(\d+)/);
+if (prMatch) {
+const prNumber = parseInt(prMatch[1], 10);
+if (!IGNORE_PRS.includes(prNumber)) {
+prs.push({
+number: prNumber,
+title: line,
+commit: line.split(' ')[0]
+});
+}
+}
+}
+
+return prs.sort((a, b) => a.number - b.number);
+}
+
+function findMissingPRs(changelogPRs: number[], gitPRs: PR[]): PR[] {
+const changelogPRSet = new Set(changelogPRs);
+return gitPRs.filter(pr => !changelogPRSet.has(pr.number));
+}

Re: [PR] ci: add GitHub Action to check CHANGELOG consistency with PRs [apisix]

2025-06-19 Thread via GitHub


LiteSun commented on code in PR #12347:
URL: https://github.com/apache/apisix/pull/12347#discussion_r2157832729


##
ci/check_changelog_prs.ts:
##


Review Comment:
   > In practice, you can try some AST parsing tools to ensure the content you 
obtain is accurate.
   
   Actually, our changelog currently has a simple and consistent format. The 
existing code is also straightforward and effective, so there’s no need to use 
an AST parsing tool for now — it would be overkill. I also prefer not to 
introduce additional dependencies, as I’d like to keep the script as simple as 
possible.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] ci: add GitHub Action to check CHANGELOG consistency with PRs [apisix]

2025-06-19 Thread via GitHub


SkyeYoung commented on code in PR #12347:
URL: https://github.com/apache/apisix/pull/12347#discussion_r2156331896


##
ci/check_changelog_prs.ts:
##
@@ -0,0 +1,235 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { execSync } from 'child_process';
+import { readFileSync } from 'fs';
+import { join } from 'path';
+
+// Types
+interface Version {
+tag: string;
+ref: string;
+}
+
+interface PR {
+number: number;
+title: string;
+commit: string;
+}
+
+// Configuration
+const IGNORE_TYPES = [
+'docs',
+'chore',
+'test',
+'ci'
+];
+
+const IGNORE_PRS = [
+// 3.9.0
+10655, 10857, 10858, 10887, 10959, 11029, 11041, 11053, 11055, 11061, 
10976, 10984, 11025,
+// 3.10.0
+11105, 11128, 11169, 11171, 11280, 11333, 11081, 11202, 11469,
+// 3.11.0
+11463, 11570,
+// 3.12.0
+11769, 11816, 11881, 11905, 11924, 11926, 11973, 11991, 11992, 11829
+];
+
+
+function getGitRef(version: string): string {
+try {
+execSync(`git rev-parse ${version}`, { stdio: 'ignore' });
+return version;
+} catch {
+return 'HEAD';
+}
+}
+
+function extractVersionsFromChangelog(): Version[] {
+const changelogPath = join(process.cwd(), '..', 'CHANGELOG.md');
+const content = readFileSync(changelogPath, 'utf-8');
+const versionRegex = /^## ([0-9]+\.[0-9]+\.[0-9]+)/gm;
+const versions: Version[] = [];
+let match;
+
+while ((match = versionRegex.exec(content)) !== null) {
+const tag = match[1];
+versions.push({
+tag,
+ref: getGitRef(tag)
+});
+}
+
+return versions;
+}
+
+function extractPRsFromChangelog(startTag: string, endTag: string): number[] {
+const changelogPath = join(process.cwd(), '..', 'CHANGELOG.md');
+const content = readFileSync(changelogPath, 'utf-8');
+const lines = content.split('\n');
+let inRange = false;
+const prs: number[] = [];
+
+for (const line of lines) {
+if (line.startsWith(`## ${startTag}`)) {
+inRange = true;
+continue;
+}
+if (inRange && line.startsWith(`## ${endTag}`)) {
+break;
+}
+if (inRange) {
+const match = line.match(/#(\d+)/);
+if (match) {
+prs.push(parseInt(match[1], 10));
+}
+}
+}
+
+return prs.sort((a, b) => a - b);
+}
+
+
+function shouldIgnoreCommitMessage(message: string): boolean {
+// Extract the commit message part (remove the commit hash)
+const messagePart = message.split(' ').slice(1).join(' ');
+
+// Check if the message starts with any of the ignored types
+for (const type of IGNORE_TYPES) {
+// Check simple format: "type: message"
+if (messagePart.startsWith(`${type}:`)) {
+return true;
+}
+// Check format with scope: "type(scope): message"
+if (messagePart.startsWith(`${type}(`)) {
+const closingBracketIndex = messagePart.indexOf('):');
+if (closingBracketIndex !== -1) {
+return true;
+}
+}
+}
+return false;
+}
+
+function extractPRsFromGitLog(oldRef: string, newRef: string): PR[] {
+const log = execSync(`git log ${oldRef}..${newRef} --oneline`, { encoding: 
'utf-8' });
+const prs: PR[] = [];
+
+for (const line of log.split('\n')) {
+if (!line.trim()) continue;
+
+// Check if this commit should be ignored
+if (shouldIgnoreCommitMessage(line)) continue;
+
+// Find PR number
+const prMatch = line.match(/#(\d+)/);
+if (prMatch) {
+const prNumber = parseInt(prMatch[1], 10);
+if (!IGNORE_PRS.includes(prNumber)) {
+prs.push({
+number: prNumber,
+title: line,
+commit: line.split(' ')[0]
+});
+}
+}
+}
+
+return prs.sort((a, b) => a.number - b.number);
+}
+
+function findMissingPRs(changelogPRs: number[], gitPRs: PR[]): PR[] {
+const changelogPRSet = new Set(changelogPRs);
+return gitPRs.filter(pr => !changelogPRSet.has(pr.number));
+

Re: [PR] ci: add GitHub Action to check CHANGELOG consistency with PRs [apisix]

2025-06-19 Thread via GitHub


SkyeYoung commented on code in PR #12347:
URL: https://github.com/apache/apisix/pull/12347#discussion_r2156330913


##
ci/check_changelog_prs.ts:
##


Review Comment:
   In practice, you can try some AST parsing tools to ensure the content you 
obtain is accurate.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] ci: add GitHub Action to check CHANGELOG consistency with PRs [apisix]

2025-06-18 Thread via GitHub


LiteSun commented on code in PR #12347:
URL: https://github.com/apache/apisix/pull/12347#discussion_r2153980408


##
ci/check_changelog_prs.ts:
##
@@ -0,0 +1,235 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { execSync } from 'child_process';
+import { readFileSync } from 'fs';
+import { join } from 'path';
+
+// Types
+interface Version {
+tag: string;
+ref: string;
+}
+
+interface PR {
+number: number;
+title: string;
+commit: string;
+}
+
+// Configuration
+const IGNORE_TYPES = [
+'docs',
+'chore',
+'test',
+'ci'
+];
+
+const IGNORE_PRS = [

Review Comment:
   refer: https://github.com/apache/apisix/pull/12308#issue-3132286015



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]