-
Notifications
You must be signed in to change notification settings - Fork 25
Enhance crashed cases handling in nightly #3047
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
Open
chandrasekaranpradeep
wants to merge
1
commit into
main
Choose a base branch
from
pchandrasekaran/enhance_crashed_cases
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,185 @@ | ||
| name: Extract crashed tests | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| repo: | ||
| description: 'Repository to fetch artifacts from (owner/repo)' | ||
| required: true | ||
| type: string | ||
| run_id: | ||
| description: 'Workflow run id to fetch artifacts for' | ||
| required: true | ||
| type: string | ||
| output_dir: | ||
| description: 'Directory to place downloaded artifacts' | ||
| required: true | ||
| type: string | ||
| artifact_prefix: | ||
| description: 'Artifact name prefix to match' | ||
| required: true | ||
| type: string | ||
| outputs: | ||
| crashed-tests: | ||
| description: "Comma-separated list of all crashed test names detected from the artifacts." | ||
| value: ${{ jobs.extract.outputs.crashed-tests }} | ||
| contains-crashed-tests: | ||
| description: "Boolean flag indicating whether any crashed tests were found." | ||
| value: ${{ jobs.extract.outputs.contains-crashed-tests }} | ||
| crashed-test-cnt: | ||
| description: "Total number of crashed test groups identified during extraction." | ||
| value: ${{ jobs.extract.outputs.crashed-test-cnt }} | ||
| crashed-test-ids: | ||
| description: "Array of job indices corresponding to each crashed test group." | ||
| value: ${{ jobs.extract.outputs.crashed-test-ids }} | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| extract: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| crashed-tests: ${{ steps.extract-crashed-tests.outputs.crashed-tests }} | ||
| contains-crashed-tests: ${{ steps.extract-crashed-tests.outputs.contains-crashed-tests }} | ||
| crashed-test-cnt: ${{ steps.extract-crashed-tests.outputs.crashed-test-cnt }} | ||
| crashed-test-ids: ${{ steps.extract-crashed-tests.outputs.crashed-test-ids }} | ||
| steps: | ||
| - name: Set reusable strings | ||
| id: strings | ||
| shell: bash | ||
| run: | | ||
| echo "work-dir=$(pwd)" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Git safe dir | ||
| run: git config --global --add safe.directory ${{ steps.strings.outputs.work-dir }} | ||
|
|
||
| - uses: actions/checkout@v4 | ||
| with: | ||
| sparse-checkout: | | ||
| .github/download-artifacts.sh | ||
|
|
||
| - name: Download Unique Ops Config Crashed Logs | ||
| shell: bash | ||
| continue-on-error: true | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
| run: | | ||
| bash .github/download-artifacts.sh "${{ inputs.repo }}" "${{ inputs.run_id }}" "${{ inputs.output_dir }}" "${{ inputs.artifact_prefix }}" | ||
|
|
||
| - name: Extract Crashed Cases | ||
| id: extract-crashed-tests | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| logs_dir="${{ inputs.output_dir }}" | ||
| crashed_tests="" | ||
| contains_crashed_tests=false | ||
| number_crashed_tests_per_job=4 | ||
|
|
||
| # Exit early with safe outputs if logs dir missing | ||
| if [ ! -d "$logs_dir" ]; then | ||
| echo "crashed-tests<<EOF" >> "$GITHUB_OUTPUT" | ||
| echo "$crashed_tests" >> "$GITHUB_OUTPUT" | ||
| echo "EOF" >> "$GITHUB_OUTPUT" | ||
| echo "contains-crashed-tests=${contains_crashed_tests}" >> "$GITHUB_OUTPUT" | ||
| echo "crashed-test-cnt=0" >> "$GITHUB_OUTPUT" | ||
| echo "crashed-test-ids=[]" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
|
|
||
| tmpfile="$(mktemp)" | ||
| trap 'rm -f "$tmpfile"' EXIT | ||
|
|
||
| # Collect .log files | ||
| files=() | ||
| while IFS= read -r -d '' f; do | ||
| files+=("$f") | ||
| done < <(find "$logs_dir" -type f -name '*.log' -print0) | ||
|
|
||
| if [ "${#files[@]}" -eq 0 ]; then | ||
| echo "crashed-tests<<EOF" >> "$GITHUB_OUTPUT" | ||
| echo "$crashed_tests" >> "$GITHUB_OUTPUT" | ||
| echo "EOF" >> "$GITHUB_OUTPUT" | ||
| echo "contains-crashed-tests=${contains_crashed_tests}" >> "$GITHUB_OUTPUT" | ||
| echo "crashed-test-cnt=0" >> "$GITHUB_OUTPUT" | ||
| echo "crashed-test-ids=[]" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Sort logs deterministically | ||
| IFS=$'\n' sorted_files=($(printf '%s\n' "${files[@]}" | sort -V)) | ||
| unset IFS | ||
|
|
||
| # Extract crash test tokens | ||
| : > "$tmpfile" | ||
| for file in "${sorted_files[@]}"; do | ||
| perl -nE 'while ( /([^\s]+::[^\s]+)/g ) { say $1 }' "$file" 2>/dev/null >> "$tmpfile" || true | ||
| printf '\n' >> "$tmpfile" | ||
| done | ||
|
|
||
| # Filter unwanted lines (errors, tracebacks, etc.) | ||
| filtered_tmp="$(mktemp)" | ||
| trap 'rm -f "$filtered_tmp" "$tmpfile"' EXIT | ||
|
|
||
| while IFS= read -r line || [ -n "$line" ]; do | ||
| line="$(printf '%s' "$line" | tr -d '\r' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" | ||
| [ -z "$line" ] && continue | ||
| low="$(printf '%s' "$line" | tr '[:upper:]' '[:lower:]')" | ||
| if printf '%s\n' "$low" | grep -qiE '(error|exception|traceback|killed|oom|failed|critical)'; then | ||
| continue | ||
| fi | ||
| if printf '%s\n' "$line" | grep -qE '^[=-]{2,}$'; then | ||
| continue | ||
| fi | ||
| if printf '%s\n' "$line" | grep -qE '^[^[:space:]]+::[^[:space:]]+(\[[^]]+\])?$'; then | ||
| printf '%s\n' "$line" >> "$filtered_tmp" | ||
| fi | ||
| done < "$tmpfile" | ||
|
|
||
| mapfile -t tokens < <(awk 'NF && !seen[$0]++ { print }' "$filtered_tmp") | ||
| rm -f "$filtered_tmp" || true | ||
|
|
||
| joined="" | ||
| if [ "${#tokens[@]}" -gt 0 ]; then | ||
| joined=$(printf '%s,' "${tokens[@]}") | ||
| joined=${joined%,} | ||
| fi | ||
|
|
||
| # Fix missing commas between concatenated forge/ entries | ||
| if [ -n "$joined" ]; then | ||
| joined="$(perl -pe 's/\s+(?=forge\/)//g' <<< "$joined")" | ||
| joined="$(perl -pe 's/([^,])(?=forge\/)/\1,/g' <<< "$joined")" | ||
| fi | ||
|
|
||
| if [ -n "$joined" ]; then | ||
| contains_crashed_tests=true | ||
| crashed_tests="$joined" | ||
| fi | ||
|
|
||
| # Count crashed tokens and group into jobs | ||
| crashed_test_count=${#tokens[@]} | ||
|
|
||
| if [ "$crashed_test_count" -gt 0 ]; then | ||
| crashed_job_count=$(( (crashed_test_count + number_crashed_tests_per_job - 1) / number_crashed_tests_per_job )) | ||
| crashed_job_ids=$(seq -s ',' 1 "$crashed_job_count") | ||
| crashed_job_ids_formatted="[$crashed_job_ids]" | ||
| else | ||
| crashed_job_count=0 | ||
| crashed_job_ids_formatted="[]" | ||
| fi | ||
|
|
||
| echo "crashed-tests<<EOF" >> "$GITHUB_OUTPUT" | ||
| echo "$crashed_tests" >> "$GITHUB_OUTPUT" | ||
| echo "EOF" >> "$GITHUB_OUTPUT" | ||
| echo "contains-crashed-tests=${contains_crashed_tests}" >> "$GITHUB_OUTPUT" | ||
| echo "crashed-test-cnt=${crashed_job_count}" >> "$GITHUB_OUTPUT" | ||
| echo "crashed-test-ids=${crashed_job_ids_formatted}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: show outputs | ||
| run: | | ||
| echo "crashed-tests (raw): ${{ steps.extract-crashed-tests.outputs.crashed-tests }}" | ||
| echo "contains-crashed-tests: ${{ steps.extract-crashed-tests.outputs.contains-crashed-tests }}" | ||
| echo "crashed-test-cnt: ${{ steps.extract-crashed-tests.outputs.crashed-test-cnt }}" | ||
| echo "crashed-test-ids: ${{ steps.extract-crashed-tests.outputs.crashed-test-ids }}" | ||
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.