From ba0314e164eacc8030cc54b3373e32813ac760db Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Tue, 16 Sep 2025 17:58:05 +0000 Subject: [PATCH 01/17] Add pull request title validation --- .github/workflows/semantic-pr.yml | 58 +++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/semantic-pr.yml diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml new file mode 100644 index 00000000..93cc7184 --- /dev/null +++ b/.github/workflows/semantic-pr.yml @@ -0,0 +1,58 @@ +# Linter to enforce semantic pull request titles (see https://www.conventionalcommits.org/) +--- +name: 🔍 Semantic PR + +on: + pull_request: + branches: + - main + types: + - opened + - edited + - synchronize + - reopened + - ready_for_review + +permissions: + pull-requests: read + issues: write + +jobs: + check_pr_title: + name: Check Pull Request Title + runs-on: ubuntu-latest + steps: + - name: Run Semantic PR Validation + id: validation + uses: actions/github-script@v6 + with: + script: | + const prTitle = github.event.pull_request.title; + const regex = /^(feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert)(\([^)]+\))?(!?): .+/; + + if (!regex.test(prTitle)) { + core.setFailed('Pull request title does not follow Conventional Commits specification.'); + } + - name: Handle Invalid Title + if: failure() + uses: actions/github-script@v6 + with: + script: | + const message = `Hey there and thank you for opening this pull request! 👋🏼 + + We require pull request titles to follow the [Conventional Commits](https://www.conventionalcommits.org/) specification and it looks like your proposed title needs to be adjusted.`; + const invalidLabel = 'invalid'; + + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: message + }); + + await github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: [invalidLabel] + }); \ No newline at end of file From 7d464d26331eff1b27177ff6037867e40105c6d1 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Tue, 16 Sep 2025 18:24:50 +0000 Subject: [PATCH 02/17] Fix workflow failure --- .github/workflows/semantic-pr.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml index 93cc7184..3583eb0c 100644 --- a/.github/workflows/semantic-pr.yml +++ b/.github/workflows/semantic-pr.yml @@ -14,8 +14,7 @@ on: - ready_for_review permissions: - pull-requests: read - issues: write + pull-requests: write jobs: check_pr_title: @@ -27,7 +26,7 @@ jobs: uses: actions/github-script@v6 with: script: | - const prTitle = github.event.pull_request.title; + const prTitle = github.context.payload.pull_request.title; const regex = /^(feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert)(\([^)]+\))?(!?): .+/; if (!regex.test(prTitle)) { From 84dae64134c2355a9ffaea6c318ebb677de1510c Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Wed, 17 Sep 2025 09:02:22 +0000 Subject: [PATCH 03/17] Fix workflow script --- .github/workflows/semantic-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml index 3583eb0c..4e79054b 100644 --- a/.github/workflows/semantic-pr.yml +++ b/.github/workflows/semantic-pr.yml @@ -26,7 +26,7 @@ jobs: uses: actions/github-script@v6 with: script: | - const prTitle = github.context.payload.pull_request.title; + const prTitle = context.payload.pull_request.title; const regex = /^(feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert)(\([^)]+\))?(!?): .+/; if (!regex.test(prTitle)) { From 12b7572f7683a4cb8944ae3ef7bad671a74cefcc Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Wed, 17 Sep 2025 09:12:31 +0000 Subject: [PATCH 04/17] Enrich the comment --- .github/workflows/semantic-pr.yml | 33 ++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml index 4e79054b..e2e67432 100644 --- a/.github/workflows/semantic-pr.yml +++ b/.github/workflows/semantic-pr.yml @@ -30,16 +30,43 @@ jobs: const regex = /^(feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert)(\([^)]+\))?(!?): .+/; if (!regex.test(prTitle)) { - core.setFailed('Pull request title does not follow Conventional Commits specification.'); + core.setFailed('Pull request title does not follow Conventional Commits specification. See PR comment for details.'); } - name: Handle Invalid Title if: failure() uses: actions/github-script@v6 with: script: | - const message = `Hey there and thank you for opening this pull request! 👋🏼 + const message = `Hey there and thank you for your contribution! 👋🏼 + + We require pull request titles to follow the [Conventional Commits](https://www.conventionalcommits.org/) specification and it looks like your proposed title needs to be adjusted. + + A valid title has the format: \`type(scope): subject\` + + **type**: Must be one of the following: + - \`feat\`: A new feature + - \`fix\`: A bug fix + - \`docs\`: Documentation only changes + - \`style\`: Changes that do not affect the meaning of the code (e.g., formatting) + - \`refactor\`: A code change that neither fixes a bug nor adds a feature + - \`perf\`: A code change that improves performance + - \`test\`: Adding missing tests or correcting existing tests + - \`chore\`: Changes to the build process or auxiliary tools + - \`build\`: Changes that affect the build system or external dependencies + - \`ci\`: Changes to CI configuration files and scripts + - \`revert\`: Reverts a previous commit + + **scope** (optional): A noun describing a section of the codebase. + + **subject**: A short description of the code changes. + + Examples: + - \`feat(api): add new endpoint for users\` + - \`fix: correct a typo in the documentation\` + - \`docs(readme): update installation instructions\` + + Please update your pull request title to match this format.`; - We require pull request titles to follow the [Conventional Commits](https://www.conventionalcommits.org/) specification and it looks like your proposed title needs to be adjusted.`; const invalidLabel = 'invalid'; await github.rest.issues.createComment({ From 11adfddce48c853d5837c3cc4cfcbc39c6ea5c59 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Wed, 17 Sep 2025 09:48:04 +0000 Subject: [PATCH 05/17] Enhance worklfow --- .github/workflows/semantic-pr.yml | 68 ++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml index e2e67432..390a5017 100644 --- a/.github/workflows/semantic-pr.yml +++ b/.github/workflows/semantic-pr.yml @@ -32,12 +32,32 @@ jobs: if (!regex.test(prTitle)) { core.setFailed('Pull request title does not follow Conventional Commits specification. See PR comment for details.'); } + - name: Find Previous Comment + if: always() + id: find_comment + uses: actions/github-script@v6 + with: + script: | + const commentMarker = ''; + + const { data: comments } = await github.rest.issues.listComments({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + }); + + const existingComment = comments.find(comment => comment.body.includes(commentMarker)); + + if (existingComment) { + core.setOutput('comment_id', existingComment.id); + } - name: Handle Invalid Title if: failure() uses: actions/github-script@v6 with: script: | - const message = `Hey there and thank you for your contribution! 👋🏼 + const message = ` + Hey there and thank you for your contribution! 👋🏼 We require pull request titles to follow the [Conventional Commits](https://www.conventionalcommits.org/) specification and it looks like your proposed title needs to be adjusted. @@ -68,6 +88,15 @@ jobs: Please update your pull request title to match this format.`; const invalidLabel = 'invalid'; + const commentId = '${{ steps.find_comment.outputs.comment_id }}'; + + if (commentId) { + await github.rest.issues.deleteComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: commentId, + }); + } await github.rest.issues.createComment({ issue_number: context.issue.number, @@ -81,4 +110,39 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, labels: [invalidLabel] - }); \ No newline at end of file + }); + - name: Handle Valid Title + if: success() + uses: actions/github-script@v6 + with: + script: | + const invalidLabel = 'invalid'; + const commentId = '${{ steps.find_comment.outputs.comment_id }}'; + + if (commentId) { + const { data: comment } = await github.rest.issues.getComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: commentId, + }); + + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: commentId, + body: `**UPDATE:** The pull request title has been corrected. ✅\n\n${comment.body}` + }); + } + + try { + await github.rest.issues.removeLabel({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + name: invalidLabel, + }); + } catch (error) { + if (error.status !== 404) { + throw error; + } + } \ No newline at end of file From 24c558bb8a1a24922ca7ad45c5af92edca1cc7af Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Wed, 17 Sep 2025 09:55:36 +0000 Subject: [PATCH 06/17] Add logs --- .github/workflows/semantic-pr.yml | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml index 390a5017..d16cfdf9 100644 --- a/.github/workflows/semantic-pr.yml +++ b/.github/workflows/semantic-pr.yml @@ -45,9 +45,10 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, }); - + console.log('>>>>> comments', comments); const existingComment = comments.find(comment => comment.body.includes(commentMarker)); + console.log('>>>>> existingComment', existingComment); if (existingComment) { core.setOutput('comment_id', existingComment.id); } @@ -89,7 +90,7 @@ jobs: const invalidLabel = 'invalid'; const commentId = '${{ steps.find_comment.outputs.comment_id }}'; - + console.log('>>>>> commentId', commentId); if (commentId) { await github.rest.issues.deleteComment({ owner: context.repo.owner, @@ -118,22 +119,7 @@ jobs: script: | const invalidLabel = 'invalid'; const commentId = '${{ steps.find_comment.outputs.comment_id }}'; - - if (commentId) { - const { data: comment } = await github.rest.issues.getComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: commentId, - }); - - await github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: commentId, - body: `**UPDATE:** The pull request title has been corrected. ✅\n\n${comment.body}` - }); - } - + console.log('>>>>> commentId', commentId); try { await github.rest.issues.removeLabel({ issue_number: context.issue.number, From 4e79f268546695e3cacc82333499eea6124168d3 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Wed, 17 Sep 2025 10:08:16 +0000 Subject: [PATCH 07/17] Enhance workflow --- .github/workflows/semantic-pr.yml | 41 +++++++++---------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml index d16cfdf9..7f887cf4 100644 --- a/.github/workflows/semantic-pr.yml +++ b/.github/workflows/semantic-pr.yml @@ -32,9 +32,8 @@ jobs: if (!regex.test(prTitle)) { core.setFailed('Pull request title does not follow Conventional Commits specification. See PR comment for details.'); } - - name: Find Previous Comment - if: always() - id: find_comment + - name: Handle Invalid Title + if: failure() uses: actions/github-script@v6 with: script: | @@ -45,18 +44,16 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, }); - console.log('>>>>> comments', comments); - const existingComment = comments.find(comment => comment.body.includes(commentMarker)); - console.log('>>>>> existingComment', existingComment); - if (existingComment) { - core.setOutput('comment_id', existingComment.id); + const existingComment = comments.find(comment => comment.body.includes(commentMarker)); + if (existingComment?.id) { + await github.rest.issues.deleteComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existingComment.id, + }); } - - name: Handle Invalid Title - if: failure() - uses: actions/github-script@v6 - with: - script: | + const message = ` Hey there and thank you for your contribution! 👋🏼 @@ -88,17 +85,6 @@ jobs: Please update your pull request title to match this format.`; - const invalidLabel = 'invalid'; - const commentId = '${{ steps.find_comment.outputs.comment_id }}'; - console.log('>>>>> commentId', commentId); - if (commentId) { - await github.rest.issues.deleteComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: commentId, - }); - } - await github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, @@ -110,22 +96,19 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - labels: [invalidLabel] + labels: ['invalid'] }); - name: Handle Valid Title if: success() uses: actions/github-script@v6 with: script: | - const invalidLabel = 'invalid'; - const commentId = '${{ steps.find_comment.outputs.comment_id }}'; - console.log('>>>>> commentId', commentId); try { await github.rest.issues.removeLabel({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - name: invalidLabel, + name: 'invalid', }); } catch (error) { if (error.status !== 404) { From 422e7d17055784f7531530d99e7171fc725504b8 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Wed, 17 Sep 2025 10:15:34 +0000 Subject: [PATCH 08/17] Delete comment if fixed --- .github/workflows/semantic-pr.yml | 84 ++++++++++++++++++------------- 1 file changed, 48 insertions(+), 36 deletions(-) diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml index 7f887cf4..9f083550 100644 --- a/.github/workflows/semantic-pr.yml +++ b/.github/workflows/semantic-pr.yml @@ -46,51 +46,46 @@ jobs: }); const existingComment = comments.find(comment => comment.body.includes(commentMarker)); - if (existingComment?.id) { - await github.rest.issues.deleteComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: existingComment.id, - }); - } - const message = ` - Hey there and thank you for your contribution! 👋🏼 + if (!existingComment) { + const message = ` + Hey there and thank you for your contribution! 👋🏼 - We require pull request titles to follow the [Conventional Commits](https://www.conventionalcommits.org/) specification and it looks like your proposed title needs to be adjusted. + We require pull request titles to follow the [Conventional Commits](https://www.conventionalcommits.org/) specification and it looks like your proposed title needs to be adjusted. - A valid title has the format: \`type(scope): subject\` + A valid title has the format: \`type(scope): subject\` - **type**: Must be one of the following: - - \`feat\`: A new feature - - \`fix\`: A bug fix - - \`docs\`: Documentation only changes - - \`style\`: Changes that do not affect the meaning of the code (e.g., formatting) - - \`refactor\`: A code change that neither fixes a bug nor adds a feature - - \`perf\`: A code change that improves performance - - \`test\`: Adding missing tests or correcting existing tests - - \`chore\`: Changes to the build process or auxiliary tools - - \`build\`: Changes that affect the build system or external dependencies - - \`ci\`: Changes to CI configuration files and scripts - - \`revert\`: Reverts a previous commit + **type**: Must be one of the following: + - \`feat\`: A new feature + - \`fix\`: A bug fix + - \`docs\`: Documentation only changes + - \`style\`: Changes that do not affect the meaning of the code (e.g., formatting) + - \`refactor\`: A code change that neither fixes a bug nor adds a feature + - \`perf\`: A code change that improves performance + - \`test\`: Adding missing tests or correcting existing tests + - \`chore\`: Changes to the build process or auxiliary tools + - \`build\`: Changes that affect the build system or external dependencies + - \`ci\`: Changes to CI configuration files and scripts + - \`revert\`: Reverts a previous commit - **scope** (optional): A noun describing a section of the codebase. + **scope** (optional): A noun describing a section of the codebase. - **subject**: A short description of the code changes. + **subject**: A short description of the code changes. - Examples: - - \`feat(api): add new endpoint for users\` - - \`fix: correct a typo in the documentation\` - - \`docs(readme): update installation instructions\` + Examples: + - \`feat(api): add new endpoint for users\` + - \`fix: correct a typo in the documentation\` + - \`docs(readme): update installation instructions\` - Please update your pull request title to match this format.`; + Please update your pull request title to match this format.`; - await github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: message - }); + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: message + }); + } await github.rest.issues.addLabels({ issue_number: context.issue.number, @@ -103,6 +98,23 @@ jobs: uses: actions/github-script@v6 with: script: | + const commentMarker = ''; + + const { data: comments } = await github.rest.issues.listComments({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + }); + + const existingComment = comments.find(comment => comment.body.includes(commentMarker)); + if (existingComment?.id) { + await github.rest.issues.deleteComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existingComment.id, + }); + } + try { await github.rest.issues.removeLabel({ issue_number: context.issue.number, From 73d29f727893da8976aeb656ea3efa7e89bb4de8 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Wed, 17 Sep 2025 10:18:00 +0000 Subject: [PATCH 09/17] Remove synchronize type --- .github/workflows/semantic-pr.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml index 9f083550..2c47da54 100644 --- a/.github/workflows/semantic-pr.yml +++ b/.github/workflows/semantic-pr.yml @@ -9,7 +9,6 @@ on: types: - opened - edited - - synchronize - reopened - ready_for_review From 94fd89c4a561f78a48778615a55f535fef3f8f65 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Wed, 17 Sep 2025 10:23:59 +0000 Subject: [PATCH 10/17] Fix comment text --- .github/workflows/semantic-pr.yml | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml index 2c47da54..a39237c7 100644 --- a/.github/workflows/semantic-pr.yml +++ b/.github/workflows/semantic-pr.yml @@ -48,6 +48,7 @@ jobs: if (!existingComment) { const message = ` + Hey there and thank you for your contribution! 👋🏼 We require pull request titles to follow the [Conventional Commits](https://www.conventionalcommits.org/) specification and it looks like your proposed title needs to be adjusted. @@ -55,26 +56,26 @@ jobs: A valid title has the format: \`type(scope): subject\` **type**: Must be one of the following: - - \`feat\`: A new feature - - \`fix\`: A bug fix - - \`docs\`: Documentation only changes - - \`style\`: Changes that do not affect the meaning of the code (e.g., formatting) - - \`refactor\`: A code change that neither fixes a bug nor adds a feature - - \`perf\`: A code change that improves performance - - \`test\`: Adding missing tests or correcting existing tests - - \`chore\`: Changes to the build process or auxiliary tools - - \`build\`: Changes that affect the build system or external dependencies - - \`ci\`: Changes to CI configuration files and scripts - - \`revert\`: Reverts a previous commit + - \`feat\`: A new feature + - \`fix\`: A bug fix + - \`docs\`: Documentation only changes + - \`style\`: Changes that do not affect the meaning of the code (e.g., formatting) + - \`refactor\`: A code change that neither fixes a bug nor adds a feature + - \`perf\`: A code change that improves performance + - \`test\`: Adding missing tests or correcting existing tests + - \`chore\`: Changes to the build process or auxiliary tools + - \`build\`: Changes that affect the build system or external dependencies + - \`ci\`: Changes to CI configuration files and scripts + - \`revert\`: Reverts a previous commit **scope** (optional): A noun describing a section of the codebase. **subject**: A short description of the code changes. Examples: - - \`feat(api): add new endpoint for users\` - - \`fix: correct a typo in the documentation\` - - \`docs(readme): update installation instructions\` + - \`feat(api): add new endpoint for users\` + - \`fix: correct a typo in the documentation\` + - \`docs(readme): update installation instructions\` Please update your pull request title to match this format.`; From 65798b205dc20c2dada3710ebb4a9e11da8dcab5 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Wed, 17 Sep 2025 10:27:46 +0000 Subject: [PATCH 11/17] Fix text --- .github/workflows/fab-build.yml | 5 ++++ .github/workflows/semantic-pr.yml | 44 +++++++++++++++---------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/.github/workflows/fab-build.yml b/.github/workflows/fab-build.yml index e24452cd..ee45ffbc 100644 --- a/.github/workflows/fab-build.yml +++ b/.github/workflows/fab-build.yml @@ -4,6 +4,11 @@ on: pull_request: branches: - main + types: + - opened + - reopened + - synchronize + - ready_for_review permissions: contents: read diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml index a39237c7..982d2410 100644 --- a/.github/workflows/semantic-pr.yml +++ b/.github/workflows/semantic-pr.yml @@ -49,35 +49,35 @@ jobs: if (!existingComment) { const message = ` - Hey there and thank you for your contribution! 👋🏼 + Hey there and thank you for your contribution! 👋🏼 - We require pull request titles to follow the [Conventional Commits](https://www.conventionalcommits.org/) specification and it looks like your proposed title needs to be adjusted. + We require pull request titles to follow the [Conventional Commits](https://www.conventionalcommits.org/) specification and it looks like your proposed title needs to be adjusted. - A valid title has the format: \`type(scope): subject\` + A valid title has the format: \`type(scope): subject\` - **type**: Must be one of the following: - - \`feat\`: A new feature - - \`fix\`: A bug fix - - \`docs\`: Documentation only changes - - \`style\`: Changes that do not affect the meaning of the code (e.g., formatting) - - \`refactor\`: A code change that neither fixes a bug nor adds a feature - - \`perf\`: A code change that improves performance - - \`test\`: Adding missing tests or correcting existing tests - - \`chore\`: Changes to the build process or auxiliary tools - - \`build\`: Changes that affect the build system or external dependencies - - \`ci\`: Changes to CI configuration files and scripts - - \`revert\`: Reverts a previous commit + **type**: Must be one of the following: + - \`feat\`: A new feature + - \`fix\`: A bug fix + - \`docs\`: Documentation only changes + - \`style\`: Changes that do not affect the meaning of the code (e.g., formatting) + - \`refactor\`: A code change that neither fixes a bug nor adds a feature + - \`perf\`: A code change that improves performance + - \`test\`: Adding missing tests or correcting existing tests + - \`chore\`: Changes to the build process or auxiliary tools + - \`build\`: Changes that affect the build system or external dependencies + - \`ci\`: Changes to CI configuration files and scripts + - \`revert\`: Reverts a previous commit - **scope** (optional): A noun describing a section of the codebase. + **scope** (optional): A noun describing a section of the codebase. - **subject**: A short description of the code changes. + **subject**: A short description of the code changes. - Examples: - - \`feat(api): add new endpoint for users\` - - \`fix: correct a typo in the documentation\` - - \`docs(readme): update installation instructions\` + Examples: + - \`feat(api): add new endpoint for users\` + - \`fix: correct a typo in the documentation\` + - \`docs(readme): update installation instructions\` - Please update your pull request title to match this format.`; + Please update your pull request title to match this format.`; await github.rest.issues.createComment({ issue_number: context.issue.number, From 30b0cd4de234de89b66e2250217863264f72495a Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Wed, 17 Sep 2025 10:35:20 +0000 Subject: [PATCH 12/17] Remove deletion --- .github/workflows/semantic-pr.yml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml index 982d2410..4b8359a9 100644 --- a/.github/workflows/semantic-pr.yml +++ b/.github/workflows/semantic-pr.yml @@ -98,23 +98,6 @@ jobs: uses: actions/github-script@v6 with: script: | - const commentMarker = ''; - - const { data: comments } = await github.rest.issues.listComments({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - }); - - const existingComment = comments.find(comment => comment.body.includes(commentMarker)); - if (existingComment?.id) { - await github.rest.issues.deleteComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: existingComment.id, - }); - } - try { await github.rest.issues.removeLabel({ issue_number: context.issue.number, From 7923bcee449336fcede5426e12fd5731f1628ec0 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Wed, 17 Sep 2025 11:13:52 +0000 Subject: [PATCH 13/17] Test new workflows --- .github/workflows/build.yml | 39 +++++++++ .github/workflows/fab-build.yml | 142 ------------------------------- .github/workflows/lint.yml | 42 +++++++++ .github/workflows/test.yml | 59 +++++++++++++ .github/workflows/type-check.yml | 42 +++++++++ 5 files changed, 182 insertions(+), 142 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/fab-build.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/test.yml create mode 100644 .github/workflows/type-check.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..2b07bfcd --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,39 @@ +name: Build CLI Package Validation + +on: + pull_request: + branches: + - main + types: + - opened + - reopened + - synchronize + - ready_for_review + +permissions: + contents: read + +jobs: + build: + name: Build Package + runs-on: ubuntu-latest + needs: + - test # Ensure all test jobs complete successfully + steps: + - uses: actions/checkout@v3 + + - name: Set up Python 3.12 + uses: actions/setup-python@v4 + with: + python-version: "3.12" + + - name: Create and activate Virtual Environment + run: | + python -m venv venv + source venv/bin/activate + pip install -r requirements.txt + + - name: Validate build package + run: | + source venv/bin/activate + python -m build \ No newline at end of file diff --git a/.github/workflows/fab-build.yml b/.github/workflows/fab-build.yml deleted file mode 100644 index ee45ffbc..00000000 --- a/.github/workflows/fab-build.yml +++ /dev/null @@ -1,142 +0,0 @@ -name: fab:build - -on: - pull_request: - branches: - - main - types: - - opened - - reopened - - synchronize - - ready_for_review - -permissions: - contents: read - -jobs: - # Linting Job - lint: - name: Lint Code - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up Python 3.12 - uses: actions/setup-python@v4 - with: - python-version: "3.12" # Use any stable Python version for linting - - - name: Install Tox - run: | - python -m pip install --upgrade pip - pip install tox - - - name: Cache Tox environments - uses: actions/cache@v3 - with: - path: .tox - key: ${{ runner.os }}-tox-lint-${{ hashFiles('**/tox.toml') }} - restore-keys: | - ${{ runner.os }}-tox-lint- - - - name: Run Linting - run: tox -e lint - - - # Type Checking Job - type-check: - name: Type Check Code - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up Python 3.12 - uses: actions/setup-python@v4 - with: - python-version: "3.12" # Use any stable Python version for type checking - - - name: Install Tox - run: | - python -m pip install --upgrade pip - pip install tox - - - name: Cache Tox environments - uses: actions/cache@v3 - with: - path: .tox - key: ${{ runner.os }}-tox-type-${{ hashFiles('**/tox.toml') }} - restore-keys: | - ${{ runner.os }}-tox-type- - - - name: Run Type Checks - run: tox -e type - - # Testing Jobs with Matrix Strategy - test: - name: Test on Python ${{ matrix.python-version }} - runs-on: ubuntu-latest - strategy: - matrix: - include: - - python-version: "3.10" - tox-env: "py310" - - python-version: "3.11" - tox-env: "py311" - - python-version: "3.12" - tox-env: "py312" - steps: - - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install Tox - run: | - python -m pip install --upgrade pip - pip install tox - - - name: Cache Tox environments - uses: actions/cache@v3 - with: - path: .tox - key: ${{ runner.os }}-tox-${{ matrix.tox-env }}-${{ hashFiles('**/tox.toml') }} - restore-keys: | - ${{ runner.os }}-tox-${{ matrix.tox-env }}- - ${{ runner.os }}-tox- - - - name: Run Tests - run: tox -e ${{ matrix.tox-env }} - - # Upload the coverage report as an artifact - - name: Upload coverage artifact - uses: actions/upload-artifact@v4 - with: - name: coverage-html-report-${{ matrix.python-version }} - path: coverage_html - - # Build Job - build: - name: Build Package - runs-on: ubuntu-latest - needs: - - test # Ensure all test jobs complete successfully - steps: - - uses: actions/checkout@v3 - - - name: Set up Python 3.12 - uses: actions/setup-python@v4 - with: - python-version: "3.12" - - - name: Create and activate Virtual Environment - run: | - python -m venv venv - source venv/bin/activate - pip install -r requirements.txt - - - name: Build package - run: | - source venv/bin/activate - python -m build diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..19c2e379 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,42 @@ +name: Lint Code + +on: + pull_request: + branches: + - main + types: + - opened + - reopened + - synchronize + - ready_for_review + +permissions: + contents: read + +jobs: + lint: + name: Lint Code + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Python 3.12 + uses: actions/setup-python@v4 + with: + python-version: "3.12" # Use any stable Python version for linting + + - name: Install Tox + run: | + python -m pip install --upgrade pip + pip install tox + + - name: Cache Tox environments + uses: actions/cache@v3 + with: + path: .tox + key: ${{ runner.os }}-tox-lint-${{ hashFiles('**/tox.toml') }} + restore-keys: | + ${{ runner.os }}-tox-lint- + + - name: Run Linting + run: tox -e lint \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..a494abc3 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,59 @@ +name: Run Tests + +on: + pull_request: + branches: + - main + types: + - opened + - reopened + - synchronize + - ready_for_review + +permissions: + contents: read + +jobs: + test: + name: Test on Python ${{ matrix.python-version }} + runs-on: ubuntu-latest + strategy: + matrix: + include: + - python-version: "3.10" + tox-env: "py310" + - python-version: "3.11" + tox-env: "py311" + - python-version: "3.12" + tox-env: "py312" + steps: + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Tox + run: | + python -m pip install --upgrade pip + pip install tox + + - name: Cache Tox environments + uses: actions/cache@v3 + with: + path: .tox + key: ${{ runner.os }}-tox-${{ matrix.tox-env }}-${{ hashFiles('**/tox.toml') }} + restore-keys: | + ${{ runner.os }}-tox-${{ matrix.tox-env }}- + ${{ runner.os }}-tox- + + - name: Run Tests + run: tox -e ${{ matrix.tox-env }} + + # Upload the coverage report as an artifact + - name: Upload coverage artifact + uses: actions/upload-artifact@v4 + with: + name: coverage-html-report-${{ matrix.python-version }} + path: coverage_html \ No newline at end of file diff --git a/.github/workflows/type-check.yml b/.github/workflows/type-check.yml new file mode 100644 index 00000000..429af648 --- /dev/null +++ b/.github/workflows/type-check.yml @@ -0,0 +1,42 @@ +name: Type Check Code + +on: + pull_request: + branches: + - main + types: + - opened + - reopened + - synchronize + - ready_for_review + +permissions: + contents: read + +jobs: + type-check: + name: Run Type Check Code + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Python 3.12 + uses: actions/setup-python@v4 + with: + python-version: "3.12" # Use any stable Python version for type checking + + - name: Install Tox + run: | + python -m pip install --upgrade pip + pip install tox + + - name: Cache Tox environments + uses: actions/cache@v3 + with: + path: .tox + key: ${{ runner.os }}-tox-type-${{ hashFiles('**/tox.toml') }} + restore-keys: | + ${{ runner.os }}-tox-type- + + - name: Run Type Checks + run: tox -e type \ No newline at end of file From 73bbf3367c27fee1b1ad02f7755c0419d854f0f5 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Wed, 17 Sep 2025 11:24:25 +0000 Subject: [PATCH 14/17] update pemrissions --- .github/workflows/semantic-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml index 4b8359a9..5cf2c29a 100644 --- a/.github/workflows/semantic-pr.yml +++ b/.github/workflows/semantic-pr.yml @@ -13,7 +13,7 @@ on: - ready_for_review permissions: - pull-requests: write + issues: write jobs: check_pr_title: From 1775238d04e2e0566ba8fb7c140b5e8a8301b554 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Wed, 17 Sep 2025 11:32:55 +0000 Subject: [PATCH 15/17] fix --- .github/workflows/semantic-pr.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml index 5cf2c29a..3a798a8a 100644 --- a/.github/workflows/semantic-pr.yml +++ b/.github/workflows/semantic-pr.yml @@ -1,6 +1,6 @@ # Linter to enforce semantic pull request titles (see https://www.conventionalcommits.org/) --- -name: 🔍 Semantic PR +name: 🔍 Semantic PR Validation on: pull_request: @@ -13,7 +13,7 @@ on: - ready_for_review permissions: - issues: write + pull-requests: write jobs: check_pr_title: @@ -24,6 +24,7 @@ jobs: id: validation uses: actions/github-script@v6 with: + token: ${{ secrets.GITHUB_TOKEN }} script: | const prTitle = context.payload.pull_request.title; const regex = /^(feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert)(\([^)]+\))?(!?): .+/; @@ -35,6 +36,7 @@ jobs: if: failure() uses: actions/github-script@v6 with: + token: ${{ secrets.GITHUB_TOKEN }} script: | const commentMarker = ''; @@ -97,6 +99,7 @@ jobs: if: success() uses: actions/github-script@v6 with: + token: ${{ secrets.GITHUB_TOKEN }} script: | try { await github.rest.issues.removeLabel({ From dd6af1017950f8c45abe8482bd05e7922d8a2e45 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Wed, 17 Sep 2025 11:38:00 +0000 Subject: [PATCH 16/17] fix --- .github/workflows/semantic-pr.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml index 3a798a8a..3c3eda1e 100644 --- a/.github/workflows/semantic-pr.yml +++ b/.github/workflows/semantic-pr.yml @@ -24,7 +24,6 @@ jobs: id: validation uses: actions/github-script@v6 with: - token: ${{ secrets.GITHUB_TOKEN }} script: | const prTitle = context.payload.pull_request.title; const regex = /^(feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert)(\([^)]+\))?(!?): .+/; @@ -99,17 +98,20 @@ jobs: if: success() uses: actions/github-script@v6 with: - token: ${{ secrets.GITHUB_TOKEN }} script: | - try { + const { data: labels } = await github.rest.issues.listLabelsOnIssue({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + + const invalidLabel = labels.find(label => label.name === 'invalid'); + + if (invalidLabel) { await github.rest.issues.removeLabel({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, name: 'invalid', }); - } catch (error) { - if (error.status !== 404) { - throw error; - } } \ No newline at end of file From 4c76c0b6fd4e5e226903bfaf4155503648aab92e Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Wed, 17 Sep 2025 11:40:27 +0000 Subject: [PATCH 17/17] fx --- .github/workflows/semantic-pr.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml index 3c3eda1e..26b2dec0 100644 --- a/.github/workflows/semantic-pr.yml +++ b/.github/workflows/semantic-pr.yml @@ -35,7 +35,6 @@ jobs: if: failure() uses: actions/github-script@v6 with: - token: ${{ secrets.GITHUB_TOKEN }} script: | const commentMarker = '';