Support pre/post hooks for tasks #7

Open
opened 2020-04-19 13:25:42 +00:00 by southerntofu · 3 comments
Owner

There should be a way to define pre/post hooks for tasks. For example:

  • if ~/.git-build/$PROJECT.pre exists, it is run before the task
  • if ~/.git-build/$PROJECT.post exists, it is run after the task

There should also be global pre/post hooks, like this:

  • ~/.git-build/GLOBAL.pre runs before any other task
  • ~/.git-build/GLOBAL.post runs after any other task

However, tasks are run in the background so the GLOBAL.post task needs to agree with specific task on a mechanism to signal when they're done (such as a lockfile)

There should be a way to define pre/post hooks for tasks. For example: - if ~/.git-build/$PROJECT.pre exists, it is run before the task - if ~/.git-build/$PROJECT.post exists, it is run after the task There should also be global pre/post hooks, like this: - ~/.git-build/GLOBAL.pre runs before any other task - ~/.git-build/GLOBAL.post runs after any other task However, tasks are run in the background so the GLOBAL.post task needs to agree with specific task on a mechanism to signal when they're done (such as a lockfile)
Author
Owner

TODO: investigate if #6 (run-parts style ordering of tasks) would not cover all the needs here. This could prove to be a simpler mechanism.

TODO: investigate if #6 (run-parts style ordering of tasks) would not cover all the needs here. This could prove to be a simpler mechanism.
Author
Owner

We can probably use ordered task to achieve pre/post hooks for individual tasks.

However maybe global pre-post hooks can still be useful. Potential usecases:

  • publish PROJECT.{log,err} of website directly to the website webroot (post hook)
  • update project list on personal homepage with build status and link to unified build log/err (post hook)
  • retrieve remote content or update some config before build (pre hook)
  • minify/prettify HTML/JSON (post hook)
We can probably use ordered task to achieve pre/post hooks for individual tasks. However maybe global pre-post hooks can still be useful. Potential usecases: - publish PROJECT.{log,err} of website directly to the website webroot (post hook) - update project list on personal homepage with build status and link to unified build log/err (post hook) - retrieve remote content or update some config before build (pre hook) - minify/prettify HTML/JSON (post hook)
Author
Owner

So i think simple lock files from tasks would do the trick :

  • when a task needs a pre-hook, it calls said pre-hook which defines a lockfile, then waits for the lockfile to disappear before running
  • when a task needs a post-hook, it simply runs it once it's done

The global post-hook can be a simple task that runs late in the game (99-homepage).

To build my homepage containing the different links to my different draft websites, i should wait for all task that symbolic link to zola to finish their thing, then append the link to target destination folder

So i think simple lock files from tasks would do the trick : - when a task needs a pre-hook, it calls said pre-hook which defines a lockfile, then waits for the lockfile to disappear before running - when a task needs a post-hook, it simply runs it once it's done The global post-hook can be a simple task that runs late in the game (`99-homepage`). To build my homepage containing the different links to my different draft websites, i should wait for all task that symbolic link to `zola` to finish their thing, then append the link to target destination folder
Sign in to join this conversation.
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: forge/build.sh#7
No description provided.