From f6ce149117806f0433a2c657ee870e711273593c Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Tue, 18 Jun 2024 16:22:37 +0300 Subject: [PATCH 01/26] ci: Auto lgtm --- .github/workflows/labeler.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/labeler.yml diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 00000000..db90543b --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,34 @@ +name: Label PR with LGTM on approval + +on: + pull_request_review: + types: [submitted] + +jobs: + label_on_approve: + runs-on: ubuntu-latest + + steps: + - name: Check if review is approved + id: review_check + run: | + if [[ "${{ github.event.review.state }}" != "approved" ]]; then + echo "This review is not an approval. Exiting." + exit 0 + fi + + - name: Add LGTM label + if: steps.review_check.outputs.review_approved == 'true' + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { owner, repo } = context.repo; + const pr_number = context.payload.pull_request.number; + + await github.issues.addLabels({ + owner, + repo, + issue_number: pr_number, + labels: ['lgtm'] + }); From a1f55591860f0b6b805b79444db47e01ce7927f8 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Tue, 18 Jun 2024 16:27:51 +0300 Subject: [PATCH 02/26] fix: script --- .github/workflows/labeler.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index db90543b..5e746343 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -12,7 +12,10 @@ jobs: - name: Check if review is approved id: review_check run: | - if [[ "${{ github.event.review.state }}" != "approved" ]]; then + if [[ "${{ github.event.review.state }}" == "approved" ]]; then + echo "::set-output name=review_approved::true" + else + echo "::set-output name=review_approved::false" echo "This review is not an approval. Exiting." exit 0 fi From d14a0229b19b31883a802fbd2e04f4349fc2bf92 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Tue, 18 Jun 2024 16:30:34 +0300 Subject: [PATCH 03/26] fix: consts --- .github/workflows/labeler.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 5e746343..28527665 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -26,8 +26,9 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | + const { context, github } = require('@actions/github'); const { owner, repo } = context.repo; - const pr_number = context.payload.pull_request.number; + const issue_number = context.payload.pull_request.number; await github.issues.addLabels({ owner, From 977ab7748cf27b13e13a4ee399458451d359e9bf Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 13:59:34 +0300 Subject: [PATCH 04/26] ci: Auto labeler action --- .github/labeler.yml | 18 ++++++++++++++++ .github/workflows/labeler.yml | 40 +++++++---------------------------- 2 files changed, 26 insertions(+), 32 deletions(-) create mode 100644 .github/labeler.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 00000000..efaac8a0 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,18 @@ +# Add 'Documentation' label to any change to .md files within the entire repository +documentation: + - changed-files: + - any-glob-to-any-file: "**/*.md" + +# Add 'feature' label to any PR where the head branch name starts with `feature` or has a `feature` section in the name +feature: + - head-branch: ["^feature", "feat:"] + +# Add 'release' label to any PR that is opened against the `main` branch +fix: + - head-branch: ["^bugfix", "fix:"] + +ci: + - head-branch: ["^ci", "ci:"] + - changed-files: + - any-glob-to-any-file: + - .github/* diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 28527665..e647c97d 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -1,38 +1,14 @@ -name: Label PR with LGTM on approval - +name: "Pull Request Labeler" on: - pull_request_review: - types: [submitted] + - pull_request_target jobs: - label_on_approve: + labeler: + permissions: + contents: read + pull-requests: write runs-on: ubuntu-latest - steps: - - name: Check if review is approved - id: review_check - run: | - if [[ "${{ github.event.review.state }}" == "approved" ]]; then - echo "::set-output name=review_approved::true" - else - echo "::set-output name=review_approved::false" - echo "This review is not an approval. Exiting." - exit 0 - fi - - - name: Add LGTM label - if: steps.review_check.outputs.review_approved == 'true' - uses: actions/github-script@v6 + - uses: actions/labeler@v5 with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const { context, github } = require('@actions/github'); - const { owner, repo } = context.repo; - const issue_number = context.payload.pull_request.number; - - await github.issues.addLabels({ - owner, - repo, - issue_number: pr_number, - labels: ['lgtm'] - }); + repo-token: ${{ secrets.GITHUB_TOKEN }} From eb7e476a57580059d120744407762fb7ef909efb Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 14:36:23 +0300 Subject: [PATCH 05/26] fix: on --- .github/workflows/labeler.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index e647c97d..4dfb4ea4 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -1,6 +1,7 @@ name: "Pull Request Labeler" on: - - pull_request_target + pull_request_review: + types: [submitted] jobs: labeler: From 50298fca351ae03322f6f72a277259ea57fa1b82 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 14:39:17 +0300 Subject: [PATCH 06/26] fix: Added more triggers --- .github/workflows/labeler.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 4dfb4ea4..a8c6635f 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -2,6 +2,10 @@ name: "Pull Request Labeler" on: pull_request_review: types: [submitted] + pull_request_review_comment: + types: [created, deleted] + pull_request: + types: [opened, edited, reopened, synchronize] jobs: labeler: From 01af563289d857c0b2f7ac7f4f82632f765080d0 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 14:41:20 +0300 Subject: [PATCH 07/26] fix: feat trigger --- .github/labeler.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index efaac8a0..83c20e4b 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -5,7 +5,7 @@ documentation: # Add 'feature' label to any PR where the head branch name starts with `feature` or has a `feature` section in the name feature: - - head-branch: ["^feature", "feat:"] + - head-branch: ["^feat", "feat:"] # Add 'release' label to any PR that is opened against the `main` branch fix: From 0bfcddc5a2b934ceb5b2d7ecc3e63ce122e5a514 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 14:55:00 +0300 Subject: [PATCH 08/26] ci: size labels --- .github/workflows/labeler.yml | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index a8c6635f..ae14089e 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -14,6 +14,36 @@ jobs: pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions/labeler@v5 + - name: Labeler + uses: actions/labeler@v5 with: repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Calculate diff size + id: diff + run: | + lines=$(git diff --stat origin/main...HEAD | tail -n1 | awk '{print $1}') + echo "changed_lines=$lines" >> $GITHUB_ENV + + - name: Determine label + id: label + run: | + changed_lines=${{ env.changed_lines }} + if [ "$changed_lines" -le 9 ]; then + label="size:s" + elif [ "$changed_lines" -le 50 ]; then + label="size:m" + elif [ "$changed_lines" -le 100 ]; then + label="size:l" + elif [ "$changed_lines" -le 500 ]; then + label="size:xl" + else + label="size:xxl" + fi + echo "label=$label" >> $GITHUB_ENV + + - name: Add label to PR + uses: actions-ecosystem/action-add-labels@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: ${{ env.label }} From ab372a183ad02561078c140aa0327e87620dcde8 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 15:09:24 +0300 Subject: [PATCH 09/26] fix: More tests --- .github/workflows/labeler.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index ae14089e..9d366161 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -14,15 +14,23 @@ jobs: pull-requests: write runs-on: ubuntu-latest steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Labeler uses: actions/labeler@v5 with: repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Fetch all branches + run: git fetch --all + - name: Calculate diff size id: diff run: | - lines=$(git diff --stat origin/main...HEAD | tail -n1 | awk '{print $1}') + base_branch=$(jq -r '.pull_request.base.ref' "$GITHUB_EVENT_PATH") + head_branch=$(jq -r '.pull_request.head.ref' "$GITHUB_EVENT_PATH") + lines=$(git diff --stat origin/$base_branch...$head_branch | tail -n1 | awk '{print $1}') echo "changed_lines=$lines" >> $GITHUB_ENV - name: Determine label From 25d173bc7a4194a1fd751380d831eee212352bce Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 16:42:42 +0300 Subject: [PATCH 10/26] docs: remove to add --- .yamllint.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.yamllint.yaml b/.yamllint.yaml index db5dd90c..78f66564 100644 --- a/.yamllint.yaml +++ b/.yamllint.yaml @@ -6,5 +6,3 @@ rules: line-length: max: 300 document-start: disable - truthy: - check-keys: false From 336df3b8f93d22600cc8a35b216dfc730d75362e Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 16:47:00 +0300 Subject: [PATCH 11/26] docs: Updated labeler --- .github/workflows/labeler.yml | 10 ++++++---- .yamllint.yaml | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 9d366161..49c47dd6 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -24,14 +24,16 @@ jobs: - name: Fetch all branches run: git fetch --all + with: + fetch-depth: 0 - name: Calculate diff size id: diff run: | - base_branch=$(jq -r '.pull_request.base.ref' "$GITHUB_EVENT_PATH") - head_branch=$(jq -r '.pull_request.head.ref' "$GITHUB_EVENT_PATH") - lines=$(git diff --stat origin/$base_branch...$head_branch | tail -n1 | awk '{print $1}') - echo "changed_lines=$lines" >> $GITHUB_ENV + insertions=$(git diff --stat origin/main...HEAD | tail -n1 | awk '{print $4}') + deletions=$(git diff --stat origin/main...HEAD | tail -n1 | awk '{print $6}') + changed_lines=$((insertions + deletions)) + echo "changed_lines=$changed_lines" >> $GITHUB_ENV - name: Determine label id: label diff --git a/.yamllint.yaml b/.yamllint.yaml index 78f66564..db5dd90c 100644 --- a/.yamllint.yaml +++ b/.yamllint.yaml @@ -6,3 +6,5 @@ rules: line-length: max: 300 document-start: disable + truthy: + check-keys: false From 721fd96feb1cd429f58798e5498e183f639b09dc Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 16:48:37 +0300 Subject: [PATCH 12/26] fix: Added default --- .github/workflows/labeler.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 49c47dd6..bba1a46b 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -30,8 +30,8 @@ jobs: - name: Calculate diff size id: diff run: | - insertions=$(git diff --stat origin/main...HEAD | tail -n1 | awk '{print $4}') - deletions=$(git diff --stat origin/main...HEAD | tail -n1 | awk '{print $6}') + insertions=$(git diff --stat origin/main...HEAD | tail -n1 | awk '{print $4 || 0}') + deletions=$(git diff --stat origin/main...HEAD | tail -n1 | awk '{print $6 || 0}') changed_lines=$((insertions + deletions)) echo "changed_lines=$changed_lines" >> $GITHUB_ENV From ca214b89a4372f71247374bfefc88466da181053 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 16:50:22 +0300 Subject: [PATCH 13/26] fix: Removed line --- .github/workflows/labeler.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index bba1a46b..ba0868d1 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -24,8 +24,6 @@ jobs: - name: Fetch all branches run: git fetch --all - with: - fetch-depth: 0 - name: Calculate diff size id: diff From bad33309ce569822810427a7111e6ee03cd11151 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 16:54:06 +0300 Subject: [PATCH 14/26] fix: labeler --- .github/workflows/labeler.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index ba0868d1..dc3b0849 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -25,9 +25,23 @@ jobs: - name: Fetch all branches run: git fetch --all + - name: Determine base and head branches + id: branches + run: | + base_branch=$(jq -r '.pull_request.base.ref' "$GITHUB_EVENT_PATH") + head_branch=$(jq -r '.pull_request.head.ref' "$GITHUB_EVENT_PATH") + echo $base_branch + echo $head_branch + echo "base_branch=$base_branch" >> $GITHUB_ENV + echo "head_branch=$head_branch" >> $GITHUB_ENV + - name: Calculate diff size id: diff run: | + base_branch=${{ env.base_branch }} + head_branch=${{ env.head_branch }} + echo $base_branch + echo $head_branch insertions=$(git diff --stat origin/main...HEAD | tail -n1 | awk '{print $4 || 0}') deletions=$(git diff --stat origin/main...HEAD | tail -n1 | awk '{print $6 || 0}') changed_lines=$((insertions + deletions)) From 57b224f0a75a2a2f62d785c4cd87707c8653ecff Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 16:55:59 +0300 Subject: [PATCH 15/26] fix: prints --- .github/workflows/labeler.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index dc3b0849..aad61fb0 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -42,7 +42,13 @@ jobs: head_branch=${{ env.head_branch }} echo $base_branch echo $head_branch - insertions=$(git diff --stat origin/main...HEAD | tail -n1 | awk '{print $4 || 0}') + git checkout $head_branch + git fetch origin $base_branch + diff_output=$(git diff --shortstat origin/$base_branch...$head_branch) + echo $diff_output + + + insertions=$(git diff --stat origin/$base_branch...HEAD | tail -n1 | awk '{print $4 || 0}') deletions=$(git diff --stat origin/main...HEAD | tail -n1 | awk '{print $6 || 0}') changed_lines=$((insertions + deletions)) echo "changed_lines=$changed_lines" >> $GITHUB_ENV From 2c67c7838ea5a4b3d700935d3ddcc5feaeec0be8 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 16:57:48 +0300 Subject: [PATCH 16/26] fix: Script --- .github/workflows/labeler.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index aad61fb0..641af242 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -45,11 +45,9 @@ jobs: git checkout $head_branch git fetch origin $base_branch diff_output=$(git diff --shortstat origin/$base_branch...$head_branch) - echo $diff_output - - insertions=$(git diff --stat origin/$base_branch...HEAD | tail -n1 | awk '{print $4 || 0}') - deletions=$(git diff --stat origin/main...HEAD | tail -n1 | awk '{print $6 || 0}') + insertions=$(diff_output | awk '{print $4 || 0}') + deletions=$(diff_output | awk '{print $6 || 0}') changed_lines=$((insertions + deletions)) echo "changed_lines=$changed_lines" >> $GITHUB_ENV From 6a3ca2218ed2cc66566d5f2dc47ef73e87493a70 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 16:59:40 +0300 Subject: [PATCH 17/26] fix: scri[pt --- .github/workflows/labeler.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 641af242..98819a9a 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -46,8 +46,8 @@ jobs: git fetch origin $base_branch diff_output=$(git diff --shortstat origin/$base_branch...$head_branch) - insertions=$(diff_output | awk '{print $4 || 0}') - deletions=$(diff_output | awk '{print $6 || 0}') + insertions=$(echo $diff_output | awk '{print $4 || 0}') + deletions=$(echo $diff_output | awk '{print $6 || 0}') changed_lines=$((insertions + deletions)) echo "changed_lines=$changed_lines" >> $GITHUB_ENV From 68d3d05af1104df842a10d4664f63a75b5d72029 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 17:01:05 +0300 Subject: [PATCH 18/26] ci: Added prints --- .github/workflows/labeler.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 98819a9a..de49f171 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -45,10 +45,11 @@ jobs: git checkout $head_branch git fetch origin $base_branch diff_output=$(git diff --shortstat origin/$base_branch...$head_branch) - + echo $diff_output insertions=$(echo $diff_output | awk '{print $4 || 0}') deletions=$(echo $diff_output | awk '{print $6 || 0}') changed_lines=$((insertions + deletions)) + echo $changed_lines echo "changed_lines=$changed_lines" >> $GITHUB_ENV - name: Determine label From 44a4471a126f6d190f192d9b02593aab4e643a22 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 17:02:13 +0300 Subject: [PATCH 19/26] ci: More prints --- .github/workflows/labeler.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index de49f171..abc185c5 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -47,7 +47,13 @@ jobs: diff_output=$(git diff --shortstat origin/$base_branch...$head_branch) echo $diff_output insertions=$(echo $diff_output | awk '{print $4 || 0}') + insertions1=$(echo $diff_output | awk '{print $4}') + echo $insertions + echo $insertions1 deletions=$(echo $diff_output | awk '{print $6 || 0}') + deletions=$(echo $diff_output | awk '{print $6}') + echo $deletions + echo $deletions1 changed_lines=$((insertions + deletions)) echo $changed_lines echo "changed_lines=$changed_lines" >> $GITHUB_ENV From a66e8d03cbc5f48cec903ae57bc7055ea273b915 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 17:05:09 +0300 Subject: [PATCH 20/26] ci: Added echo 0 --- .github/workflows/labeler.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index abc185c5..e0b8b985 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -46,11 +46,11 @@ jobs: git fetch origin $base_branch diff_output=$(git diff --shortstat origin/$base_branch...$head_branch) echo $diff_output - insertions=$(echo $diff_output | awk '{print $4 || 0}') + insertions=$(echo $diff_output | awk '{print $4 || echo 0}') insertions1=$(echo $diff_output | awk '{print $4}') echo $insertions echo $insertions1 - deletions=$(echo $diff_output | awk '{print $6 || 0}') + deletions=$(echo $diff_output | awk '{print $6 || echo 0}') deletions=$(echo $diff_output | awk '{print $6}') echo $deletions echo $deletions1 From 9cc08940174c62564fc24a80b575879ce12a5c43 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 17:06:29 +0300 Subject: [PATCH 21/26] ci: Fixed condition --- .github/workflows/labeler.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index e0b8b985..bfbf6218 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -46,11 +46,11 @@ jobs: git fetch origin $base_branch diff_output=$(git diff --shortstat origin/$base_branch...$head_branch) echo $diff_output - insertions=$(echo $diff_output | awk '{print $4 || echo 0}') + insertions=$(echo $diff_output | awk '{print $4}' || echo 0) insertions1=$(echo $diff_output | awk '{print $4}') echo $insertions echo $insertions1 - deletions=$(echo $diff_output | awk '{print $6 || echo 0}') + deletions=$(echo $diff_output | awk '{print $6}' || echo 0) deletions=$(echo $diff_output | awk '{print $6}') echo $deletions echo $deletions1 From 52ddaadd0d713fab0bd64aea9066a26b47a284f0 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 17:14:21 +0300 Subject: [PATCH 22/26] fix: condition --- .github/workflows/labeler.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index bfbf6218..28536449 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -46,12 +46,12 @@ jobs: git fetch origin $base_branch diff_output=$(git diff --shortstat origin/$base_branch...$head_branch) echo $diff_output - insertions=$(echo $diff_output | awk '{print $4}' || echo 0) - insertions1=$(echo $diff_output | awk '{print $4}') + insertions=$(echo $diff_output | awk '{print $4}') + insertions1=$(echo $diff_output | awk '{print ($4 == "" ? 0 : $4)}') echo $insertions echo $insertions1 deletions=$(echo $diff_output | awk '{print $6}' || echo 0) - deletions=$(echo $diff_output | awk '{print $6}') + deletions1=$(echo $diff_output | awk '{print ($6 == "" ? 0 : $6)}') echo $deletions echo $deletions1 changed_lines=$((insertions + deletions)) From a69eb15c16aad62ac92b20e7a685b826dd85a699 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 17:15:32 +0300 Subject: [PATCH 23/26] fix: Removed unused lines --- .github/workflows/labeler.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 28536449..896fa0cc 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -46,12 +46,8 @@ jobs: git fetch origin $base_branch diff_output=$(git diff --shortstat origin/$base_branch...$head_branch) echo $diff_output - insertions=$(echo $diff_output | awk '{print $4}') - insertions1=$(echo $diff_output | awk '{print ($4 == "" ? 0 : $4)}') - echo $insertions - echo $insertions1 - deletions=$(echo $diff_output | awk '{print $6}' || echo 0) - deletions1=$(echo $diff_output | awk '{print ($6 == "" ? 0 : $6)}') + insertions=$(echo $diff_output | awk '{print ($4 == "" ? 0 : $4)}') + deletions=$(echo $diff_output | awk '{print ($6 == "" ? 0 : $6)}') echo $deletions echo $deletions1 changed_lines=$((insertions + deletions)) From 574c197c968af9ed33a576a01a6553081624ed76 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 17:15:46 +0300 Subject: [PATCH 24/26] fix: Removed more prints --- .github/workflows/labeler.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 896fa0cc..4aa8d636 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -48,8 +48,6 @@ jobs: echo $diff_output insertions=$(echo $diff_output | awk '{print ($4 == "" ? 0 : $4)}') deletions=$(echo $diff_output | awk '{print ($6 == "" ? 0 : $6)}') - echo $deletions - echo $deletions1 changed_lines=$((insertions + deletions)) echo $changed_lines echo "changed_lines=$changed_lines" >> $GITHUB_ENV From e7e26d9835e5f402c7a72506414941671b901baa Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 17:22:24 +0300 Subject: [PATCH 25/26] ci: Lgtm --- .github/workflows/labeler.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 4aa8d636..30c3529e 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -74,3 +74,17 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} labels: ${{ env.label }} + + add_lgtm_label: + runs-on: ubuntu-latest + if: github.event.review.state == 'approved' + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Add LGTM label + uses: actions-ecosystem/action-add-labels@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: lgtm From ae40be01fea86d416bef2039551c090f1e7a985c Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Wed, 19 Jun 2024 17:25:09 +0300 Subject: [PATCH 26/26] fix: condition --- .github/workflows/labeler.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 30c3529e..d2bfad9c 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -77,7 +77,7 @@ jobs: add_lgtm_label: runs-on: ubuntu-latest - if: github.event.review.state == 'approved' + if: github.event.review.state == 'APPROVED' steps: - name: Checkout repository