Skip to content

Update `cache` keyword for the JSON schema

Mireya Andres requested to merge update-json-schema-cache-keyword into master

What does this MR do and why?

For #365839 (closed).

Updates the JSON schema with the following:

  • Removes deprecated cache_entry keyword.
  • Adds cache:key, cache:paths, cache:policy, cache:untracked

Note: There is an issue with adding negative tests for the JSON schema, so I had to separate them into different files for now. See #381535 (closed).

Positive tests are not affected, so all valid test cases can still live in one file.

Screenshots or screen recordings

Valid YAML Invalid YAML
Valid YAML Invalid YAML

How to set up and validate locally

  1. Enable the schema_linting feature flag.

  2. Go to the pipeline editor (CI/CD > Editor).

  3. Copy paste the content of spec/frontend/editor/schema/ci/yaml_tests/positive_tests/cache.yml to the editor. There should be no linting errors.

  4. Copy paste the following content. Linting errors will show up in the editor.

    invalid-cache:
      script: echo "This job uses a cache."
      cache:
        key:
          files: package.json
          prefix:
            - binaries-cache-$CI_JOB_NAME
        paths: binaries/*.apk
    
    invalid-cache-2:
      script: echo "This job uses a cache."
      cache:
        key: ..
        paths:
          - vendor/ruby
        untracked: 'true'
        when: 'never'

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports