Skip to content

Commit

Permalink
[CheckCompatibility] Prevent interleaving of log output (#9280)
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <petern@amazon.com>
(cherry picked from commit 23fd9a5)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Aug 15, 2023
1 parent f6caf4f commit ee2f0a3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/check-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ 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"
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,36 +43,44 @@ 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;

Check warning on line 48 in buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy#L46-L48

Added lines #L46 - L48 were not covered by tests
try {
if (cloneAndCheckout(repositoryUrl, tempDir)) {
if (repositoryUrl.toString().endsWithAny('notifications', 'notifications.git')) {
tempDir = Paths.get(tempDir.getAbsolutePath(), 'notifications')
}
project.exec {
workingDir = tempDir
def stdout = new ByteArrayOutputStream()
executable = (OperatingSystem.current().isWindows()) ? 'gradlew.bat' : './gradlew'
args 'assemble'
args ('assemble')

Check warning on line 57 in buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy#L57

Added line #L57 was not covered by tests
standardOutput stdout
errorOutput errout

Check warning on line 59 in buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy#L59

Added line #L59 was not covered by tests
}
compatibleComponents.add(repositoryUrl)
} else {
logger.lifecycle("Skipping compatibility check for $repositoryUrl")
skipped = true

Check warning on line 63 in buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy#L63

Added line #L63 was not covered by tests
}
} 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())

Check warning on line 74 in buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/groovy/org/opensearch/gradle/CheckCompatibilityTask.groovy#L70-L74

Added lines #L70 - L74 were not covered by tests
}
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")
Expand Down

0 comments on commit ee2f0a3

Please sign in to comment.