-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Close Stalled PRs | ||
on: | ||
schedule: | ||
- cron: '15 15 * * *' # Run every day at 15:15 UTC / 7:15 PST / 8:15 PDT | ||
permissions: | ||
pull-requests: write | ||
jobs: | ||
stale: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: GitHub App token | ||
id: github_app_token | ||
uses: tibdex/github-app-token@v1.5.0 | ||
with: | ||
app_id: ${{ secrets.APP_ID }} | ||
private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
installation_id: 22958780 | ||
- name: Stale PRs | ||
uses: actions/stale@v8 | ||
with: | ||
repo-token: ${{ steps.github_app_token.outputs.token }} | ||
stale-pr-label: 'stalled' | ||
stale-pr-message: 'This PR is stalled because it has been open for 30 days with no activity. Remove stalled label or comment or this will be closed in 7 days.' | ||
close-pr-message: 'This PR was closed because it has been stalled for 7 days with no activity.' | ||
days-before-pr-stale: 30 | ||
days-before-pr-close: 7 | ||
days-before-issue-stale: -1 | ||
days-before-issue-close: -1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.gradle | ||
|
||
import groovy.json.JsonSlurper | ||
import org.ajoberstar.grgit.Grgit | ||
import org.ajoberstar.grgit.operation.BranchListOp | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.Internal | ||
import org.gradle.api.tasks.TaskAction | ||
import org.gradle.internal.os.OperatingSystem | ||
|
||
import java.nio.file.Paths | ||
|
||
class CheckCompatibilityTask extends DefaultTask { | ||
|
||
static final String REPO_URL = 'https://raw.githubusercontent.com/opensearch-project/opensearch-plugins/main/plugins/.meta' | ||
|
||
@Input | ||
List repositoryUrls = project.hasProperty('repositoryUrls') ? project.property('repositoryUrls').split(',') : getRepoUrls() | ||
|
||
@Input | ||
String ref = project.hasProperty('ref') ? project.property('ref') : 'main' | ||
|
||
@Internal | ||
List failedComponents = [] | ||
|
||
@Internal | ||
List gitFailedComponents = [] | ||
|
||
@Internal | ||
List compatibleComponents = [] | ||
|
||
@TaskAction | ||
void checkCompatibility() { | ||
logger.info("Checking compatibility for: $repositoryUrls for $ref") | ||
repositoryUrls.parallelStream().forEach { repositoryUrl -> | ||
def tempDir = File.createTempDir() | ||
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' | ||
standardOutput stdout | ||
} | ||
compatibleComponents.add(repositoryUrl) | ||
} else { | ||
logger.lifecycle("Skipping compatibility check for $repositoryUrl") | ||
} | ||
} catch (ex) { | ||
failedComponents.add(repositoryUrl) | ||
logger.info("Gradle assemble failed for $repositoryUrl", ex) | ||
} finally { | ||
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") | ||
} | ||
} | ||
|
||
protected static List getRepoUrls() { | ||
def json = new JsonSlurper().parse(REPO_URL.toURL()) | ||
def labels = json.projects.values() | ||
return labels as List | ||
} | ||
|
||
protected boolean cloneAndCheckout(repoUrl, directory) { | ||
try { | ||
def grgit = Grgit.clone(dir: directory, uri: repoUrl) | ||
def remoteBranches = grgit.branch.list(mode: BranchListOp.Mode.REMOTE) | ||
String targetBranch = 'origin/' + ref | ||
if (remoteBranches.find { it.name == targetBranch } == null) { | ||
gitFailedComponents.add(repoUrl) | ||
logger.info("$ref does not exist for $repoUrl. Skipping the compatibility check!!") | ||
return false | ||
} else { | ||
logger.info("Checking out $targetBranch") | ||
grgit.checkout(branch: targetBranch) | ||
return true | ||
} | ||
} catch (ex) { | ||
logger.error('Exception occurred during GitHub operations', ex) | ||
gitFailedComponents.add(repoUrl) | ||
return false | ||
} | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ad391210ffd806931334be9670a35af00c56f959 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
297e1cfade4ef71466cc9d4f361d81807c8dc4c8 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
eec248b26f16e888688e5bb37b7eeda76b78d2f7 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
c70ef20ca338558147887df60f46341bc47f6900 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
9e5404764092c1f6305ad5719078f46ab228d587 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
f651595784d6cca4cbca6a8ad74c48fceed6cea8 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ad4ecf779ebc794cd351f57792f56ea01387b868 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cd9121ce24d6d3f2898946d04b0ef3ec548b00b4 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
e96f649e8e9dcb29a1f8e95328b99c9eb6cf76c2 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ec783a737f96991a87b1d5794e2f9eb2024d708a |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3fa5f9d04b6b782d869d6e0657d896eeadca5866 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
94293b169fb8572f440a5a4a523320ecf9778ffe |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2df800a38b64867b8dcd61fc2cd986114e4a80cb |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a01e8153f34d72e8c8c0180c1dea5b10f677dd3a |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
b7d47d54683b0b1e09b271c32d1b7d3eb1990f49 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5e68b9816e6cff8ee15f5b350cf2ffa54f9828b7 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
d23b1f05b471e05d0d6068b3ece7c8c65672eae7 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dfb4313f3c68d337310522840d7144c1605d084a |