Skip to content

Allow Plugins to request to perform cluster actions and index actions with their assigned PluginSubject and prompt on install #40906

Allow Plugins to request to perform cluster actions and index actions with their assigned PluginSubject and prompt on install

Allow Plugins to request to perform cluster actions and index actions with their assigned PluginSubject and prompt on install #40906

Workflow file for this run

name: Gradle Check (Jenkins)
on:
push:
branches-ignore:
- 'backport/**'
- 'create-pull-request/**'
- 'dependabot/**'
pull_request_target:
types: [opened, synchronize, reopened]
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
check-files:
runs-on: ubuntu-latest
outputs:
RUN_GRADLE_CHECK: ${{ steps.changed-files-specific.outputs.any_changed }}
steps:
- uses: actions/checkout@v4
- name: Get changed files
id: changed-files-specific
uses: tj-actions/changed-files@v45
with:
files_ignore: |
release-notes/*.md
.github/**
*.md
gradle-check:
needs: check-files
if: github.repository == 'opensearch-project/OpenSearch' && needs.check-files.outputs.RUN_GRADLE_CHECK == 'true'
permissions:
contents: read # to fetch code (actions/checkout)
pull-requests: write # to create or update comment (peter-evans/create-or-update-comment)
issues: write # To create an issue if check fails on push.
runs-on: ubuntu-latest
timeout-minutes: 130
steps:
- name: Checkout OpenSearch repo
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup environment variables (PR)
if: github.event_name == 'pull_request_target'
run: |
echo "event_name=pull_request_target" >> $GITHUB_ENV
echo "branch_name=$(jq --raw-output .pull_request.base.ref $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
echo "pr_from_sha=$(jq --raw-output .pull_request.head.sha $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
echo "pr_from_clone_url=$(jq --raw-output .pull_request.head.repo.clone_url $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
echo "pr_to_clone_url=$(jq --raw-output .pull_request.base.repo.clone_url $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
echo "pr_title=$(jq --raw-output .pull_request.title $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
echo "pr_number=$(jq --raw-output .pull_request.number $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
echo "pr_owner=$(jq --raw-output .pull_request.user.login $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
echo "pr_or_commit_description=$(jq --ascii-output .pull_request.body $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
echo "post_merge_action=false" >> $GITHUB_ENV
# to get the PR data that can be used for post merge actions
- uses: actions/github-script@v7
if: github.event_name == 'push'
id: get_pr_data
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
return (
await github.rest.repos.listPullRequestsAssociatedWithCommit({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
})
).data[0];
- name: Setup environment variables (Push)
if: github.event_name == 'push'
run: |
repo_url="https://github.com/opensearch-project/OpenSearch"
ref_id=$(git rev-parse HEAD)
branch_name=$(git rev-parse --abbrev-ref HEAD)
echo "branch_name=$branch_name" >> $GITHUB_ENV
echo "event_name=push" >> $GITHUB_ENV
echo "pr_from_sha=$ref_id" >> $GITHUB_ENV
echo "pr_from_clone_url=$repo_url" >> $GITHUB_ENV
echo "pr_to_clone_url=$repo_url" >> $GITHUB_ENV
echo "pr_title=Push trigger $branch_name $ref_id $repo_url" >> $GITHUB_ENV
echo "pr_owner=$(jq --raw-output '.commits[0].author.username' $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
echo 'pr_number=${{ fromJson(steps.get_pr_data.outputs.result).number }}' >> $GITHUB_ENV
echo "pr_or_commit_description=$(jq --ascii-output .head_commit.message $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
echo "post_merge_action=true" >> $GITHUB_ENV
- name: Checkout opensearch-build repo
uses: actions/checkout@v4
with:
repository: opensearch-project/opensearch-build
ref: main
path: opensearch-build
- name: Trigger jenkins workflow to run gradle check
run: |
set -e
set -o pipefail
bash opensearch-build/scripts/gradle/gradle-check.sh ${{ secrets.JENKINS_GRADLE_CHECK_GENERIC_WEBHOOK_TOKEN }} | tee -a gradle-check.log
- name: Setup Result Status
if: always()
run: |
WORKFLOW_URL=`cat gradle-check.log | grep 'WORKFLOW_URL' | awk '{print $2}'`
RESULT=`cat gradle-check.log | grep 'Result:' | awk '{print $2}'`
echo "workflow_url=$WORKFLOW_URL" >> $GITHUB_ENV
echo "result=$RESULT" >> $GITHUB_ENV
- name: Upload Coverage Report
if: success()
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./codeCoverage.xml
- name: Create Comment Success
if: ${{ github.event_name == 'pull_request_target' && success() && env.result == 'SUCCESS' }}
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ env.pr_number }}
body: |
:white_check_mark: Gradle check result for ${{ env.pr_from_sha }}: [${{ env.result }}](${{ env.workflow_url }})
- name: Extract Test Failure
if: ${{ github.event_name == 'pull_request_target' && env.result != 'SUCCESS' }}
run: |
TEST_FAILURES=`curl -s "${{ env.workflow_url }}/testReport/api/json?tree=suites\[cases\[status,className,name\]\]" | jq -r '.. | objects | select(.status=="FAILED",.status=="REGRESSION") | (.className + "." + .name)' | uniq -c | sort -n -r | head -n 10`
if [[ "$TEST_FAILURES" != "" ]]
then
echo "test_failures<<EOF" >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo "* **TEST FAILURES:**" >> $GITHUB_ENV
echo '```' >> $GITHUB_ENV
echo "$TEST_FAILURES" >> $GITHUB_ENV
echo '```' >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
fi
- name: Create Comment Flaky
if: ${{ github.event_name == 'pull_request_target' && success() && env.result != 'SUCCESS' }}
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ env.pr_number }}
body: |
:grey_exclamation: Gradle check result for ${{ env.pr_from_sha }}: [${{ env.result }}](${{ env.workflow_url }}) ${{ env.test_failures }}
Please review all [flaky tests](https://github.com/opensearch-project/OpenSearch/blob/main/DEVELOPER_GUIDE.md#flaky-tests) that succeeded after retry and create an issue if one does not already exist to track the flaky failure.
- name: Create Comment Failure
if: ${{ github.event_name == 'pull_request_target' && failure() }}
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ env.pr_number }}
body: |
:x: Gradle check result for ${{ env.pr_from_sha }}: [${{ env.result }}](${{ env.workflow_url }})
Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure [a flaky test](https://github.com/opensearch-project/OpenSearch/blob/main/DEVELOPER_GUIDE.md#flaky-tests) unrelated to your change?
check-result:
needs: [check-files, gradle-check]
if: always()
runs-on: ubuntu-latest
steps:
- name: Fail if gradle-check fails
if: ${{ needs.check-files.outputs.RUN_GRADLE_CHECK && needs.gradle-check.result == 'failure' }}
run: exit 1