Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
Signed-off-by: Sayali Gaikawad <gaiksaya@amazon.com>
  • Loading branch information
gaiksaya committed May 24, 2024
1 parent 031dc28 commit 72a678c
Showing 1 changed file with 35 additions and 32 deletions.
67 changes: 35 additions & 32 deletions .github/workflows/gradle-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,25 @@ permissions:
contents: read # to fetch code (actions/checkout)

jobs:

check-files:
if: github.repository == 'opensearch-project/OpenSearch'
runs-on: ubuntu-latest
outputs:
RUN_GRADLE_CHECK: ${{steps.changed-files-specific.outputs.any_changed}}
steps:
- name: Get changed files
id: changed-files-specific
uses: tj-actions/changed-files@v44
with:
files_ignore: |
release-notes/*.md
.github/**
*.md
gradle-check:
if: github.repository == 'opensearch-project/OpenSearch'
needs: check-files
if: github.repository == 'opensearch-project/OpenSearch' && needs.check-files.outputs.RUN_GRADLE_CHECK
permissions:
contents: read # to fetch code (actions/checkout)
pull-requests: write # to create or update comment (peter-evans/create-or-update-comment)
Expand All @@ -27,28 +43,8 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Get changed files
id: changed-files-specific
uses: tj-actions/changed-files@v44
with:
files_ignore: |
release-notes/*.md
.github/**
ADMINS.md
CHANGELOG-3.0.md
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
DEVELOPER_GUIDE.md
MAINTAINERS.md
README.md
RELEASING.md
SECURITY.md
TESTING.md
TRIAGING.md
- name: Setup environment variables (PR)
if: github.event_name == 'pull_request_target' && steps.changed-files-specific.outputs.any_changed == 'true'
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
Expand Down Expand Up @@ -77,7 +73,7 @@ jobs:
).data[0];
- name: Setup environment variables (Push)
if: github.event_name == 'push' && steps.changed-files-specific.outputs.any_changed == 'true'
if: github.event_name == 'push'
run: |
repo_url="https://github.com/opensearch-project/OpenSearch"
ref_id=$(git rev-parse HEAD)
Expand All @@ -94,44 +90,42 @@ jobs:
echo "post_merge_action=true" >> $GITHUB_ENV
- name: Checkout opensearch-build repo
if: steps.changed-files-specific.outputs.any_changed == 'true'
uses: actions/checkout@v4
with:
repository: opensearch-project/opensearch-build
ref: main
path: opensearch-build

- name: Trigger jenkins workflow to run gradle check
if: steps.changed-files-specific.outputs.any_changed == 'true'
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() && steps.changed-files-specific.outputs.any_changed == 'true'
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() && steps.changed-files-specific.outputs.any_changed == 'true'
if: success()
uses: codecov/codecov-action@v4
with:
files: ./codeCoverage.xml

- name: Create Comment Success
if: ${{ github.event_name == 'pull_request_target' && success() && env.result == 'SUCCESS' && steps.changed-files-specific.outputs.any_changed == 'true' }}
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' && steps.changed-files-specific.outputs.any_changed == 'true' }}
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" != "" ]]
Expand All @@ -146,7 +140,7 @@ jobs:
fi
- name: Create Comment Flaky
if: ${{ github.event_name == 'pull_request_target' && success() && env.result != 'SUCCESS' && steps.changed-files-specific.outputs.any_changed == 'true' }}
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 }}
Expand All @@ -156,7 +150,7 @@ jobs:
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() && steps.changed-files-specific.outputs.any_changed == 'true' }}
if: ${{ github.event_name == 'pull_request_target' && failure() }}
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ env.pr_number }}
Expand All @@ -166,10 +160,19 @@ jobs:
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?
- name: Create Issue On Push Failure
if: ${{ github.event_name == 'push' && failure() && steps.changed-files-specific.outputs.any_changed == 'true' }}
if: ${{ github.event_name == 'push' && failure() }}
uses: dblock/create-a-github-issue@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
assignees: ${{ github.event.head_commit.author.username }}, ${{ github.triggering_actor }}
filename: .github/ISSUE_TEMPLATE/failed_check.md

check-result:
needs: [check-files, gradle-check]
if: always()
runs-on: ubuntu-latest
steps:
- name: fail if conditional job failed
if: ${{ needs.check-files.outputs.RUN_GRADLE_CHECK && needs.gradle-check.result == 'failure' }}
run: exit 1

0 comments on commit 72a678c

Please sign in to comment.