From 1f99e33aa90d84637a23d6e873c0b4bfc11dea24 Mon Sep 17 00:00:00 2001 From: Sayali Gaikawad Date: Thu, 22 Jun 2023 02:21:14 +0000 Subject: [PATCH 1/3] Add workflow to check compatibility Signed-off-by: Sayali Gaikawad --- .github/workflows/check-compatibility.yml | 31 +++++++++++++++++++ .../gradle/CheckCompatibilityTask.groovy | 12 +++++-- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/check-compatibility.yml diff --git a/.github/workflows/check-compatibility.yml b/.github/workflows/check-compatibility.yml new file mode 100644 index 0000000000000..e95b060eb86e6 --- /dev/null +++ b/.github/workflows/check-compatibility.yml @@ -0,0 +1,31 @@ +--- +name: checkCompatibility + +on: + pull_request_target + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Run compatibility task + run: ./gradlew checkCompatibility | tee $HOME/gradlew-check.out + - name: Get results + run: | + echo 'Compatibility status:' > ${{ github.workspace }}/results.txt && echo '```' >> ${{ github.workspace }}/results.txt + grep -e 'Compatible components' -e 'Incompatible components' -e 'Components skipped' -A 2 -B 3 $HOME/gradlew-check.out >> "${{ github.workspace }}/results.txt" + echo '```' >> ${{ 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: ${{ SECRETS.TOKEN }} + issue-number: ${{ steps.github_app_token.outputs.token }} + body-path: "${{ github.workspace }}/results.txt" diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy index ee6446fec6d57..c54a9382073ce 100644 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy +++ b/buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy @@ -40,8 +40,8 @@ class CheckCompatibilityTask extends DefaultTask { @TaskAction void checkCompatibility() { - logger.info("Checking compatibility for: $repositoryUrls for $ref") repositoryUrls.parallelStream().forEach { repositoryUrl -> + logger.lifecycle("Checking compatibility for: $repositoryUrl with ref: $ref") def tempDir = File.createTempDir() try { if (cloneAndCheckout(repositoryUrl, tempDir)) { @@ -82,7 +82,15 @@ class CheckCompatibilityTask extends DefaultTask { protected static List getRepoUrls() { def json = new JsonSlurper().parse(REPO_URL.toURL()) def labels = json.projects.values() - return labels as List + def repoUrls = replaceSshWithHttps(labels as List) + return repoUrls + } + + protected static replaceSshWithHttps(List inputList) { + inputList.replaceAll { element -> + element.replace("git@github.com:", "https://github.com/") + } + return inputList } protected boolean cloneAndCheckout(repoUrl, directory) { From 420f3202d2abc1f4126640177076a06417bc8044 Mon Sep 17 00:00:00 2001 From: Sayali Gaikawad Date: Thu, 6 Jul 2023 05:43:00 -0700 Subject: [PATCH 2/3] Refactor code Signed-off-by: Sayali Gaikawad --- .github/workflows/check-compatibility.yml | 6 +++++- .../opensearch/gradle/CheckCompatibilityTask.groovy | 10 +++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check-compatibility.yml b/.github/workflows/check-compatibility.yml index e95b060eb86e6..c97293f0700cc 100644 --- a/.github/workflows/check-compatibility.yml +++ b/.github/workflows/check-compatibility.yml @@ -1,5 +1,5 @@ --- -name: checkCompatibility +name: Check Compatibility on: pull_request_target @@ -9,13 +9,16 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Run compatibility task run: ./gradlew checkCompatibility | tee $HOME/gradlew-check.out + - name: Get results run: | echo 'Compatibility status:' > ${{ github.workspace }}/results.txt && echo '```' >> ${{ github.workspace }}/results.txt grep -e 'Compatible components' -e 'Incompatible components' -e 'Components skipped' -A 2 -B 3 $HOME/gradlew-check.out >> "${{ github.workspace }}/results.txt" echo '```' >> ${{ github.workspace }}/results.txt + - name: GitHub App token id: github_app_token uses: tibdex/github-app-token@v1.6.0 @@ -23,6 +26,7 @@ jobs: 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: diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy index c54a9382073ce..b95bb3be22f8b 100644 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy +++ b/buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy @@ -81,16 +81,16 @@ class CheckCompatibilityTask extends DefaultTask { protected static List getRepoUrls() { def json = new JsonSlurper().parse(REPO_URL.toURL()) - def labels = json.projects.values() - def repoUrls = replaceSshWithHttps(labels as List) + def repository = json.projects.values() + def repoUrls = replaceSshWithHttps(repository as List) return repoUrls } - protected static replaceSshWithHttps(List inputList) { - inputList.replaceAll { element -> + protected static replaceSshWithHttps(List repoList) { + repoList.replaceAll { element -> element.replace("git@github.com:", "https://github.com/") } - return inputList + return repoList } protected boolean cloneAndCheckout(repoUrl, directory) { From e757198bd3f91d4b9ea502a459cfba757bbaa91a Mon Sep 17 00:00:00 2001 From: Sayali Gaikawad Date: Thu, 6 Jul 2023 07:08:18 -0700 Subject: [PATCH 3/3] Refactor code Signed-off-by: Sayali Gaikawad --- .github/workflows/check-compatibility.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-compatibility.yml b/.github/workflows/check-compatibility.yml index c97293f0700cc..b208fe38a581f 100644 --- a/.github/workflows/check-compatibility.yml +++ b/.github/workflows/check-compatibility.yml @@ -30,6 +30,6 @@ jobs: - name: Add comment on the PR uses: peter-evans/create-or-update-comment@v3 with: - token: ${{ SECRETS.TOKEN }} - issue-number: ${{ steps.github_app_token.outputs.token }} + token: ${{ steps.github_app_token.outputs.token }} + issue-number: ${{ github.event.number }} body-path: "${{ github.workspace }}/results.txt"