Update MAINTAINERS.md #65
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run performance benchmark on pull request | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
run-performance-benchmark-on-pull-request: | |
if: ${{ (github.event.issue.pull_request) && (contains(github.event.comment.body, '"run-benchmark-test"')) }} | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
issues: write | |
pull-requests: write | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Set up required env vars | |
run: | | |
echo "PR_NUMBER=${{ github.event.issue.number }}" >> $GITHUB_ENV | |
echo "REPOSITORY=${{ github.event.repository.full_name }}" >> $GITHUB_ENV | |
OPENSEARCH_VERSION=$(awk -F '=' '/^opensearch[[:space:]]*=/ {gsub(/[[:space:]]/, "", $2); print $2}' buildSrc/version.properties) | |
echo "OPENSEARCH_VERSION=$OPENSEARCH_VERSION" >> $GITHUB_ENV | |
major_version=$(echo $OPENSEARCH_VERSION | cut -d'.' -f1) | |
echo "OPENSEARCH_MAJOR_VERSION=$major_version" >> $GITHUB_ENV | |
- name: Check comment format | |
id: check_comment | |
run: | | |
comment='${{ github.event.comment.body }}' | |
if echo "$comment" | jq -e 'has("run-benchmark-test")'; then | |
echo "Valid comment format detected, check if valid config id is provided" | |
config_id=$(echo $comment | jq -r '.["run-benchmark-test"]') | |
benchmark_configs=$(cat .github/benchmark-configs.json) | |
if echo $benchmark_configs | jq -e --arg id "$config_id" 'has($id)' && echo "$benchmark_configs" | jq -e --arg version "$OPENSEARCH_MAJOR_VERSION" --arg id "$config_id" '.[$id].supported_major_versions | index($version) != null' > /dev/null; then | |
echo $benchmark_configs | jq -r --arg id "$config_id" '.[$id]."cluster-benchmark-configs" | to_entries[] | "\(.key)=\(.value)"' >> $GITHUB_ENV | |
else | |
echo "invalid=true" >> $GITHUB_OUTPUT | |
fi | |
else | |
echo "invalid=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Post invalid format comment | |
if: steps.check_comment.outputs.invalid == 'true' | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'Invalid comment format or config id.' | |
}) | |
- name: Fail workflow for invalid comment | |
if: steps.check_comment.outputs.invalid == 'true' | |
run: | | |
echo "Invalid comment format detected. Failing the workflow." | |
exit 1 | |
- id: get_approvers | |
run: | | |
echo "approvers=$(cat .github/CODEOWNERS | grep '^\*' | tr -d '* ' | sed 's/@/,/g' | sed 's/,//1')" >> $GITHUB_OUTPUT | |
- uses: trstringer/manual-approval@v1 | |
if: (!contains(steps.get_approvers.outputs.approvers, github.event.comment.user.login)) | |
with: | |
secret: ${{ github.TOKEN }} | |
approvers: ${{ steps.get_approvers.outputs.approvers }} | |
minimum-approvals: 1 | |
issue-title: 'Request to approve/deny benchmark for PR #${{ env.PR_NUMBER }}' | |
issue-body: "Please approve or deny the release for PR #${{ env.PR_NUMBER }}" | |
exclude-workflow-initiator-as-approver: false | |
- name: Get PR Details | |
id: get_pr | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const issue = context.payload.issue; | |
const prNumber = issue.number; | |
console.log(`Pull Request Number: ${prNumber}`); | |
const { data: pull_request } = await github.rest.pulls.get({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: prNumber, | |
}); | |
return { | |
"headRepoFullName": pull_request.head.repo.full_name, | |
"headRef": pull_request.head.ref | |
}; | |
- name: Set pr details env vars | |
run: | | |
echo '${{ steps.get_pr.outputs.result }}' | jq -r '.headRepoFullName' | |
echo '${{ steps.get_pr.outputs.result }}' | jq -r '.headRef' | |
headRepo=$(echo '${{ steps.get_pr.outputs.result }}' | jq -r '.headRepoFullName') | |
headRef=$(echo '${{ steps.get_pr.outputs.result }}' | jq -r '.headRef') | |
echo "prHeadRepo=$headRepo" >> $GITHUB_ENV | |
echo "prheadRef=$headRef" >> $GITHUB_ENV | |
- name: Print ENV | |
run: | | |
cat $GITHUB_ENV | |
- name: Checkout PR Repo | |
uses: actions/checkout@v2 | |
with: | |
repository: ${{ env.prHeadRepo }} | |
ref: ${{ env.prHeadRef }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup Java | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 21 | |
- name: Build and Assemble OpenSearch from PR | |
run: | | |
./gradlew :distribution:archives:linux-tar:assemble -Dbuild.snapshot=false | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.UPLOAD_ARCHIVE_ARTIFACT_ROLE }} | |
role-session-name: publish-to-s3 | |
aws-region: us-west-2 | |
- name: Push to S3 | |
run: | | |
aws s3 cp distribution/archives/linux-tar/build/distributions/opensearch-min-$OPENSEARCH_VERSION-linux-x64.tar.gz s3://${{ secrets.ARCHIVE_ARTIFACT_BUCKET_NAME }}/PR-$PR_NUMBER/ | |
echo "DISTRIBUTION_URL=${{ secrets.ARTIFACT_BUCKET_CLOUDFRONT_URL }}/PR-$PR_NUMBER/opensearch-min-$OPENSEARCH_VERSION-linux-x64.tar.gz" >> $GITHUB_ENV | |
- name: Checkout opensearch-build repo | |
uses: actions/checkout@v4 | |
with: | |
repository: rishabh6788/opensearch-build | |
ref: main | |
path: opensearch-build | |
- name: Trigger jenkins workflow to run gradle check | |
run: | | |
cat $GITHUB_ENV | |
bash opensearch-build/scripts/benchmark/benchmark-pull-request.sh ${{ secrets.JENKINS_PR_BENCHMARK_GENERIC_WEBHOOK_TOKEN }} | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Update PR with Job Url | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const workflowUrl = process.env.WORKFLOW_URL; | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `The Jenkins job url is ${workflowUrl} . Final results will be published once the job is completed.` | |
}) |