Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TT-1832 Add slack notification for nightly run with detailed flaky test summary #15446

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d1f0fc8
Update slack notification for flaky test detector
lukaszcl Nov 25, 2024
ea75e52
Bump flakeguard and support shuffle flag
lukaszcl Nov 25, 2024
48bfbce
Merge branch 'develop' into TT-1832-Implement-Slack-Notification-for-…
lukaszcl Nov 28, 2024
57222ac
bump flakeguard
lukaszcl Nov 28, 2024
cc01faf
Merge branch 'develop' into TT-1832-Implement-Slack-Notification-for-…
lukaszcl Nov 28, 2024
215e7af
update notification
lukaszcl Nov 28, 2024
55ac102
Fix
lukaszcl Nov 28, 2024
a49e362
Add separate job for nightly flakeguard workflow
lukaszcl Dec 3, 2024
dbb132e
trigger
lukaszcl Dec 3, 2024
712a893
fix
lukaszcl Dec 3, 2024
24f0bfb
Merge branch 'fix-nightly-flakeguard-job' into TT-1832-Implement-Slac…
lukaszcl Dec 3, 2024
a2c4259
Fix
lukaszcl Dec 3, 2024
8d1738b
Fix codeowners issue
lukaszcl Dec 3, 2024
fdda554
fix
lukaszcl Dec 3, 2024
bbf180c
fix
lukaszcl Dec 3, 2024
9cca636
Fix
lukaszcl Dec 3, 2024
bf035ef
Fix codeowners issue
lukaszcl Dec 3, 2024
6abd379
revert: fail test
lukaszcl Dec 3, 2024
1920380
Fix all tests path
lukaszcl Dec 3, 2024
cc1eec3
Merge branch 'fix-nightly-flakeguard-job' into TT-1832-Implement-Slac…
lukaszcl Dec 3, 2024
9652d42
fix notification
lukaszcl Dec 3, 2024
d06bb80
Fix format
lukaszcl Dec 3, 2024
65eb692
Revert "revert: fail test"
lukaszcl Dec 3, 2024
099f647
debug
lukaszcl Dec 3, 2024
a1b60c3
bump
lukaszcl Dec 3, 2024
e146d32
Fix
lukaszcl Dec 3, 2024
2516aaf
bump
lukaszcl Dec 3, 2024
8e178de
fix
lukaszcl Dec 3, 2024
0315ff0
fix
lukaszcl Dec 3, 2024
f69398b
bump
lukaszcl Dec 3, 2024
115152b
revert
lukaszcl Dec 3, 2024
7204727
Fix
lukaszcl Dec 3, 2024
ddde02a
bump flakeguard to fix codeowners
lukaszcl Dec 3, 2024
0e38c42
bump
lukaszcl Dec 3, 2024
f6694f5
Merge branch 'fix-nightly-flakeguard-job' into TT-1832-Implement-Slac…
lukaszcl Dec 3, 2024
4f339d9
fix
lukaszcl Dec 3, 2024
4f36cb7
Merge branch 'develop' into TT-1832-Implement-Slack-Notification-for-…
lukaszcl Dec 4, 2024
fbe763b
Bump flakeguard
lukaszcl Dec 4, 2024
5dcb3a8
fail test on purpose
lukaszcl Dec 4, 2024
d2a7d47
fix
lukaszcl Dec 4, 2024
48bf79a
Fix
lukaszcl Dec 4, 2024
eeb9e3e
Fix
lukaszcl Dec 4, 2024
29c85cd
fix
lukaszcl Dec 4, 2024
650ac03
fix lint
lukaszcl Dec 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/flakeguard-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
uses: ./.github/workflows/flakeguard.yml
with:
repoUrl: 'https://github.com/smartcontractkit/chainlink'
baseRef: 'origin/develop'
headRef: 'develop'
projectPath: '.'
maxPassRatio: '1.0'
runAllTests: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/flakeguard-on-demand.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
runAllTests: ${{ inputs.runAllTests }}
findByTestFilesDiff: ${{ inputs.findByTestFilesDiff }}
findByAffectedPackages: ${{ inputs.findByAffectedPackages }}
slackNotificationAfterTestsChannelId: ${{ inputs.slack_notification_after_tests_channel_id }}
slackNotificationAfterTestsChannelId: ${{ inputs.slack_notification_after_tests_channel_id || 'C07TRF65CNS' }} #flaky-test-detector-notifications
extraArgs: ${{ inputs.extraArgs }}
secrets:
SLACK_BOT_TOKEN: ${{ secrets.QA_SLACK_API_KEY }}
Expand Down
98 changes: 84 additions & 14 deletions .github/workflows/flakeguard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
description: 'The path to the project to run the flaky test detection.'
default: '.'
baseRef:
required: true
required: false
type: string
description: 'The base reference or branch to compare changes for detecting flaky tests.'
headRef:
Expand Down Expand Up @@ -66,6 +66,7 @@ env:
DEFAULT_RUNNER: 'ubuntu-latest' # The default runner to use for running tests.
UPLOAD_ALL_TEST_RESULTS: ${{ fromJson(inputs.extraArgs)['upload_all_test_results'] || 'false' }} # Whether to upload all test results as artifacts.
PRINT_FAILED_TESTS: ${{ fromJson(inputs.extraArgs)['print_failed_tests'] || 'false' }} # Whether to print failed tests in the GitHub console.


