From 3b976256ede7c97f2ca5556608524a1c446a6912 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Fri, 26 Jul 2024 16:36:37 +0900 Subject: [PATCH 01/18] feat: add workflow to check conflict Signed-off-by: hlts2 --- .github/workflows/check-conflict.yml | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/check-conflict.yml diff --git a/.github/workflows/check-conflict.yml b/.github/workflows/check-conflict.yml new file mode 100644 index 0000000000..5e7b520f94 --- /dev/null +++ b/.github/workflows/check-conflict.yml @@ -0,0 +1,41 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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 conflict +on: + pull_request: +jobs: + dump-contexts-to-log: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/dump-context + check-conflict: + if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.DISPATCH_TOKEN }} + - name: Set Git config + run: | + git config --global --add safe.directory ${GITHUB_WORKSPACE} + - name: Check conflict + run: | + if grep -r ">>> HEAD" . --exclude-dir=.git --exclude=check-conflict.yml; then + echo "Please fix conflict locally." + exit 1 + fi From 466779c379fa6584ff2d7b654588328792951690 Mon Sep 17 00:00:00 2001 From: Yusuke Kato Date: Sat, 27 Jul 2024 05:50:50 +0900 Subject: [PATCH 02/18] Apply suggestions from code review Signed-off-by: Yusuke Kato --- .github/workflows/check-conflict.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-conflict.yml b/.github/workflows/check-conflict.yml index 5e7b520f94..6eb494b977 100644 --- a/.github/workflows/check-conflict.yml +++ b/.github/workflows/check-conflict.yml @@ -35,7 +35,7 @@ jobs: git config --global --add safe.directory ${GITHUB_WORKSPACE} - name: Check conflict run: | - if grep -r ">>> HEAD" . --exclude-dir=.git --exclude=check-conflict.yml; then + if grep -r "<<<< HEAD" . --exclude-dir=.git --exclude=check-conflict.yml; then echo "Please fix conflict locally." exit 1 fi From ff8a2c37ff3f7fec03e4c03418ef214017d7f988 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 29 Jul 2024 15:23:57 +0900 Subject: [PATCH 03/18] feat: send conflict warning comment Signed-off-by: hlts2 --- .github/workflows/check-conflict.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/check-conflict.yml b/.github/workflows/check-conflict.yml index 6eb494b977..5a8de3dbc6 100644 --- a/.github/workflows/check-conflict.yml +++ b/.github/workflows/check-conflict.yml @@ -36,6 +36,21 @@ jobs: - name: Check conflict run: | if grep -r "<<<< HEAD" . --exclude-dir=.git --exclude=check-conflict.yml; then + PR_COMMENTS=$(curl ${API_URL}?per_page=10000) + BODY=$(echo -E "${PR_COMMENTS}" | jq 'last(.[] | select(.user.login == "vdaas-ci") | select(.body | test("^\\\\*\\\\*\\\\[WARNING:CONFLICT")) | .body)' -r) + + if [ "$BODY" = "null" ]; then + curl --include --verbose --fail \ + -H "Accept: application/json" \ + -H "Content-Type:application/json" \ + -H "Authorization: token ${GITHUB_TOKEN}" \ + --request POST \ + --data "{\"body\": \"**[WARNING:CONFLICT]** You may require to fix the conflict. Please check.\"}" \ + ${API_URL} + fi echo "Please fix conflict locally." exit 1 fi + env: + GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} + API_URL: ${{ github.event.pull_request.comments_url }} From aee3f323088f7234354867a8e839ac2ab9c7f88a Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 29 Jul 2024 15:24:31 +0900 Subject: [PATCH 04/18] fix: verify for sending comment Signed-off-by: hlts2 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a5d4a226ee..75e951c5ba 100755 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +>>> HEAD +
From 2b7eaf4ff9dd533abe124ca203a66b3f43937adb Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 06:24:53 +0000 Subject: [PATCH 05/18] style: format code with Gofumpt and Prettier This commit fixes the style issues introduced in aee3f32 according to the output from Gofumpt and Prettier. Details: https://github.com/vdaas/vald/pull/2548 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 75e951c5ba..51eb86cd78 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ ->>> HEAD +> > > HEAD
From 91f2826f8a38cdd73feb30404b1e0f4e4d003944 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 29 Jul 2024 15:26:36 +0900 Subject: [PATCH 06/18] fix: verify for sending comment Signed-off-by: hlts2 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 51eb86cd78..725c45d777 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -> > > HEAD +<<< HEAD
From af401c1786f234e2717c9d1574b6570ceec0476c Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 29 Jul 2024 15:31:36 +0900 Subject: [PATCH 07/18] fix: debug body Signed-off-by: hlts2 --- .github/workflows/check-conflict.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check-conflict.yml b/.github/workflows/check-conflict.yml index 5a8de3dbc6..df55eb7af9 100644 --- a/.github/workflows/check-conflict.yml +++ b/.github/workflows/check-conflict.yml @@ -38,6 +38,7 @@ jobs: if grep -r "<<<< HEAD" . --exclude-dir=.git --exclude=check-conflict.yml; then PR_COMMENTS=$(curl ${API_URL}?per_page=10000) BODY=$(echo -E "${PR_COMMENTS}" | jq 'last(.[] | select(.user.login == "vdaas-ci") | select(.body | test("^\\\\*\\\\*\\\\[WARNING:CONFLICT")) | .body)' -r) + echo "${BODY}" if [ "$BODY" = "null" ]; then curl --include --verbose --fail \ From b47588cea5a27f99e770993bb017473d4809c093 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 29 Jul 2024 15:35:16 +0900 Subject: [PATCH 08/18] fix: add log Signed-off-by: hlts2 --- .github/workflows/check-conflict.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/check-conflict.yml b/.github/workflows/check-conflict.yml index df55eb7af9..3b99e4eab8 100644 --- a/.github/workflows/check-conflict.yml +++ b/.github/workflows/check-conflict.yml @@ -51,6 +51,8 @@ jobs: fi echo "Please fix conflict locally." exit 1 + else + echo "Nothing conflict" fi env: GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} From 506e5833ced0ab6f78983db79e09e240406d6d0d Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 29 Jul 2024 15:38:16 +0900 Subject: [PATCH 09/18] feat: add debug code Signed-off-by: hlts2 --- .github/workflows/check-conflict.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/check-conflict.yml b/.github/workflows/check-conflict.yml index 3b99e4eab8..2af1289bb8 100644 --- a/.github/workflows/check-conflict.yml +++ b/.github/workflows/check-conflict.yml @@ -35,6 +35,9 @@ jobs: git config --global --add safe.directory ${GITHUB_WORKSPACE} - name: Check conflict run: | + ls + grep -r "<<<< HEAD" . --exclude-dir=.git --exclude=check-conflict.yml + if grep -r "<<<< HEAD" . --exclude-dir=.git --exclude=check-conflict.yml; then PR_COMMENTS=$(curl ${API_URL}?per_page=10000) BODY=$(echo -E "${PR_COMMENTS}" | jq 'last(.[] | select(.user.login == "vdaas-ci") | select(.body | test("^\\\\*\\\\*\\\\[WARNING:CONFLICT")) | .body)' -r) From 55ad4c76d7892f4e27e16abf6044899c20caa95a Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 29 Jul 2024 15:43:25 +0900 Subject: [PATCH 10/18] fix: add debug Signed-off-by: hlts2 --- .github/workflows/check-conflict.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check-conflict.yml b/.github/workflows/check-conflict.yml index 2af1289bb8..f15b7328d5 100644 --- a/.github/workflows/check-conflict.yml +++ b/.github/workflows/check-conflict.yml @@ -36,6 +36,7 @@ jobs: - name: Check conflict run: | ls + cat README.md grep -r "<<<< HEAD" . --exclude-dir=.git --exclude=check-conflict.yml if grep -r "<<<< HEAD" . --exclude-dir=.git --exclude=check-conflict.yml; then From 1debded4062496c4b88faf5c2f3dc3a215e9d2c9 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 29 Jul 2024 15:44:35 +0900 Subject: [PATCH 11/18] fix: deleted unnecessary debug code Signed-off-by: hlts2 --- .github/workflows/check-conflict.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/check-conflict.yml b/.github/workflows/check-conflict.yml index f15b7328d5..f17a0c8c02 100644 --- a/.github/workflows/check-conflict.yml +++ b/.github/workflows/check-conflict.yml @@ -35,11 +35,7 @@ jobs: git config --global --add safe.directory ${GITHUB_WORKSPACE} - name: Check conflict run: | - ls - cat README.md - grep -r "<<<< HEAD" . --exclude-dir=.git --exclude=check-conflict.yml - - if grep -r "<<<< HEAD" . --exclude-dir=.git --exclude=check-conflict.yml; then + if ! grep -r "<<<< HEAD" . --exclude-dir=.git --exclude=check-conflict.yml; then PR_COMMENTS=$(curl ${API_URL}?per_page=10000) BODY=$(echo -E "${PR_COMMENTS}" | jq 'last(.[] | select(.user.login == "vdaas-ci") | select(.body | test("^\\\\*\\\\*\\\\[WARNING:CONFLICT")) | .body)' -r) echo "${BODY}" From a78bf493e9678165dd59adbe7e170681c81a7d97 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 29 Jul 2024 15:48:34 +0900 Subject: [PATCH 12/18] fix: fails comment for sending comment Signed-off-by: hlts2 --- .github/workflows/check-conflict.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check-conflict.yml b/.github/workflows/check-conflict.yml index f17a0c8c02..e18a37620d 100644 --- a/.github/workflows/check-conflict.yml +++ b/.github/workflows/check-conflict.yml @@ -36,11 +36,10 @@ jobs: - name: Check conflict run: | if ! grep -r "<<<< HEAD" . --exclude-dir=.git --exclude=check-conflict.yml; then - PR_COMMENTS=$(curl ${API_URL}?per_page=10000) - BODY=$(echo -E "${PR_COMMENTS}" | jq 'last(.[] | select(.user.login == "vdaas-ci") | select(.body | test("^\\\\*\\\\*\\\\[WARNING:CONFLICT")) | .body)' -r) - echo "${BODY}" + PR_COMMENTS=`curl ${API_URL}?per_page=10000` + BODY=`echo -E "${PR_COMMENTS}" | jq 'last(.[] | select(.user.login == "vdaas-ci") | select(.body | test("^\\\\*\\\\*\\\\[WARNING:CONFLICT")) | .body)' -r` - if [ "$BODY" = "null" ]; then + if [ "${BODY}" = "null" ]; then curl --include --verbose --fail \ -H "Accept: application/json" \ -H "Content-Type:application/json" \ From 5d2991a7e9f3e7c88b7c8ffeb869b79abc6b3dbe Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 29 Jul 2024 15:51:28 +0900 Subject: [PATCH 13/18] fix: deleted unnecessary changes Signed-off-by: hlts2 --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 725c45d777..a5d4a226ee 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -<<< HEAD -
From b8e39deb782e92186480427ff53d27f6c22e3430 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 29 Jul 2024 15:53:54 +0900 Subject: [PATCH 14/18] feat: fix grep condition Signed-off-by: hlts2 --- .github/workflows/check-conflict.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-conflict.yml b/.github/workflows/check-conflict.yml index e18a37620d..d2eda8436f 100644 --- a/.github/workflows/check-conflict.yml +++ b/.github/workflows/check-conflict.yml @@ -35,7 +35,7 @@ jobs: git config --global --add safe.directory ${GITHUB_WORKSPACE} - name: Check conflict run: | - if ! grep -r "<<<< HEAD" . --exclude-dir=.git --exclude=check-conflict.yml; then + if grep -r "<<<< HEAD" . --exclude-dir=.git --exclude=check-conflict.yml; then PR_COMMENTS=`curl ${API_URL}?per_page=10000` BODY=`echo -E "${PR_COMMENTS}" | jq 'last(.[] | select(.user.login == "vdaas-ci") | select(.body | test("^\\\\*\\\\*\\\\[WARNING:CONFLICT")) | .body)' -r` From 98f4c442acd2769d375edcbf568d0675f4a5f094 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 29 Jul 2024 15:56:07 +0900 Subject: [PATCH 15/18] fix: add changes for verify Signed-off-by: hlts2 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a5d4a226ee..e1ddea7a14 100755 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +<<<< HEAD +
From d0cc228cf678113af2ecd01058695d3923764f3c Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 29 Jul 2024 15:57:18 +0900 Subject: [PATCH 16/18] Revert "fix: add changes for verify" This reverts commit 98f4c442acd2769d375edcbf568d0675f4a5f094. --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index e1ddea7a14..a5d4a226ee 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -<<<< HEAD -
From 31ed2a80435c3ca4bd07e9d6892386a30776ed2a Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 29 Jul 2024 15:58:43 +0900 Subject: [PATCH 17/18] fix: add changes for verify Signed-off-by: hlts2 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a5d4a226ee..76d7049ce9 100755 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +<<<<<< HEAD +