drone / go-convert

Package convert provides tools for converting pipeline configuration files to the Drone format.
Apache License 2.0
10 stars 8 forks source link

[downgrade] conditions logic is not accurate #80

Open jimsheldon opened 1 year ago

jimsheldon commented 1 year ago

Some of the downgrade condition/trigger logic is wrong.

For example, <+codebase.commitRef> =~ "refs/heads/master" is not valid, it should be <+codebase.commitRef> == "refs/heads/master".

We need to investigate the correct condition and trigger logic.

jimsheldon commented 1 year ago

I think we need logic that can handle wildcards.

For example, we can have a drone condition like this:

- name: example
  image: alpine
  commands: echo example
  when:
    branch:
    - example-*

To do this in JEXL, we need to use =~ like this:

<+trigger.branch> =~ "example-.*"

But a drone pipeline like this:

- name: example
  image: alpine
  commands: echo example
  when:
    branch:
    - example

Would use JEXL like this:

<+trigger.branch> == "example"
jimsheldon commented 1 year ago

Improved JEXL conditions in #81

jimsheldon commented 10 months ago

For Drone, we would be trying to replicate the behavior of the doublestar library.

Drone uses the drone-yaml library for yaml parsing https://github.com/harness/drone/blob/master/go.mod#L18

drone-yaml uses an old version 1.1.1 https://github.com/drone/drone-yaml/blob/master/go.mod#L6C31-L6C31

This is a relatively small library with less than 500 lines of code https://github.com/bmatcuk/doublestar/blob/v1.1.1/doublestar.go

Perhaps we can use this logic in the conversion.