jobs:
get-tests:
Expand Down Expand Up @@ -100,7 +101,7 @@ jobs:

- name: Install flakeguard
shell: bash
run: go install github.com/smartcontractkit/chainlink-testing-framework/tools/flakeguard@f03577def97a20a38c0e1de1cbe7fc98d416dd86 # flakguard@0.1.0
run: go install github.com/smartcontractkit/chainlink-testing-framework/tools/flakeguard@9e40f2765df01f20b3bf53f0fb3ead920e3a1f4a # flakguard@0.1.0

- name: Find new or updated test packages
if: ${{ inputs.runAllTests == false }}
Expand Down Expand Up @@ -259,7 +260,7 @@ jobs:

- name: Install flakeguard
shell: bash
run: go install github.com/smartcontractkit/chainlink-testing-framework/tools/flakeguard@f03577def97a20a38c0e1de1cbe7fc98d416dd86 # flakguard@0.1.0
run: go install github.com/smartcontractkit/chainlink-testing-framework/tools/flakeguard@9e40f2765df01f20b3bf53f0fb3ead920e3a1f4a # flakguard@0.1.0

- name: Run tests with flakeguard
shell: bash
Expand Down Expand Up @@ -306,7 +307,7 @@ jobs:

- name: Install flakeguard
shell: bash
run: go install github.com/smartcontractkit/chainlink-testing-framework/tools/flakeguard@f03577def97a20a38c0e1de1cbe7fc98d416dd86 # flakguard@0.1.0
run: go install github.com/smartcontractkit/chainlink-testing-framework/tools/flakeguard@9e40f2765df01f20b3bf53f0fb3ead920e3a1f4a # flakguard@0.1.0

- name: Set combined test results
id: set_test_results
Expand Down Expand Up @@ -341,10 +342,27 @@ jobs:
fi
echo "Failed tests count: $FAILED_TESTS_COUNT"
echo "failed_tests_count=$FAILED_TESTS_COUNT" >> "$GITHUB_OUTPUT"

# Calculate failed ratio (failed / non-failed tests ratio in %)
if [ "$ALL_TESTS_COUNT" -gt 0 ]; then
NON_FAILED_COUNT=$((ALL_TESTS_COUNT - FAILED_TESTS_COUNT))

if [ "$NON_FAILED_COUNT" -gt 0 ]; then
FAILED_RATIO=$(awk "BEGIN {printf \"%.2f\", ($FAILED_TESTS_COUNT / $NON_FAILED_COUNT) * 100}")
else
FAILED_RATIO=0
fi
else
NON_FAILED_COUNT=0
FAILED_RATIO=0
fi
echo "Failed tests ratio: $FAILED_RATIO%"
echo "failed_ratio=$FAILED_RATIO" >> "$GITHUB_OUTPUT"
else
echo "No test results directory found."
echo "all_tests_count=0" >> "$GITHUB_OUTPUT"
echo "failed_tests_count=0" >> "$GITHUB_OUTPUT"
echo "failed_ratio=0" >> "$GITHUB_OUTPUT"
fi

- name: Tests Summary
Expand All @@ -368,47 +386,47 @@ jobs:
with:
path: all_tests.md
name: all-summary.md
retention-days: 7
retention-days: 90

- name: Upload All Test Results as Artifact
if: ${{ fromJson(steps.set_test_results.outputs.all_tests_count) > 0 }}
uses: actions/upload-artifact@v4.4.3
with:
path: all_tests.json
name: all-test-results.json
retention-days: 7
retention-days: 90

- name: Upload Failed Tests Summary as Artifact
if: ${{ fromJson(steps.set_test_results.outputs.all_tests_count) > 0 }}
uses: actions/upload-artifact@v4.4.3
with:
path: failed_tests.md
name: failed-summary.md
retention-days: 7
retention-days: 90

- name: Upload Failed Test Results as Artifact
if: ${{ fromJson(steps.set_test_results.outputs.failed_tests_count) > 0 }}
uses: actions/upload-artifact@v4.4.3
with:
path: failed_tests.json
name: failed-test-results.json
retention-days: 7
retention-days: 90

- name: Upload Failed Test Logs as Artifact
if: ${{ fromJson(steps.set_test_results.outputs.failed_tests_count) > 0 }}
uses: actions/upload-artifact@v4.4.3
with:
path: failed_test_logs.json
name: failed-test-logs.json
retention-days: 7
retention-days: 90

- name: Upload All Test Results as Artifact
if: ${{ fromJson(steps.set_test_results.outputs.all_tests_count) > 0 && env.UPLOAD_ALL_TEST_RESULTS == 'true' }}
uses: actions/upload-artifact@v4.4.3
with:
path: all_tests.json
name: all-test-results.json
retention-days: 7
retention-days: 90

- name: Post comment on PR if flaky tests found
if: ${{ fromJson(steps.set_test_results.outputs.failed_tests_count) > 0 && github.event_name == 'pull_request' }}
Expand All @@ -427,9 +445,61 @@ jobs:
body: commentBody
});

- name: Send Slack message
- name: Send Slack message for failed tests
if: ${{ inputs.slackNotificationAfterTestsChannelId != '' && fromJson(steps.set_test_results.outputs.failed_tests_count) > 0 }}
uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: ${{ inputs.slackNotificationAfterTestsChannelId }}
payload: |
{
"attachments": [
{
"color": "#C62828",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Flaky Test Detector for `${{ steps.set_project_path_pretty.outputs.path }}` project - ${{ contains(join(needs.*.result, ','), 'failure') && 'Failed :x:' || contains(join(needs.*.result, ','), 'cancelled') && 'Was cancelled :warning:' || 'Passed :white_check_mark:' }}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ inputs.runAllTests == true && format('Ran all tests for `{0}` branch.', inputs.headRef) || format('Ran changed tests between `{0}` and `{1}` (`{2}`).', inputs.baseRef, needs.get-tests.outputs.git_head_short_sha, env.GIT_HEAD_REF) }}"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "Total Failed Tests: ${{ steps.set_test_results.outputs.failed_tests_count }}"
},
{
"type": "mrkdwn",
"text": "Failed to Non-Failed Ratio: ${{ steps.set_test_results.outputs.failed_ratio }}%"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ format('<{0}/{1}/actions/runs/{2}|View Flaky Detector Details> | <{3}/compare/{4}...{5}#files_bucket|Compare Changes>{6}', github.server_url, github.repository, github.run_id, inputs.repoUrl, inputs.baseRef, needs.get-tests.outputs.git_head_sha, github.event_name == 'pull_request' && format(' | <{0}|View PR>', github.event.pull_request.html_url) || '') }}"
}
}
]
}
]
}

- name: Send general Slack message
uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0
if: ${{ inputs.slackNotificationAfterTestsChannelId != '' && fromJson(steps.set_test_results.outputs.all_tests_count) > 0 }}
if: ${{ inputs.slackNotificationAfterTestsChannelId != '' && fromJson(steps.set_test_results.outputs.failed_tests_count) == 0 && fromJson(steps.set_test_results.outputs.all_tests_count) > 0 }}
id: slack
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
Expand All @@ -452,14 +522,14 @@ jobs:
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Ran changed tests between `${{ inputs.baseRef }}` and `${{ needs.get-tests.outputs.git_head_short_sha }}` (`${{ env.GIT_HEAD_REF }}`)."
"text": "${{ inputs.runAllTests == true && format('Ran all tests for `{0}` branch.', env.GIT_HEAD_REF) || format('Ran changed tests between `{0}` and `{1}` (`{2}`).', inputs.baseRef, needs.get-tests.outputs.git_head_short_sha, env.GIT_HEAD_REF) }}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ format('<{0}/{1}/actions/runs/{2}|View Flaky Detector Details> | <{3}/compare/{4}...{5}#files_bucket|Compare Changes>{6}', github.server_url, github.repository, github.run_id, inputs.repoUrl, inputs.baseRef, needs.get-tests.outputs.git_head_sha, github.event_name == 'pull_request' && format(' | <{0}|View PR>', github.event.pull_request.html_url) || '') }}"
"text": "${{ inputs.runAllTests == true && format('<{0}/{1}/actions/runs/{2}|View Flaky Detector Details>', github.server_url, github.repository, github.run_id) || format('<{0}/{1}/actions/runs/{2}|View Flaky Detector Details> | <{3}/compare/{4}...{5}#files_bucket|Compare Changes>{6}', github.server_url, github.repository, github.run_id, inputs.repoUrl, inputs.baseRef, needs.get-tests.outputs.git_head_sha, github.event_name == 'pull_request' && format(' | <{0}|View PR>', github.event.pull_request.html_url) || '') }}"
}
}
]
Expand Down
Loading