Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

YAML anchors cause linter failure when paths is set #18

@staylor

Description

@staylor

Drone configs allow YAML anchors:

drone_gcs_cache_common: &drone_gcs_cache_common
  image: homerovalle/drone-gcs-cache
  settings:
    bucket: foo
    restore: true
  environment:
    GCS_CACHE_JSON_KEY:
      from_secret: gcs_cache_json_key

then in practice:

- name: restore_master_caches
  <<: *drone_gcs_cache_common
  when:
    event: push
    branch: master

- name: restore_pr_caches
  <<: *drone_gcs_cache_common
  when:
    event: pull_request

However, if combined with use of when: paths:, YAML anchors declared in the config cause Linter errors - they are apparently interpreted as steps with no name attribute.

Given:

kind: pipeline
type: docker
name: test

drone_gcs_cache_common: &drone_gcs_cache_common
  image: homerovalle/drone-gcs-cache
  settings:
    bucket: foo
    restore: true

steps:
- name: foo
  image: node:12.14.1
  commands: 
  - npm i
  when:
    paths:
      include:
      - README.md

This will break immediately when run by Drone:

Linter: invalid or missing step name

If the when block is removed completely: everything works.
when also works when paths is not present.

Help?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions