From 822c3556815369785efde953e9d8dc0dfb769714 Mon Sep 17 00:00:00 2001 From: Peter Nied Date: Fri, 11 Aug 2023 21:51:04 +0000 Subject: [PATCH 1/2] [CheckCompatibility] Prevent interleaving of log output Signed-off-by: Peter Nied --- .github/workflows/check-compatibility.yml | 4 ++-- .../gradle/CheckCompatibilityTask.groovy | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/check-compatibility.yml b/.github/workflows/check-compatibility.yml index b208fe38a581f..5bd9000245bab 100644 --- a/.github/workflows/check-compatibility.yml +++ b/.github/workflows/check-compatibility.yml @@ -11,12 +11,12 @@ jobs: - uses: actions/checkout@v3 - name: Run compatibility task - run: ./gradlew checkCompatibility | tee $HOME/gradlew-check.out + run: ./gradlew checkCompatibility -i | 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" + grep -e 'Compatible components' -e 'Incompatible components' -e 'Components skipped' $HOME/gradlew-check.out >> "${{ github.workspace }}/results.txt" echo '```' >> ${{ github.workspace }}/results.txt - name: GitHub App token diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy index b95bb3be22f8b..11a57ab776562 100644 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy +++ b/buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy @@ -43,6 +43,9 @@ class CheckCompatibilityTask extends DefaultTask { repositoryUrls.parallelStream().forEach { repositoryUrl -> logger.lifecycle("Checking compatibility for: $repositoryUrl with ref: $ref") def tempDir = File.createTempDir() + def stdout = new ByteArrayOutputStream() + def errout = new ByteArrayOutputStream() + def skipped = false; try { if (cloneAndCheckout(repositoryUrl, tempDir)) { if (repositoryUrl.toString().endsWithAny('notifications', 'notifications.git')) { @@ -50,29 +53,34 @@ class CheckCompatibilityTask extends DefaultTask { } project.exec { workingDir = tempDir - def stdout = new ByteArrayOutputStream() executable = (OperatingSystem.current().isWindows()) ? 'gradlew.bat' : './gradlew' - args 'assemble' + args ('assemble') standardOutput stdout + errorOutput errout } compatibleComponents.add(repositoryUrl) } else { - logger.lifecycle("Skipping compatibility check for $repositoryUrl") + skipped = true } } catch (ex) { failedComponents.add(repositoryUrl) logger.info("Gradle assemble failed for $repositoryUrl", ex) } finally { + if (skipped) { + logger.lifecycle("Skipping compatibility check for $repositoryUrl") + } else { + logger.lifecycle("Finished compatibility check for $repositoryUrl") + logger.info("Standard output for $repositoryUrl build:\n\n" + stdout.toString()) + logger.error("Error output for $repositoryUrl build:\n\n" + errout.toString()) + } tempDir.deleteDir() } } if (!failedComponents.isEmpty()) { logger.lifecycle("Incompatible components: $failedComponents") - logger.info("Compatible components: $compatibleComponents") } if (!gitFailedComponents.isEmpty()) { logger.lifecycle("Components skipped due to git failures: $gitFailedComponents") - logger.info("Compatible components: $compatibleComponents") } if (!compatibleComponents.isEmpty()) { logger.lifecycle("Compatible components: $compatibleComponents") From 8518854fae7e8307cef993c7283518b7cc20c3a5 Mon Sep 17 00:00:00 2001 From: Peter Nied Date: Mon, 14 Aug 2023 19:11:53 +0000 Subject: [PATCH 2/2] Switch comment to markdown format Signed-off-by: Peter Nied --- .github/workflows/check-compatibility.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check-compatibility.yml b/.github/workflows/check-compatibility.yml index 5bd9000245bab..18d800faee129 100644 --- a/.github/workflows/check-compatibility.yml +++ b/.github/workflows/check-compatibility.yml @@ -15,9 +15,11 @@ jobs: - 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' $HOME/gradlew-check.out >> "${{ github.workspace }}/results.txt" - echo '```' >> ${{ github.workspace }}/results.txt + echo '## Compatibility status:' > "${{ github.workspace }}/results.txt" + echo "Checks if related components are compatible with change $(git rev-parse --short HEAD)" >> "${{ github.workspace }}/results.txt" + echo "### Incompatible components" >> "${{ github.workspace }}/results.txt" && grep -e 'Incompatible component' $HOME/gradlew-check.out | sed -e 's/Incompatible component: \[\(.*\)\]/- \1/' >> "${{ github.workspace }}/results.txt" + 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