cisagov / skeleton-generic

A generic skeleton project for quickly getting a new cisagov project started.
Creative Commons Zero v1.0 Universal
13 stars 11 forks source link

Fix: Build Workflow Runs All Jobs Twice #175

Closed Matthew-Grayson closed 2 months ago

Matthew-Grayson commented 3 months ago

๐Ÿ—ฃ Description

EDIT: Add conditional to build jobs so they do not run a second time for internal PRs. Remove on: pull_request logic from build.yml.

๐Ÿ’ญ Motivation and context

This logic causes build jobs to run twice on each pull request. This can cause rate limit issues when GitHub Actions is queuing jobs.

The on: push logic by itself runs jobs when:

  1. A contributor pushes to a branch
  2. A contributor creates a pull request
  3. A codeowner merges a pull request

The on: pull_request logic runs jobs when:

  1. A contributor creates a pull request
  2. A contributor pushes to a branch connected to a PR

Closes #174

๐Ÿงช Testing

๐Ÿ“ท Screenshots (if appropriate)

image

โœ… Pre-approval checklist

โœ… Pre-merge checklist

โœ… Post-merge checklist

mcdonnnj commented 3 months ago

Per the documentation for push and pull_request events, the reason you see two runs is because one is for the pull request and the other is for the latest commit for the branch. If you wait for the push Actions to complete and then open a pull request you will see that the only new Actions work generated is for the pull_request event. I'm not sure how the rest of my team feels but I see no reason to change this configuration.

jsf9k commented 3 months ago

Per the documentation for push and pull_request events, the reason you see two runs is because one is for the pull request and the other is for the latest commit for the branch. If you wait for the push Actions to complete and then open a pull request you will see that the only new Actions work generated is for the pull_request event. I'm not sure how the rest of my team feels but I see no reason to change this configuration.

See also here.

Matthew-Grayson commented 3 months ago

@mcdonnnj @jsf9k Thank you for your attention on this. The motivation is to clean up the number of checks in GitHub Actions. These add noise and bog down the queue when many PRs are submitted at once (say by dependabot).

I pushed changes based on your feedback that prevent duplicate jobs, but still run jobs on PRs from a fork. But, I understand if you feel this change is an unnecessary risk to functionality. Please see https://github.com/cisagov/skeleton-generic/pull/175/commits/17af8a8bc2dbd2f9b3f7fc9d6a2ae89755901f92.

jsf9k commented 3 months ago

I pushed changes based on your feedback that prevent duplicate jobs, but still run jobs on PRs from a fork. But, I understand if you feel this change is an unnecessary risk to functionality. Please see 17af8a8.

I'm not averse to a change like this to reduce the contention for GH Actions runners, provided that is satisfies the conditions I enumerated in #174. That said, this current implementation is pretty ugly. The conditional would have to be added manually to every single job in every single workflow. Can we do something cleaner and less invasive?

mcdonnnj commented 3 months ago

I pushed changes based on your feedback that prevent duplicate jobs, but still run jobs on PRs from a fork. But, I understand if you feel this change is an unnecessary risk to functionality. Please see 17af8a8.

I'm not averse to a change like this to reduce the contention for GH Actions runners, provided that is satisfies the conditions I enumerated in #174. That said, this current implementation is pretty ugly. The conditional would have to be added manually to every single job in every single workflow. Can we do something cleaner and less invasive?

@jsf9k I think the idea is that if the diagnostics job is gated then other jobs, which rely on it, will not be able to start. I'm still of the opinion that if a downstream project wants to modify this that is their prerogative but the default is fine as it is.

Matthew-Grayson commented 3 months ago

@jsf9k I think the idea is that if the diagnostics job is gated then other jobs, which rely on it, will not be able to start. I'm still of the opinion that if a downstream project wants to modify this that is their prerogative but the default is fine as it is.

Right. Understood.

mcdonnnj commented 2 months ago

Per conversations here, in #174, and within our team we will not be incorporating this change into the skeleton.