From 111550d261e6618d488bff6d450a502b4cc26744 Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Thu, 26 Sep 2024 08:56:36 -0700 Subject: [PATCH 01/12] Enable PR checklist workflow and update PR template --- .github/Pull_Request_template.md | 17 +++++--- .github/workflows/pr-checklist.yml | 69 ++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/pr-checklist.yml diff --git a/.github/Pull_Request_template.md b/.github/Pull_Request_template.md index de511c0a84..b4def2e1b8 100644 --- a/.github/Pull_Request_template.md +++ b/.github/Pull_Request_template.md @@ -1,12 +1,16 @@ -### Description +## Description _Add a comprehensive description of proposed changes_ -_List issue number(s) if exist(s): #6 (for example)_ +_List associated issue number(s) if exist(s): #6 (for example)_ + +_Documentation PR (if needed): #1340 (for example)_ + +_Benchmarks PR (if needed): https://github.com/IntelPython/scikit-learn_bench/pull/155 (for example)_ --- -Checklist to comply with before moving PR from draft: +Checklist to comply with **before moving PR from draft**: **PR completeness and readability** @@ -14,15 +18,18 @@ Checklist to comply with before moving PR from draft: - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation to reflect the changes or created a separate PR with update and provided its number in the description, if necessary. - [ ] Git commit message contains an appropriate signed-off-by string _(see [CONTRIBUTING.md](https://github.com/intel/scikit-learn-intelex/blob/main/CONTRIBUTING.md#pull-requests) for details)_. -- [ ] I have added a respective label(s) to PR if I have a permission for that. +- [ ] I have added a respective label(s) to PR if I have a permission for that. - [ ] I have resolved any merge conflicts that might occur with the base branch. **Testing** -- [ ] The unit tests pass successfully. - [ ] I have run it locally and tested the changes extensively. +- [ ] All CI jobs are green or I have provided justification why they aren't. +- [ ] I have extended testing suite if new functionality was introduced in this PR. **Performance** - [ ] I have measured performance for affected algorithms using [scikit-learn_bench](https://github.com/IntelPython/scikit-learn_bench) and provided at least summary table with measured data, if performance change is expected. - [ ] I have provided justification why performance has changed or why changes are not expected. +- [ ] I have provided justification why quality metrics have changed or why changes are not expected. +- [ ] I have extended benchmarking suite and provided corresponding scikit-learn_bench PR if new measurable functionality was introduced in this PR. diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml new file mode 100644 index 0000000000..db75d3c689 --- /dev/null +++ b/.github/workflows/pr-checklist.yml @@ -0,0 +1,69 @@ +#=============================================================================== +# Copyright 2024 Intel Corporation +# +# Licensed 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. +#=============================================================================== + +name: Check PR Checklist + +on: + pull_request: + types: [opened, edited, synchronize] + +jobs: + checklist: + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Get pull request details + id: pr + uses: actions/github-script@v7 + with: + script: | + const pr_desc = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number + }); + console.log(pr_desc); + console.log(pr_desc.data.body); + console.log(pr_desc.data.draft); + return { + body: pr_desc.data.body, + draft: pr_desc.data.draft + }; + - name: Check if PR is not draft + id: is-not-draft + run: | + if [ "${{ steps.pr.outputs.draft }}" = "true" ]; then + echo "PR is in draft state. Exiting." + exit 0 + fi + - name: Check if all checkboxes are checked + id: checkboxes + run: | + DESCRIPTION="${{ steps.pr.outputs.body }}" + UNCHECKED=$(echo "$DESCRIPTION" | grep -c '\[ \]') + echo "::set-output name=unchecked::$UNCHECKED" + - name: Move PR to draft if not all checkboxes are checked + if: steps.checkboxes.outputs.unchecked != '0' + uses: actions/github-script@v7 + with: + script: | + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + draft: true + }); From 2bc5e6101c48885192e60343a360a0df0ac2cb5c Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Thu, 26 Sep 2024 09:09:32 -0700 Subject: [PATCH 02/12] Add debug output --- .github/workflows/pr-checklist.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml index db75d3c689..bac457eff4 100644 --- a/.github/workflows/pr-checklist.yml +++ b/.github/workflows/pr-checklist.yml @@ -46,6 +46,7 @@ jobs: - name: Check if PR is not draft id: is-not-draft run: | + echo "${{ steps.pr.outputs }}" if [ "${{ steps.pr.outputs.draft }}" = "true" ]; then echo "PR is in draft state. Exiting." exit 0 From 08e3583a5a57808b1d2eef6aa91a135796412725 Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Thu, 26 Sep 2024 09:12:07 -0700 Subject: [PATCH 03/12] Change output set --- .github/workflows/pr-checklist.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml index bac457eff4..dc1c8ccd12 100644 --- a/.github/workflows/pr-checklist.yml +++ b/.github/workflows/pr-checklist.yml @@ -36,17 +36,13 @@ jobs: repo: context.repo.repo, pull_number: context.payload.pull_request.number }); - console.log(pr_desc); - console.log(pr_desc.data.body); - console.log(pr_desc.data.draft); - return { - body: pr_desc.data.body, - draft: pr_desc.data.draft - }; + core.setOutput('body', pr_desc.data.body) + core.setOutput('draft', pr_desc.data.draft) - name: Check if PR is not draft id: is-not-draft run: | - echo "${{ steps.pr.outputs }}" + echo "DRAFT: ${{ steps.pr.outputs.draft }}" + echo "BODY: ${{ steps.pr.outputs.body }}" if [ "${{ steps.pr.outputs.draft }}" = "true" ]; then echo "PR is in draft state. Exiting." exit 0 From f7ed9a0ad4b83a7aa67bc49477cfd173457aceed Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Thu, 26 Sep 2024 09:14:10 -0700 Subject: [PATCH 04/12] Remove debug, add PR permission --- .github/workflows/pr-checklist.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml index dc1c8ccd12..e6eeefe8ee 100644 --- a/.github/workflows/pr-checklist.yml +++ b/.github/workflows/pr-checklist.yml @@ -20,6 +20,9 @@ on: pull_request: types: [opened, edited, synchronize] +permissions: + pull-requests: write + jobs: checklist: runs-on: ubuntu-24.04 @@ -41,8 +44,6 @@ jobs: - name: Check if PR is not draft id: is-not-draft run: | - echo "DRAFT: ${{ steps.pr.outputs.draft }}" - echo "BODY: ${{ steps.pr.outputs.body }}" if [ "${{ steps.pr.outputs.draft }}" = "true" ]; then echo "PR is in draft state. Exiting." exit 0 From 6b68438c341e716943c1a8a2de25cddc4aa3ae9c Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Thu, 26 Sep 2024 09:18:37 -0700 Subject: [PATCH 05/12] Change unchecked number output --- .github/workflows/pr-checklist.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml index e6eeefe8ee..30fb8418a8 100644 --- a/.github/workflows/pr-checklist.yml +++ b/.github/workflows/pr-checklist.yml @@ -53,7 +53,8 @@ jobs: run: | DESCRIPTION="${{ steps.pr.outputs.body }}" UNCHECKED=$(echo "$DESCRIPTION" | grep -c '\[ \]') - echo "::set-output name=unchecked::$UNCHECKED" + echo "Unchecked checkboxes: $UNCHECKED" + echo "unchecked=$UNCHECKED" >> $GITHUB_STATE - name: Move PR to draft if not all checkboxes are checked if: steps.checkboxes.outputs.unchecked != '0' uses: actions/github-script@v7 From 7e86c5d17a0c4e7281237587a98bb22a51adda75 Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Thu, 26 Sep 2024 09:21:57 -0700 Subject: [PATCH 06/12] Fix github output --- .github/workflows/pr-checklist.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml index 30fb8418a8..0281a34731 100644 --- a/.github/workflows/pr-checklist.yml +++ b/.github/workflows/pr-checklist.yml @@ -54,7 +54,7 @@ jobs: DESCRIPTION="${{ steps.pr.outputs.body }}" UNCHECKED=$(echo "$DESCRIPTION" | grep -c '\[ \]') echo "Unchecked checkboxes: $UNCHECKED" - echo "unchecked=$UNCHECKED" >> $GITHUB_STATE + echo "unchecked=$UNCHECKED" >> $GITHUB_OUTPUT - name: Move PR to draft if not all checkboxes are checked if: steps.checkboxes.outputs.unchecked != '0' uses: actions/github-script@v7 From 39826ddb343186ffb45805ff6d64e8042db8def9 Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Thu, 26 Sep 2024 09:29:06 -0700 Subject: [PATCH 07/12] Extend permission --- .github/workflows/pr-checklist.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml index 0281a34731..c48fc47755 100644 --- a/.github/workflows/pr-checklist.yml +++ b/.github/workflows/pr-checklist.yml @@ -22,6 +22,7 @@ on: permissions: pull-requests: write + contents: write jobs: checklist: From cb91b96b850a8e1cf1aa2125435170aede26a0e5 Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Thu, 26 Sep 2024 09:34:51 -0700 Subject: [PATCH 08/12] Add token --- .github/workflows/pr-checklist.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml index c48fc47755..a2b858042d 100644 --- a/.github/workflows/pr-checklist.yml +++ b/.github/workflows/pr-checklist.yml @@ -59,6 +59,8 @@ jobs: - name: Move PR to draft if not all checkboxes are checked if: steps.checkboxes.outputs.unchecked != '0' uses: actions/github-script@v7 + env: + GITHUB_TOKEN: ${{ github.token }} with: script: | await github.rest.pulls.update({ From 606c44c57645e08c0346c1f1479a63e7cfb4284f Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Thu, 26 Sep 2024 09:48:30 -0700 Subject: [PATCH 09/12] Add failure of job instead of action --- .github/workflows/pr-checklist.yml | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml index a2b858042d..d0a719d1e8 100644 --- a/.github/workflows/pr-checklist.yml +++ b/.github/workflows/pr-checklist.yml @@ -20,10 +20,6 @@ on: pull_request: types: [opened, edited, synchronize] -permissions: - pull-requests: write - contents: write - jobs: checklist: runs-on: ubuntu-24.04 @@ -42,30 +38,14 @@ jobs: }); core.setOutput('body', pr_desc.data.body) core.setOutput('draft', pr_desc.data.draft) - - name: Check if PR is not draft - id: is-not-draft - run: | - if [ "${{ steps.pr.outputs.draft }}" = "true" ]; then - echo "PR is in draft state. Exiting." - exit 0 - fi - name: Check if all checkboxes are checked id: checkboxes run: | DESCRIPTION="${{ steps.pr.outputs.body }}" UNCHECKED=$(echo "$DESCRIPTION" | grep -c '\[ \]') - echo "Unchecked checkboxes: $UNCHECKED" echo "unchecked=$UNCHECKED" >> $GITHUB_OUTPUT - - name: Move PR to draft if not all checkboxes are checked - if: steps.checkboxes.outputs.unchecked != '0' - uses: actions/github-script@v7 - env: - GITHUB_TOKEN: ${{ github.token }} - with: - script: | - await github.rest.pulls.update({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.payload.pull_request.number, - draft: true - }); + - name: Fail if not all checkboxes are checked and PR is not draft + if: ${{ (steps.pr.outputs.draft == "false") && (steps.checkboxes.outputs.unchecked != '0') }} + run: | + echo "Unchecked checkboxes: ${{ steps.checkboxes.outputs.unchecked }}" + exit 1 From 747415dbb12ee2fce1ed366e3635083c529774a1 Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Thu, 26 Sep 2024 09:50:27 -0700 Subject: [PATCH 10/12] Change quotes in condition --- .github/workflows/pr-checklist.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml index d0a719d1e8..2cb1e94dd1 100644 --- a/.github/workflows/pr-checklist.yml +++ b/.github/workflows/pr-checklist.yml @@ -45,7 +45,7 @@ jobs: UNCHECKED=$(echo "$DESCRIPTION" | grep -c '\[ \]') echo "unchecked=$UNCHECKED" >> $GITHUB_OUTPUT - name: Fail if not all checkboxes are checked and PR is not draft - if: ${{ (steps.pr.outputs.draft == "false") && (steps.checkboxes.outputs.unchecked != '0') }} + if: ${{ (steps.pr.outputs.draft == 'false') && (steps.checkboxes.outputs.unchecked != '0') }} run: | echo "Unchecked checkboxes: ${{ steps.checkboxes.outputs.unchecked }}" exit 1 From 05fbcfde3372b5b7954b4f550ae72d61ad5d6039 Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Thu, 26 Sep 2024 10:01:07 -0700 Subject: [PATCH 11/12] Prevent grep failure --- .github/workflows/pr-checklist.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml index 2cb1e94dd1..ae9cfd381e 100644 --- a/.github/workflows/pr-checklist.yml +++ b/.github/workflows/pr-checklist.yml @@ -42,7 +42,7 @@ jobs: id: checkboxes run: | DESCRIPTION="${{ steps.pr.outputs.body }}" - UNCHECKED=$(echo "$DESCRIPTION" | grep -c '\[ \]') + UNCHECKED=$(echo "$DESCRIPTION" | grep -c '\[ \]' || true) echo "unchecked=$UNCHECKED" >> $GITHUB_OUTPUT - name: Fail if not all checkboxes are checked and PR is not draft if: ${{ (steps.pr.outputs.draft == 'false') && (steps.checkboxes.outputs.unchecked != '0') }} From 051ec71f4b4925c8675fa901521274e477e851f9 Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Thu, 26 Sep 2024 10:18:56 -0700 Subject: [PATCH 12/12] Add job name and timeout --- .github/workflows/pr-checklist.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml index ae9cfd381e..887b879abb 100644 --- a/.github/workflows/pr-checklist.yml +++ b/.github/workflows/pr-checklist.yml @@ -22,6 +22,8 @@ on: jobs: checklist: + name: Close all checkboxes before moving from draft + timeout-minutes: 5 runs-on: ubuntu-24.04 steps: - name: Checkout