acts icon indicating copy to clipboard operation
acts copied to clipboard

ci: Only run main ubuntu builds on WIP PRs

Open paulgessinger opened this issue 2 years ago • 9 comments

paulgessinger avatar Sep 02 '22 08:09 paulgessinger

@benjaminhuth one problem with this approach is that removing the WIP label does not trigger the previously skipped workflows. What do you think?

paulgessinger avatar Sep 02 '22 11:09 paulgessinger

Hmm I'm not an expert on github actions, but could this not be done with this?

https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#label

To trigger these things when the label WIP is deleted...

benjaminhuth avatar Sep 02 '22 12:09 benjaminhuth

Ah no sorry, that seems to be related to the global creation and deletion...

benjaminhuth avatar Sep 02 '22 12:09 benjaminhuth

@benjaminhuth I fear that only runs when you add/remove/modify a label for the repo but not for the PR

@paulgessinger I think it is okay. we can always trigger by commit. manual trigger would be a nice solution but might not be worth the time implementing it right away

andiwand avatar Sep 02 '22 12:09 andiwand

https://stackoverflow.com/questions/62325286/run-github-actions-when-pull-requests-have-a-specific-label

This seems to adress this... If we add

on:
  pull_request:
    types: [ unlabeled ]

would this work?

Maybe it would always trigger if we unlabel a PR with any label then, but that should be rare cases?

benjaminhuth avatar Sep 02 '22 12:09 benjaminhuth

however, its maybe a bit unconvenient to require a empty commit in some cases, but often there will be anyhow a sync with main necessary and that should trigger it then...

benjaminhuth avatar Sep 02 '22 12:09 benjaminhuth

Triggering the CI on unlabel might put more load on the CI than running all jobs on WIP PRs. Since we do squash & merge anyway, the empty commits should at least not show up after a PR is merged, but I agree it's suboptimal.

paulgessinger avatar Sep 02 '22 12:09 paulgessinger

@paulgessinger I tried a bit on my fork to set this up correctely, and I think I found a way to express this:

On the requirements the push trigger must be removed, so that the pull_request: synchronized is triggered. Then we must specify all triggers for pull request:

on:
  pull_request:
    branches:
      - main
      - 'release/**'
      - 'develop/**'
    paths-ignore:
      - "docs/**"
    types:
      - opened
      - reopened
      - synchronize 
      - unlabeled

The condition for the linux_ubuntu job then must be:

linux_ubuntu:
  if: "${{ (github.event.action != 'unlabeled') || (github.event.action == 'unlabeled' && github.event.label.name == ':construction: WIP') }}"

The one for the non-WIP-jobs is:

only_if_not_wip:
  if: "${{ (github.event.action != 'unlabeled' && !contains(github.event.pull_request.labels.*.name, ':construction: WIP')) || (github.event.action == 'unlabeled' && github.event.label.name == ':construction: WIP') }}"

The only other difference is that due to the removement of the push label, the CI won't be triggered on push onto branches of the repo that not have a PR associated anymore. But since we only work with PRs on the main repo, this should be fine, right?

benjaminhuth avatar Sep 05 '22 09:09 benjaminhuth

This issue/PR has been automatically marked as stale because it has not had recent activity. The stale label will be removed if any interaction occurs.

stale[bot] avatar Oct 12 '22 12:10 stale[bot]