From 48edfc1a45e764c21569c12b6aab1baa38f34f30 Mon Sep 17 00:00:00 2001 From: Sayali Gaikawad Date: Tue, 15 Aug 2023 13:58:44 -0700 Subject: [PATCH 1/4] Run compatibility check based on PR base branch Signed-off-by: Sayali Gaikawad --- .github/workflows/check-compatibility.yml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/check-compatibility.yml b/.github/workflows/check-compatibility.yml index d9c232e8b1015..65894b12352f5 100644 --- a/.github/workflows/check-compatibility.yml +++ b/.github/workflows/check-compatibility.yml @@ -7,12 +7,17 @@ on: jobs: build: if: github.repository == 'opensearch-project/OpenSearch' + permissions: + contents: read # to fetch code (actions/checkout) + pull-requests: write # to create or update comment (peter-evans/create-or-update-comment) runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Run compatibility task - run: ./gradlew checkCompatibility -i | tee $HOME/gradlew-check.out + run: ./gradlew checkCompatibility -i -PrepositoryUrls=https://github.com/opensearch-project/common-utils | tee $HOME/gradlew-check.out - name: Get results run: | @@ -22,17 +27,8 @@ jobs: echo "### Skipped components" >> "${{ github.workspace }}/results.txt" && grep -e 'Skipped component' $HOME/gradlew-check.out | sed -e 's/Skipped component: \[\(.*\)\]/- \1/' >> "${{ github.workspace }}/results.txt" echo "### Compatible components" >> "${{ github.workspace }}/results.txt" && grep -e 'Compatible component' $HOME/gradlew-check.out | sed -e 's/Compatible component: \[\(.*\)\]/- \1/' >> "${{ github.workspace }}/results.txt" - - name: GitHub App token - id: github_app_token - uses: tibdex/github-app-token@v1.6.0 - with: - app_id: ${{ secrets.APP_ID }} - private_key: ${{ secrets.APP_PRIVATE_KEY }} - installation_id: 22958780 - - name: Add comment on the PR uses: peter-evans/create-or-update-comment@v3 with: - token: ${{ steps.github_app_token.outputs.token }} issue-number: ${{ github.event.number }} body-path: "${{ github.workspace }}/results.txt" From 4b3b160e62c0fb395e164a4cb2925e475461e5e8 Mon Sep 17 00:00:00 2001 From: Sayali Gaikawad Date: Tue, 22 Aug 2023 16:48:40 -0700 Subject: [PATCH 2/4] Remove test env Signed-off-by: Sayali Gaikawad --- .github/workflows/check-compatibility.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-compatibility.yml b/.github/workflows/check-compatibility.yml index 65894b12352f5..5c5bd04473ced 100644 --- a/.github/workflows/check-compatibility.yml +++ b/.github/workflows/check-compatibility.yml @@ -17,7 +17,7 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - name: Run compatibility task - run: ./gradlew checkCompatibility -i -PrepositoryUrls=https://github.com/opensearch-project/common-utils | tee $HOME/gradlew-check.out + run: ./gradlew checkCompatibility -i | tee $HOME/gradlew-check.out - name: Get results run: | From 20378a7e2f6d8268cfb77b70c7302f423906dc5e Mon Sep 17 00:00:00 2001 From: Sayali Gaikawad Date: Wed, 23 Aug 2023 11:04:45 -0700 Subject: [PATCH 3/4] Create another job to comment Signed-off-by: Sayali Gaikawad --- .github/workflows/check-compatibility.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check-compatibility.yml b/.github/workflows/check-compatibility.yml index 5c5bd04473ced..6ba97e2a91dde 100644 --- a/.github/workflows/check-compatibility.yml +++ b/.github/workflows/check-compatibility.yml @@ -8,8 +8,7 @@ jobs: build: if: github.repository == 'opensearch-project/OpenSearch' permissions: - contents: read # to fetch code (actions/checkout) - pull-requests: write # to create or update comment (peter-evans/create-or-update-comment) + contents: read runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -27,8 +26,24 @@ jobs: echo "### Skipped components" >> "${{ github.workspace }}/results.txt" && grep -e 'Skipped component' $HOME/gradlew-check.out | sed -e 's/Skipped component: \[\(.*\)\]/- \1/' >> "${{ github.workspace }}/results.txt" echo "### Compatible components" >> "${{ github.workspace }}/results.txt" && grep -e 'Compatible component' $HOME/gradlew-check.out | sed -e 's/Compatible component: \[\(.*\)\]/- \1/' >> "${{ github.workspace }}/results.txt" + - name: Upload results + uses: actions/upload-artifact@v3 + with: + name: results.txt + path: ${{ github.workspace }}/results.txt + + add-comment: + needs: [build] + permissions: + pull-requests: write + runs-on: ubuntu-latest + steps: + - name: Download results + uses: actions/download-artifact@v3 + with: + name: results.txt - name: Add comment on the PR uses: peter-evans/create-or-update-comment@v3 with: issue-number: ${{ github.event.number }} - body-path: "${{ github.workspace }}/results.txt" + body-path: results.txt From d62b95b1ea4115c027144879205fdf1ff0d97196 Mon Sep 17 00:00:00 2001 From: Sayali Gaikawad Date: Wed, 23 Aug 2023 11:17:29 -0700 Subject: [PATCH 4/4] Fix naming Signed-off-by: Sayali Gaikawad --- .github/workflows/check-compatibility.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-compatibility.yml b/.github/workflows/check-compatibility.yml index 6ba97e2a91dde..b5f2ccbae6917 100644 --- a/.github/workflows/check-compatibility.yml +++ b/.github/workflows/check-compatibility.yml @@ -5,7 +5,7 @@ on: pull_request_target jobs: - build: + check-compatibility: if: github.repository == 'opensearch-project/OpenSearch' permissions: contents: read @@ -33,7 +33,7 @@ jobs: path: ${{ github.workspace }}/results.txt add-comment: - needs: [build] + needs: [check-compatibility] permissions: pull-requests: write runs-on: ubuntu-latest @@ -42,6 +42,7 @@ jobs: uses: actions/download-artifact@v3 with: name: results.txt + - name: Add comment on the PR uses: peter-evans/create-or-update-comment@v3 with: