mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
🎯 ci: Update ESLint Workflow to target api/ and client/ changes (#5771)
This commit is contained in:
parent
d90c9c4b77
commit
71c30a3640
1 changed files with 7 additions and 43 deletions
50
.github/workflows/eslint-ci.yml
vendored
50
.github/workflows/eslint-ci.yml
vendored
|
|
@ -1,10 +1,14 @@
|
||||||
name: ESLint Code Quality Checks
|
name: ESLint Code Quality Checks
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- dev
|
- dev
|
||||||
- release/*
|
- release/*
|
||||||
|
paths:
|
||||||
|
- 'api/**'
|
||||||
|
- 'client/**'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
eslint_checks:
|
eslint_checks:
|
||||||
|
|
@ -29,22 +33,8 @@ jobs:
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
# Use a paths filter (v3) to detect changes in JavaScript/TypeScript files,
|
# Run ESLint on changed files within the api/ and client/ directories.
|
||||||
# but only consider files that are added or modified (ignoring deleted files).
|
|
||||||
- name: Filter changed files for ESLint
|
|
||||||
id: file_filter
|
|
||||||
uses: dorny/paths-filter@v3
|
|
||||||
with:
|
|
||||||
filters: |
|
|
||||||
eslint:
|
|
||||||
- added|modified: '**/*.js'
|
|
||||||
- added|modified: '**/*.jsx'
|
|
||||||
- added|modified: '**/*.ts'
|
|
||||||
- added|modified: '**/*.tsx'
|
|
||||||
|
|
||||||
# Run ESLint only if relevant files have been added or modified.
|
|
||||||
- name: Run ESLint on changed files
|
- name: Run ESLint on changed files
|
||||||
if: steps.file_filter.outputs.eslint == 'true'
|
|
||||||
env:
|
env:
|
||||||
SARIF_ESLINT_IGNORE_SUPPRESSED: "true"
|
SARIF_ESLINT_IGNORE_SUPPRESSED: "true"
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -52,9 +42,8 @@ jobs:
|
||||||
BASE_SHA=$(jq --raw-output .pull_request.base.sha "$GITHUB_EVENT_PATH")
|
BASE_SHA=$(jq --raw-output .pull_request.base.sha "$GITHUB_EVENT_PATH")
|
||||||
echo "Base commit SHA: $BASE_SHA"
|
echo "Base commit SHA: $BASE_SHA"
|
||||||
|
|
||||||
# List files changed between the base commit and current HEAD,
|
# List files changed between the base commit and HEAD, filtering only those in api/ or client/
|
||||||
# but only include files that are not deleted (ACMRTUXB: A, C, M, R, T, U, X, B).
|
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB "$BASE_SHA" HEAD | grep -E '^(api|client)/.*\.(js|jsx|ts|tsx)$')
|
||||||
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB "$BASE_SHA" HEAD | grep -E '\.(js|jsx|ts|tsx)$')
|
|
||||||
echo "Files to lint:"
|
echo "Files to lint:"
|
||||||
echo "$CHANGED_FILES"
|
echo "$CHANGED_FILES"
|
||||||
|
|
||||||
|
|
@ -64,31 +53,6 @@ jobs:
|
||||||
--format @microsoft/eslint-formatter-sarif \
|
--format @microsoft/eslint-formatter-sarif \
|
||||||
--output-file eslint-results.sarif $CHANGED_FILES || true
|
--output-file eslint-results.sarif $CHANGED_FILES || true
|
||||||
|
|
||||||
# If no JavaScript/TypeScript files were added or modified,
|
|
||||||
# create a valid (non-empty) SARIF file containing one run.
|
|
||||||
- name: Create empty SARIF results file
|
|
||||||
if: steps.file_filter.outputs.eslint != 'true'
|
|
||||||
run: |
|
|
||||||
cat << 'EOF' > eslint-results.sarif
|
|
||||||
{
|
|
||||||
"version": "2.1.0",
|
|
||||||
"$schema": "https://json.schemastore.org/sarif-2.1.0.json",
|
|
||||||
"runs": [
|
|
||||||
{
|
|
||||||
"tool": {
|
|
||||||
"driver": {
|
|
||||||
"name": "ESLint",
|
|
||||||
"informationUri": "https://eslint.org",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"rules": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"results": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
- name: Upload analysis results to GitHub
|
- name: Upload analysis results to GitHub
|
||||||
uses: github/codeql-action/upload-sarif@v3
|
uses: github/codeql-action/upload-sarif@v3
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue