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

improve lint workflow to avoid fast fail #1378

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Changes from all commits
Commits
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
16 changes: 5 additions & 11 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,12 @@ jobs:

- name: Lint Changed Files
run: |
jq -r '.[]' ${HOME}/files_modified.json ${HOME}/files_added.json | sort | uniq > /tmp/changed_files.txt
CHANGED_FILES=$(cat /tmp/changed_files.txt)
echo "These are the changed files: $CHANGED_FILES"
CHANGED_FILES=($(jq -r '.[]' ${HOME}/files_modified.json ${HOME}/files_added.json | grep '.\+.\(js\|ts\|tsx\)$' | sort -u))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember one of the issues we were trying to tackle was when a file is renamed, both 'modified' and 'added' shas will show the same renamed file which lead to later lint that file more than once, is it? @RyanL1997 , is this considered in the new change as I saw uniq was removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer sort -u over sort | uniq. they have the same output

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mengweieric Yes, that shouldn't be a problem. Since the above step Check Changes of Files has filtered the output

if [[ -n "$CHANGED_FILES" ]]; then
echo "Linting changed files..."
while IFS= read -r file; do
if [[ $file == *.js || $file == *.ts || $file == *.tsx ]]; then
echo "linting file $file"
yarn lint "$file"
fi
done < /tmp/changed_files.txt
echo 'These are the changed files:'
printf '%s\n' "${CHANGED_FILES[@]}"
yarn lint "${CHANGED_FILES[@]}"
else
echo "No matched files to lint."
fi
working-directory: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}
working-directory: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}
Loading