Condition alternatives and/or step concurrency limit

Hi,

I’m working on a TypeScript monorepo using Drone for CICD. There’s a main branch, and whenever a PR is accepted onto main, the built artifacts shall be published to some private package registry. It seems to me it’s a classical need, and also the publish step should not be run concurrently. First, am I wrong?

I’ve tested two .drone.yml so far, and neither satisfy me:

  1. with two pipelines in the file, the former builds and tests with no condition, and the latter builds and publishes only on trigger push on the main branch, with concurrency: limit: 1, and a dependency on the former. The problem is that the whole thing takes quite some time because both pipelines have to install dependencies (they are cached, but still) and to transpile TS to JS (which right now are not cached because there is a dist directory in every package directory, so they would need to be extracted and restored in place).
  2. with one pipeline where some steps (e.g. publish) have a condition for push event + main branch. The problem is the publish step has to be concurrency-limited, so right now the only way is to limit the whole pipeline. For a PR, there’s one job for the push event (testing the branch) and one for the pull_request event (testing a potential merge), and so they run sequentially, which is unfortunate.

The process could be improved in two ways:

  1. Obviously, putting a concurrency limit on steps would be the best thing to do.
  2. Or, having one pipeline which runs only on push on main, and an other on the opposite, i.e. pull_request OR (push AND main branch). This latter expression is not possible right now. I propose to add a new node OR so to make such constructs possible. It could look like:
trigger:
  or:
    - event:
      - pull_request
    - branch:
      - main
      event:
      - push

What do you think?

Thanks.

Globally limiting pipeline step concurrency would be a nice feature, however, it cannot be easily achieved with Drone’s current architecture. It would require significant changes to our pipeline engine. If we ever plan to re-write or re-design our pipeline engine we can consider this feature, but for now, this remains out of scope for us.

This is possible today.

This below pipeline would only run on pull request (refs/pulls/**) or push to main (refs/heads/main)

trigger:
  refs:
  - refs/pull/**
  - refs/heads/main

or alternatively you can use Starlark scripting or Jsonnet scripting to define your pipeline, as opposed to yaml. If you define your pipeline in Starlark you have the power of a full scripting language.

My bad, I meant: (pull_request on any branch) OR (push on any branch except main). But maybe it’s possible as well using exclude?

Off-topic while I have your attention: I can’t find any explanation about include in condition. How is branch: - main different from branch: include: -main?

Regarding Jsonnet, I thought it was scoped within a pipeline, but looking at drone-jsonnet-config/.drone.jsonnet at master · drone/drone-jsonnet-config · GitHub it seems to render multiple pipelines, good to know!