-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Fix: logs step will work when failure is there #36314
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -292,7 +292,7 @@ jobs: | |||||
| fi | ||||||
|
|
||||||
| - name: Add a comment on the PR with new CI failures | ||||||
| if: env.ci_test_failed == 'true' && needs.file-check.outputs.pr != '0' | ||||||
| if: env.ci_test_failed != 'true' && needs.file-check.outputs.pr != '0' | ||||||
| uses: peter-evans/create-or-update-comment@v3 | ||||||
| with: | ||||||
| issue-number: ${{fromJson(needs.file-check.outputs.pr)}} | ||||||
|
|
@@ -306,7 +306,7 @@ jobs: | |||||
| ``` | ||||||
|
|
||||||
| - name: Add a comment on the PR when ci-test-limited is successful | ||||||
| if: env.ci_test_failed != 'true' && needs.file-check.outputs.pr != '0' | ||||||
| if: env.ci_test_failed == 'true' && needs.file-check.outputs.pr != '0' | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inversion of logic detected. Please verify the intended behavior. The condition for adding a comment when the If the intention is to add a comment when the -if: env.ci_test_failed == 'true' && needs.file-check.outputs.pr != '0'
+if: env.ci_test_failed != 'true' && needs.file-check.outputs.pr != '0'Committable suggestion
Suggested change
|
||||||
| uses: peter-evans/create-or-update-comment@v3 | ||||||
| with: | ||||||
| issue-number: ${{fromJson(needs.file-check.outputs.pr)}} | ||||||
|
|
@@ -451,7 +451,7 @@ jobs: | |||||
| fi | ||||||
|
|
||||||
| - name: Add a comment on the PR with new CI failures | ||||||
| if: env.ci_test_failed == 'true' && needs.file-check.outputs.pr != '0' | ||||||
| if: env.ci_test_failed != 'true' && needs.file-check.outputs.pr != '0' | ||||||
| uses: peter-evans/create-or-update-comment@v3 | ||||||
| with: | ||||||
| issue-number: ${{fromJson(needs.file-check.outputs.pr)}} | ||||||
|
|
@@ -465,7 +465,7 @@ jobs: | |||||
| ``` | ||||||
|
|
||||||
| - name: Add a comment on the PR when ci-test-limited-existing-docker-image is success | ||||||
| if: env.ci_test_failed != 'true' && needs.file-check.outputs.pr != '0' | ||||||
| if: env.ci_test_failed == 'true' && needs.file-check.outputs.pr != '0' | ||||||
| uses: peter-evans/create-or-update-comment@v3 | ||||||
| with: | ||||||
| issue-number: ${{fromJson(needs.file-check.outputs.pr)}} | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,48 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Define the folder and postfix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FOLDER="./cypress/e2e" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| POSTFIX="spec.js" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OUTPUT_CSV="output.csv" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Initialize the CSV file with headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "rowNum,folder,filename,tags1,tags2,tags3,tags4,tags5,tags6,tags7,tags8,tags9" > "$OUTPUT_CSV" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Initialize row number counter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rowNum=1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Find all files in the folder with the specified postfix and process each one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| find "$FOLDER" -name "*$POSTFIX" | while read -r file; do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Extract the directory path and filename | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dirpath=$(dirname "$file") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| filename=$(basename "$file") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Extract tags from the describe section using grep and awk | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tags=$(awk -v RS='[{}]' '/tags:/ {gsub(/[["\]]/, ""); print $0}' "$file" | grep -Eo '@tag\.[A-Za-z0-9_-]+') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Remove brackets and split tags into an array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| IFS=',' read -r -a tagArray <<< "$(echo "$tags" | tr '\n' ',' | sed 's/,$//')" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Initialize empty tag variables for up to 9 tags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tags1=""; tags2=""; tags3=""; tags4=""; tags5="" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tags6=""; tags7=""; tags8=""; tags9="" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Assign tags to respective variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ ${#tagArray[@]} -gt 0 ]; then tags1="${tagArray[0]}"; fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ ${#tagArray[@]} -gt 1 ]; then tags2="${tagArray[1]}"; fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ ${#tagArray[@]} -gt 2 ]; then tags3="${tagArray[2]}"; fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ ${#tagArray[@]} -gt 3 ]; then tags4="${tagArray[3]}"; fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ ${#tagArray[@]} -gt 4 ]; then tags5="${tagArray[4]}"; fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ ${#tagArray[@]} -gt 5 ]; then tags6="${tagArray[5]}"; fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ ${#tagArray[@]} -gt 6 ]; then tags7="${tagArray[6]}"; fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ ${#tagArray[@]} -gt 7 ]; then tags8="${tagArray[7]}"; fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ ${#tagArray[@]} -gt 8 ]; then tags9="${tagArray[8]}"; fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+23
to
+39
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tag assignment logic works, but let's make it more efficient and readable. 📝
Here's an example of how you can refactor the code: - # Initialize empty tag variables for up to 9 tags
- tags1=""; tags2=""; tags3=""; tags4=""; tags5=""
- tags6=""; tags7=""; tags8=""; tags9=""
-
- # Assign tags to respective variables
- if [ ${#tagArray[@]} -gt 0 ]; then tags1="${tagArray[0]}"; fi
- if [ ${#tagArray[@]} -gt 1 ]; then tags2="${tagArray[1]}"; fi
- if [ ${#tagArray[@]} -gt 2 ]; then tags3="${tagArray[2]}"; fi
- if [ ${#tagArray[@]} -gt 3 ]; then tags4="${tagArray[3]}"; fi
- if [ ${#tagArray[@]} -gt 4 ]; then tags5="${tagArray[4]}"; fi
- if [ ${#tagArray[@]} -gt 5 ]; then tags6="${tagArray[5]}"; fi
- if [ ${#tagArray[@]} -gt 6 ]; then tags7="${tagArray[6]}"; fi
- if [ ${#tagArray[@]} -gt 7 ]; then tags8="${tagArray[7]}"; fi
- if [ ${#tagArray[@]} -gt 8 ]; then tags9="${tagArray[8]}"; fi
+ # Initialize an array to store tag variables
+ tagVars=("" "" "" "" "" "" "" "" "")
+
+ # Assign tags to respective variables using a loop
+ for i in "${!tagArray[@]}"; do
+ if [ $i -lt 9 ]; then
+ tagVars[$i]="${tagArray[$i]}"
+ fi
+ doneThese changes will make the script more efficient and easier to understand. Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Append the data to the CSV file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "$rowNum,$dirpath,$filename,$tags1,$tags2,$tags3,$tags4,$tags5,$tags6,$tags7,$tags8,$tags9" >> "$OUTPUT_CSV" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Increment row number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rowNum=$((rowNum + 1)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "CSV file created: $OUTPUT_CSV" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inversion of logic detected. Please verify the intended behavior.
The condition for adding a comment on the PR with new CI failures has been changed from checking if
env.ci_test_failedis'true'to checking if it is not'true'. This inverts the logic, causing a comment to be added when there are no CI test failures.If the intention is to add a comment only when there are new CI failures, please revert the condition as follows:
Committable suggestion