Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[downgrade] conditions logic is not accurate #80

Open
jimsheldon opened this issue Apr 5, 2023 · 3 comments
Open

[downgrade] conditions logic is not accurate #80

jimsheldon opened this issue Apr 5, 2023 · 3 comments
Labels
bug Something isn't working downgrade

Comments

@jimsheldon
Copy link
Collaborator

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 jimsheldon added bug Something isn't working downgrade labels Apr 5, 2023
@jimsheldon
Copy link
Collaborator Author

jimsheldon commented Apr 6, 2023

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
Copy link
Collaborator Author

Improved JEXL conditions in #81

@jimsheldon
Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working downgrade
Projects
None yet
Development

No branches or pull requests

1 participant