Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
18af2cf
intentionally create a useOnyx canBeMissing error
MacroLens May 28, 2025
0d5685c
scripts: add lintChanged.sh
MacroLens May 28, 2025
eefdc1e
github-actions: lint-changed change depth to 30000
MacroLens May 28, 2025
248e644
fix: change the checkout action to fetch further
MacroLens May 28, 2025
05e2932
fix-wip: add fetch back
MacroLens May 28, 2025
bdc335c
scripts: lintChanged.sh fix style and clean logic
MacroLens May 29, 2025
97005d0
scripts: lintChanged.sh unify style
MacroLens May 29, 2025
4f9bc67
scripts: lintChanged.sh add CI/local checks
MacroLens May 29, 2025
62eedc9
workflows: lint-changed: add commit count logic
MacroLens May 29, 2025
005dc2e
workflows: lint-changed: shellcheck fixes
MacroLens May 29, 2025
b0b50e5
Revert "workflows: lint-changed: shellcheck fixes"
MacroLens May 29, 2025
487aa6b
workflows: lint-changed: fix the shellcheck errors
MacroLens May 29, 2025
b99a4e0
workflows: lint-changed remove checkout condition
MacroLens May 29, 2025
1028953
workflows: lint-changed.yml replace max logic
MacroLens May 29, 2025
f3be8ab
scripts: lintChanged.sh: handle large file count
MacroLens May 29, 2025
b90f49c
Use tag instead of app version for release link
roryabraham May 21, 2025
1e48052
trigger workflows, will revert
MacroLens May 30, 2025
a1ea4f3
Revert "trigger workflows, will revert"
MacroLens May 30, 2025
38564eb
apply suggestions
MacroLens Jun 2, 2025
b57c422
scripts: lintChanged: remove array logic
MacroLens Jun 2, 2025
2dc41f4
Update .github/workflows/lint-changed.yml
MacroLens Jun 2, 2025
7a15186
Apply suggestions from code review
MacroLens Jun 3, 2025
5e3491e
scripts: lintChanged.sh: add newline EOF
MacroLens Jun 3, 2025
b7e99b0
Revert "intentionally create a useOnyx canBeMissing error"
MacroLens Jun 3, 2025
5bfda6f
Merge remote-tracking branch 'upstream/main' into fix_62656_lint_changed
MacroLens Jun 3, 2025
54addb8
Merge remote-tracking branch 'upstream/main' into fix_62656_lint_changed
MacroLens Jun 3, 2025
03cf5d5
fix: scripts: lintChanged.sh: unshallow branch
MacroLens Jun 3, 2025
6f37361
cspell config: Add unshallow to the words
MacroLens Jun 3, 2025
18c3c6d
lint-changed: fix fetch-depth
MacroLens Jun 4, 2025
ca3f78d
Revert "cspell config: Add unshallow to the words"
MacroLens Jun 4, 2025
8cc3ee0
Apply suggestions from code review
MacroLens Jun 5, 2025
db58cf1
workflows: lint-changed.yml: remove call to api
MacroLens Jun 5, 2025
7f455f3
Merge remote-tracking branch 'upstream/main' into fix_62656_lint_changed
MacroLens Jun 5, 2025
5b73da2
workflows: lint-changed: add comment to explain +2
MacroLens Jun 5, 2025
de2156f
workflows: lint-changed: add more detailed comment
MacroLens Jun 6, 2025
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
36 changes: 32 additions & 4 deletions .github/workflows/lint-changed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,47 @@ jobs:
if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }}
runs-on: ubuntu-latest
steps:
- name: Count commits between merge base and HEAD
id: count
run: |
# Compare the base commit and HEAD to get the count of commits after base
# up to and including HEAD. Add 2 to this total when fetching history.
#
# When opening a PR, GitHub will create a merge commit that squashes
# your changes for use in the workflow. So your history locally
# may look like
# o---o---o---B - development
# /
# ---o---1---C---o---o---A - main
# Note that the `1` is the merge-base of development and main. The
# number of commits after `1` upto and including `A` is 4.
# In the workflow, GitHub squashs development, so it becomes:
# ---o---1---C---o---o---A - main
# \--M - PR branch
# Where `M`` is the new squashed commit. To fetch enough history to
# include the merge base, we need to fetch `M`, `A` through `C` and
# `1` for total of 4+2=6 commits. The +2 commits accounts for the
# base `1` and merge commit `M`.
RAW_COUNT="$(gh api "repos/$REPO/compare/${BASE}...main" | jq -r '.total_commits')"
ADJUSTED_COUNT=$((RAW_COUNT + 2))
Comment thread
rafecolton marked this conversation as resolved.
echo "count=$ADJUSTED_COUNT" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ github.token }}
BASE: ${{ github.event.pull_request.base.sha }}
REPO: ${{ github.repository }}

- name: Checkout
# v4
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
fetch-depth: ${{ fromJSON(steps.count.outputs.count) }}

- name: Setup Node
uses: ./.github/actions/composite/setupNode
with:
IS_DESKTOP_BUILD: true

- name: Run ESLint to check for deprecation warnings
run: |
# This will just fetch the latest commit from main
git fetch origin main --no-tags --depth=1

# shellcheck disable=SC2046
npm run lint-changed
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"perf-test": "NODE_OPTIONS=--experimental-vm-modules npx reassure",
"typecheck": "NODE_OPTIONS=--max_old_space_size=8192 tsc",
"lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=0 --cache --cache-location=node_modules/.cache/eslint",
"lint-changed": "NODE_OPTIONS=--max_old_space_size=8192 eslint --max-warnings=0 --config ./.eslintrc.changed.js $(git diff --diff-filter=AMR --name-only origin/main HEAD -- \"*.ts\" \"*.tsx\")",
"lint-changed": "NODE_OPTIONS=--max_old_space_size=8192 ./scripts/lintChanged.sh",
"lint-watch": "npx eslint-watch --watch --changed",
"shellcheck": "./scripts/shellCheck.sh",
"prettier": "prettier --write .",
Expand Down
42 changes: 42 additions & 0 deletions scripts/lintChanged.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# Lints .ts and .tsx files that have changed in this branch

set -eu

TOP="$(realpath "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)/..")"
readonly TOP
source "${TOP}/scripts/shellUtils.sh"

# Ensure this script is running inside an npm run context
if [[ -z "${npm_lifecycle_event:-}" ]]; then
info "Re-executing this script from an npm context"
exec npx -c "NODE_OPTIONS=--max_old_space_size=8192 ${BASH_SOURCE[0]} $*"
fi

# Fetch the commit history to include the merge-base commit
info "Fetching origin/main"
git fetch origin main --no-tags
Comment thread
rafecolton marked this conversation as resolved.

MERGE_BASE_SHA_HASH="$(git merge-base origin/main HEAD)"
Comment thread
MacroLens marked this conversation as resolved.
readonly MERGE_BASE_SHA_HASH

# Check if output is empty or malformed
if [[ -z "$MERGE_BASE_SHA_HASH" ]] || ! [[ "$MERGE_BASE_SHA_HASH" =~ ^[a-fA-F0-9]{40}$ ]]; then
error "git merge-base returned unexpected output: $MERGE_BASE_SHA_HASH"
exit 1
fi

# Get the diff output and check status
if ! GIT_DIFF_OUTPUT="$(git diff --diff-filter=AMR --name-only "$MERGE_BASE_SHA_HASH" HEAD -- '*.ts' '*.tsx')"; then
error "git diff failed - output: $GIT_DIFF_OUTPUT"
exit 1
fi

# Run eslint on the changed files
if [[ -n "$GIT_DIFF_OUTPUT" ]] ; then
# shellcheck disable=SC2086 # For multiple files in variable
eslint --max-warnings=0 --config ./.eslintrc.changed.js $GIT_DIFF_OUTPUT
else
info "No TypeScript files changed"
fi