# This is used by the action https://github.com/dorny/paths-filter (which we have forked to https://github.com/getsentry/paths-filter)

# TODO: There are some meta files that we potentially could ignore for both front/backend,
# as well as some configuration files that should trigger both
frontend_components_lintable: &frontend_components_lintable
  - '**/*.[tj]{s,sx}'

frontend_lintable: &frontend_lintable
  - *frontend_components_lintable
  - '**/tsconfig*.json'
  - '{package,now,vercel}.json'

yarn_lockfile: &yarn_lockfile
  - 'yarn.lock'

eslint_config: &eslint_config
  - '.eslint*'

# `frontend_src` filters on files that are frontend changes excluding
# changes to the tests/ directory.
# If you want to filter on *all* frontend files, use the `frontend_all` filter.
frontend_src: &frontend_src
  - *yarn_lockfile
  - *eslint_config
  - '!(tests)/**/*.[tj]{s,sx}'
  - '**/tsconfig*.json'
  - '{package,now,vercel}.json'
  - '**/*.less'
  - 'static/**'
  - 'fixtures/search-syntax/**/*'
  - '.github/workflows/frontend.yml'

frontend_all: &frontend_all
  - *frontend_src
  - '**/*.[tj]{s,sx}'

frontend_modified_lintable:
  - added|modified: *frontend_lintable

frontend_components_modified_lintable:
  - added|modified: *frontend_components_lintable

# Also used in `getsentry-dispatch.yml` to dispatch backend tests on getsentry
backend_dependencies: &backend_dependencies
  - 'requirements-*.txt'

backend_build_changes: &backend_build_changes
  # If you change this line make sure that workflows using this action (e.g. acceptance, api_docs)
  # *and* file-filters would be updated as well
  - '.github/actions/setup-sentry/action.yml'
  - '.github/workflows/backend.yml'
  - '.pre-commit-config.yaml'
  - 'Makefile'
  - 'pyproject.toml'

# `backend_src` filters on files that are backend changes excluding
# changes to the tests/ directory.
# If you want to filter on *all* backend files, use the `backend_all` filter.
backend_src: &backend_src
  - *backend_build_changes
  - *backend_dependencies
  - '!(tests)/**/*.py'
  - '**/*.sh'
  - '**/*.pysnap'
  - 'src/sentry/!(static)/**'
  - 'migrations_lockfile.txt'
  - 'config/**/*'
  - 'fixtures/search-syntax/**/*'

backend_all: &backend_all
  - *backend_src
  - '**/*.py'
  - '**/*.pyi'

# This is the ultimate controller for acceptance.yml
acceptance: &acceptance
  - *frontend_all
  - *backend_all
  # This is verbose because backend_build_changes includes it, however,
  - '.github/actions/setup-sentry/action.yml'
  - '.github/workflows/acceptance.yml'

plugins: &plugins
  - *backend_all
  - 'src/sentry_plugins/**/*.html'

api_docs: &api_docs
  - *backend_all
  - 'api-docs/**'
  - 'tests/apidocs/**'

# This is the ultimate controller for backend.yml
backend_any_type: &backend_any_type
  - *backend_all
  - *api_docs
  - *plugins

migrations_added:
  - added: 'src/sentry/migrations/*'

migrations_modified:
  - modified: 'src/sentry/migrations/*'

# These files will trigger our wokrflow to check if lockfile
# updates are needed
migration_lockfile:
  - *backend_dependencies
  - '**/*.py'
  - .github/workflows/check-if-migration-is-required.yml
  - .github/workflows/scripts/migration-check.sh