Skip to content

ESLint pipeline failures for JavaScript files outside frontend directories

Summary

The eslint-changed-files job fails in pipelines when JavaScript files are added outside frontend directories (e.g., in doc-locale/) because it has a hard dependency on generate-apollo-graphql-schema, which doesn't run for non-frontend paths.

This can cause pipeline failures such as https://gitlab.com/gitlab-org/gitlab/-/pipelines/2110165323

Unable to create pipeline
    'eslint-changed-files' job needs 'generate-apollo-graphql-schema' job, but 'generate-apollo-graphql-schema' does not exist in the pipeline. This might be because of the only, except, or rules keywords. To need a job that sometimes does not exist in the pipeline, use needs:optional.

Root Cause Analysis

  1. eslint-changed-files triggers on ANY JavaScript file (*.js) via the Ruby script tooling/ci/changed_files.rb
  2. generate-apollo-graphql-schema seems to only for frontend-specific paths defined in *code-backstage-patterns
  3. .eslint-base has a hard dependency: needs: [generate-apollo-graphql-schema]

Suggested Fix

A suggested fix may be to update static-analysis.gitlab-ci.yml to make this dependency optional for eslint. A concern with this approach may be that if other rules/config changed we may end up with a situation where we don't use this apollo schema when we should have.

+    - job: generate-apollo-graphql-schema
+      optional: true
Edited by 🤖 GitLab Bot 🤖