Skip to content

Runner Job Started/Completed Hooks#1737

Merged
thboop merged 42 commits intomainfrom
fhammerl/job-start-complete-hooks
Mar 18, 2022
Merged

Runner Job Started/Completed Hooks#1737
thboop merged 42 commits intomainfrom
fhammerl/job-start-complete-hooks

Conversation

@fhammerl
Copy link
Copy Markdown
Contributor

@fhammerl fhammerl commented Mar 9, 2022

This PR implements Job Started and Job completed hooks for reuse. This functionality is in beta, and is subject to change over time.

Technical changes

  • Add support for non-actions in ScriptHandler
  • Add a HookProvider with provides job started/job end hooks for JobExtensionRunners to run
  • Update our telemetry so we can see how many users are using this
  • Add tests for this functionality

Description

This ADR describes the functionality in more detail, but at a high level:

  • We will expose 2 variables that users can set to enable hooks
    • ACTIONS_RUNNER_HOOK_JOB_STARTED
    • ACTIONS_RUNNER_HOOK_JOB_COMPLETED

You can set these variables to the absolute path of a a .sh or .ps1 file.

We will execute pwsh (fallback to powershell) or bash (fallback to sh) as appropriate.

  • .sh files will execute with the args -e {pathtofile}
  • .ps1 files will execute with the args -command \". '{pathtofile}'\"

We will not set the standard flags we typically set for runs commands. So, if you want to set pipefail on bash for example, you will need to do that in your script.

UI

We want to ensure the experience for users invoking workflows is good, if hooks take too long, you may feel your job is delayed or broken. So, much like Set Up Job, we will generate two new steps automatically in your job, one for each configured hook:

  • Set up runner
  • Complete runner

@fhammerl fhammerl requested a review from a team as a code owner March 9, 2022 12:14
@fhammerl fhammerl changed the title [WIP] Ppre job hook [WIP] Pre job hook Mar 9, 2022
@fhammerl fhammerl self-assigned this Mar 11, 2022
@thboop thboop changed the title [WIP] Pre job hook Runner Job Started/Completed Hooks Mar 15, 2022
protected override void PrintActionDetails(ActionRunStage stage)
{

if (stage == ActionRunStage.Post)
Copy link
Copy Markdown
Collaborator

@thboop thboop Mar 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentionally removing this, we shouldn't have a way to access this as a script step anyways but job extensions are going to try and use post stage script handlers

@ethomson
Copy link
Copy Markdown
Contributor

Two minor comments but overall I'm excited to see this land. Great work.

thboop and others added 2 commits March 16, 2022 15:49
Co-authored-by: Edward Thomson <ethomson@github.com>
@thboop thboop merged commit 7d5e9cd into main Mar 18, 2022
@thboop thboop deleted the fhammerl/job-start-complete-hooks branch March 18, 2022 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants