Skip to content

perf: remove PureReportActionItem and use stable report #128

perf: remove PureReportActionItem and use stable report

perf: remove PureReportActionItem and use stable report #128

Workflow file for this run

name: ESLint check
on:
workflow_call:
pull_request:
types: [opened, synchronize]
branches-ignore: [staging, production]
paths: ['**.js', '**.ts', '**.tsx', '**.json', '**.mjs', '**.cjs', 'config/.editorconfig', 'config/eslint/**', 'scripts/lint.sh', 'scripts/lintChanged.sh', '.watchmanconfig', '.imgbotconfig']
concurrency:
group: ${{ github.ref == 'refs/heads/main' && format('{0}-{1}', github.ref, github.sha) || github.ref }}-lint
cancel-in-progress: true
jobs:
lint:
name: ESLint check
if: ${{ github.event.head_commit.author.name != 'OSBotify' || github.event_name == 'push' }}
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- name: Checkout
# v6
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
# Only use the elevated OSBotify token on the post-merge `workflow_call` run
# (so the auto-commit step below can push to the protected `main` branch).
# PR runs use the default GITHUB_TOKEN so PR code can't borrow push-to-main
# access via the persisted checkout credentials.
token: ${{ github.event_name == 'push' && secrets.OS_BOTIFY_COMMIT_TOKEN || github.token }}
- name: Setup Node
uses: ./.github/actions/composite/setupNode
- name: Remove E/App version from package-lock.json
shell: bash
run: jq 'del(.version, .packages[""].version)' package-lock.json > normalized-package-lock.json
- name: Restore ESLint cache
# v5.0.1
uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb
with:
path: node_modules/.cache/eslint
key: ${{ runner.os }}-eslint-${{ hashFiles('eslint.config.mjs', 'config/eslint/**', 'normalized-package-lock.json') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-eslint-${{ hashFiles('eslint.config.mjs', 'config/eslint/**', 'normalized-package-lock.json') }}-
${{ runner.os }}-eslint-
# ESLint's cache doesn't track cross-file TypeScript dependencies, which can cause stale errors.
# If lint fails, we clear the cache and retry to rule out false positives.
# See: https://typescript-eslint.io/troubleshooting/faqs/eslint/#can-i-use-eslints---cache-with-typescript-eslint
- name: Lint JavaScript and Typescript with ESLint
run: |
if ! npm run lint; then
echo "Lint failed, clearing cache and retrying..."
rm -rf node_modules/.cache/eslint
npm run lint
fi
- name: Save ESLint cache
# v5.0.1
uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb
if: always()
with:
path: node_modules/.cache/eslint
key: ${{ runner.os }}-eslint-${{ hashFiles('eslint.config.mjs', 'config/eslint/**', 'normalized-package-lock.json') }}-${{ github.sha }}
# If lint tightened the seatbelt baseline (i.e. fewer baselined errors than last time),
# commit the updated TSV back to `main` as OSBotify. Only runs under `workflow_call`
# (i.e. invoked from preDeploy.yml, which only triggers on push to main).
- name: Check for tightened eslint-seatbelt baseline
id: seatbelt_diff
if: github.event_name == 'push'
run: |
if git diff --quiet config/eslint/eslint.seatbelt.tsv; then
echo "tightened=false" >> "$GITHUB_OUTPUT"
echo "::notice::eslint.seatbelt.tsv unchanged; skipping auto-commit."
else
echo "tightened=true" >> "$GITHUB_OUTPUT"
fi
- name: Setup git for OSBotify
if: steps.seatbelt_diff.outputs.tightened == 'true'
uses: Expensify/GitHub-Actions/setupGitForOSBotify@main
with:
OP_VAULT: ${{ vars.OP_VAULT }}
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
SETUP_AS_APP: false
# If the push races with another commit to `main`, let this step fail.
# The next `push: main` lint run will re-tighten the baseline and try
# again; no need to retry here.
- name: Auto-commit tightened eslint-seatbelt baseline
if: steps.seatbelt_diff.outputs.tightened == 'true'
continue-on-error: true
run: |
git add config/eslint/eslint.seatbelt.tsv
git commit -m "Auto-tighten eslint-seatbelt baseline"
git push origin main