Skip to content

Commit

Permalink
revert: "feat(ci): Run lint --fix with dirtybot (#17538)" (#17617)
Browse files Browse the repository at this point in the history
Revert "feat(ci): Run `lint --fix` with dirtybot (#17538)"

This reverts commit 91ed8b9.
  • Loading branch information
AndesKrrrrrrrrrrr authored Jan 22, 2025
1 parent 6d2b9ea commit 27c57ef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 70 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,6 @@ jobs:
matrix: ${{ fromJson(needs.prepare.outputs.LINT_CHUNKS) }}
steps:
- uses: actions/checkout@v4
if: ${{ github.event_name == 'pull_request' }}
# Needed for doing git commit in git-check-dirty script
with:
token: ${{ secrets.DIRTY_FIX_BOT_TOKEN }}
ref: ${{ github.event.pull_request.head.ref }}
- uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
Expand All @@ -399,19 +394,6 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
keys: ${{ needs.prepare.outputs.CACHE_KEYS }}
enable-cache: 'node_modules,generated-files'
- name: Lintfix
if: ${{ !contains(github.event.pull_request.labels.*.name, 'dirty bypass') }}
run: |
set -euo pipefail
echo "Running lint --fix for affected projects: ${AFFECTED_PROJECTS}"
./infra/scripts/ci/git-check-dirty.sh \
-p "/" \
-a "nx run-many --target lint --fix --parallel ${MAX_JOBS} --projects=${AFFECTED_PROJECTS//[[\]]}" \
-o "dirtybot" \
-r || {
echo "Error: Lintfix failed. Check the logs above for details." >&2
exit 1
}
- name: Linting
run: ./scripts/ci/run-in-parallel-native.sh lint

Expand Down
55 changes: 3 additions & 52 deletions infra/scripts/ci/git-check-dirty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,6 @@ rel_path=$1
abs_path=$DIR/$rel_path
action=$2
owner="${3:-github actions}"
check_mode="${CHECK_MODE:-}"
run_mode="${RUN_MODE:-}"

while getopts "p:a:o:crh" opt; do
case $opt in
p) abs_path="$DIR/$OPTARG" ;;
a) action="$OPTARG" ;;
o) owner="$OPTARG" ;;
c) check_mode=true ;;
r) run_mode=true ;;
h)
cat <<EOF
Usage:
$0 <path> <action> <owner>
$0 [options]
The options -p, -a, -o are required if using the second form
Options:
-p <path> path to the file to check
-a <action> action to run
-o <owner> owner to commit as
-c check mode
-r run mode
EOF
exit 0
;;
*) echo "Invalid option: -$OPTARG" >&2 ;;
esac
done

for opt in "$abs_path" "$action" "$owner"; do
if [[ -z "$opt" ]] || [[ "$opt" = -* ]]; then
echo "A required argument is missing" >&2
exit 1
fi
done

commit_as_github_actions() {
git config user.name 'github-actions[bot]'
Expand All @@ -54,22 +17,10 @@ commit_as_dirty_bot() {
git config user.email '[email protected]'
}

if [[ "$run_mode" == true ]]; then
# Split action into array safely:
IFS=' ' read -r -a action_array <<<"$action"
if ! yarn "${action_array[@]}"; then
echo "Error: Failed to execute yarn command: ${action_array[*]}" >&2
exit 1
fi
fi

if [[ "$check_mode" == true ]] && ! git diff --quiet; then
echo "found unstaged files from $action, aborting"
exit 1
fi
if [[ $(git diff --stat "$abs_path") != '' ]]; then
echo "changes found in $rel_path that will be commited"
git diff "$abs_path" || true
git diff "$abs_path"
git add "$abs_path"
if [ "$owner" == "github actions" ]; then
commit_as_github_actions
elif [ "$owner" == "dirtybot" ]; then
Expand All @@ -78,7 +29,7 @@ if [[ $(git diff --stat "$abs_path") != '' ]]; then
echo "Error: Unknown owner!"
exit 1
fi
git commit -am "chore: $action update dirty files"
git commit -m "chore: $action update dirty files"
git push
else
echo "found no unstaged files from $action, nothing to commit"
Expand Down

0 comments on commit 27c57ef

Please sign in to comment.