github-action-benchmark icon indicating copy to clipboard operation
github-action-benchmark copied to clipboard

Add optional commit SHA in config.

Open jefchien opened this issue 3 years ago • 6 comments

Description

Allows the user to pass in a commit SHA to use instead of relying on the payload or head commit. The main use-case of this is for workflow dispatch runs where the SHA is provided through an input.

This change should be valid based on https://docs.github.com/en/rest/reference/commits#get-a-commit.

jefchien avatar Dec 17 '21 20:12 jefchien

Hi @jefchien

Thank you for your contribution! Could you please explain to me a bit more why would we want to provide the SHA as an input rather than just using the one provided via pull request or fall back to the current commit's sha?

ktrz avatar Dec 21 '21 12:12 ktrz

Hi @ktrz,

So, in my use case, the workflow where the action is used can be triggered by a workflow dispatch where the SHA is provided as an input. This allows us to run the benchmarking after successful CI workflow runs or on selected commits. The issue I've found is that the github.context.ref used in the fall back is the workflow commit SHA rather than the one actually used in the benchmarking. If there's another way to access the workflow dispatch inputs, it might be a better solution. This PR provides an optional field that will supersede any of the other attempts.

jefchien avatar Dec 21 '21 16:12 jefchien

@jefchien

Is running the workflow_dispatch job event an automated process? Instead of providing the commit_sha as input, would you be able to push a branch or tag and run the workflow from there instead?

That way you can make the branch point to the commit you want, and run the workflow from that branch, so that the commit is correct and you don't need to provide the commit_sha as input.

It might be more tricky if your invocation of the workflow_dispatch job is automated (because you'd need a GitHub account to publish it from I guess) so that's why I ask.

NathanielRN avatar Dec 22 '21 19:12 NathanielRN

@NathanielRN

Running the workflow_dispatch is a manual process, but the same workflow is also triggered by a repository_dispatch from a different workflow. That's an interesting workaround. I suppose I could use a GitHub action like https://github.com/marketplace/actions/create-branch to create the branch as part of the workflow and then checkout that branch in the job used to run this action. Actually, that probably won't work since the GitHub context is based on the workflow run.

jefchien avatar Jan 06 '22 20:01 jefchien

Hi @ktrz , any feedback though?

khanhntd avatar Feb 01 '23 00:02 khanhntd

I'll get back to this during the weekend as I have a pretty busy week

ktrz avatar Feb 02 '23 11:02 ktrz