contributor-guide/style-guide: Add a note about task idempotence
PATCH 1/1 contributor-guide/style-guide: Add a note about task idempotence
--- documentation/contributor-guide/recipe-style-guide.rst | 10 ++++++++++ 1 file changed, 10 insertions(+)
documentation/contributor-guide/recipe-style-guide.rst +10 -0
@@ -257,6 +257,16 @@ Tips and Guidelines for Writing Recipes and ``-nativesdk`` ones, whenever possible. This avoids having to maintain multiple recipe files at the same time. +- Recipes should have tasks which are idempotent, i.e. that executing a given task + multiple times shouldn't change the end result. The build environment is built upon + this assumption and breaking it can cause obscure build failures. + +- For idempotence when modifying files it is usually best to copy a file 'X' to + 'X.orig' only if it already doesn't exist before copying 'X.orig' to 'X' and + modifying 'X'. This ensures if rerun the task always has the same end result + and the original file can be preserved to reuse. It also guards against an + interrupted build corrupting the file. + Patch Upstream Status =====================
Signature · 1 line
2.39.2
Hi,
Quoted 10 lines · Richard Purdie
Signed-off-by Richard Purdie <[email protected]>--- documentation/contributor-guide/recipe-style-guide.rst | 10 ++++++++++ 1 file changed, 10 insertions(+)documentation/contributor-guide/recipe-style-guide.rst +0
-0
documentation/contributor-guide/recipe-style-guide.rst Tips and Guidelines for Writing Recipes · line 266
Quoted 10 lines
documentation/contributor-guide/recipe-style-guide.rst +7
-0@@ -257,6 +257,16 @@ Tips and Guidelines for Writing Recipes and ``-nativesdk`` ones, whenever possible. This avoids having to maintain multiple recipe files at the same time. +- Recipes should have tasks which are idempotent, i.e. that executing a given task + multiple times shouldn't change the end result. The build environment is built upon + this assumption and breaking it can cause obscure build failures. + +- For idempotence when modifying files it is usually best to copy a file 'X' to + 'X.orig' only if it already doesn't exist before copying 'X.orig' to 'X' and + modifying 'X'. This ensures if rerun the task always has the same end result
I have a hard time parsing this phrase :-/
How about :
For idempotence, when modifying files, it is usually best to :
* copy a file 'X' to 'X.orig' (only if it doesn't exist already)
* then, copy 'X.orig' back to 'X',
* and, finally, modify 'X'.
(Not being a native speaker, I've no idea if this is really better T_T)
documentation/contributor-guide/recipe-style-guide.rst Tips and Guidelines for Writing Recipes · line 272
Quoted 6 lines
documentation/contributor-guide/recipe-style-guide.rst +3
-0+ and the original file can be preserved to reuse. It also guards against an + interrupted build corrupting the file. + Patch Upstream Status =====================
Regards,
Signature · 2 lines
Yoann Congal Smile ECS - Tech Expert
PATCH v2 1/1 contributor-guide/style-guide: Add a note about task idempotence
From: Michael Opdenacker <[email protected]>
From: Richard Purdie <[email protected]>
---
Changes in V2:
- Use a bulleted list to clarify the order of steps (Suggested by Yoann Congal)
- Recall that we are talking about idempotence in tasks. Useful for people overlooking the previous paragraph.
--- .../contributor-guide/recipe-style-guide.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
documentation/contributor-guide/recipe-style-guide.rst +14 -0
@@ -257,6 +257,20 @@ Tips and Guidelines for Writing Recipes and ``-nativesdk`` ones, whenever possible. This avoids having to maintain multiple recipe files at the same time. +- Recipes should have tasks which are idempotent, i.e. that executing a given task + multiple times shouldn't change the end result. The build environment is built upon + this assumption and breaking it can cause obscure build failures. + +- For idempotence when modifying files in tasks, it is usually best to: + + - copy a file ``X`` to ``X.orig`` (only if it doesn't exist already) + - then, copy ``X.orig`` back to ``X``, + - and, finally, modify ``X``. + + This ensures if rerun the task always has the same end result and the + original file can be preserved to reuse. It also guards against an + interrupted build corrupting the file. + Patch Upstream Status =====================
Signature · 1 line
2.34.1
Quoted 31 lines · On Wed, 2023-09-20 at 21:13 +0200, [email protected] wrote:
From: Michael Opdenacker <[email protected]>
From: Richard Purdie <[email protected]>
Signed-off-by Richard Purdie <[email protected]>CC Yoann Congal <[email protected]>---
Changes in V2:
- Use a bulleted list to clarify the order of steps (Suggested by Yoann Congal)
- Recall that we are talking about idempotence in tasks. Useful for people overlooking the previous paragraph.--- .../contributor-guide/recipe-style-guide.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+)documentation/contributor-guide/recipe-style-guide.rst +6
-0@@ -257,6 +257,20 @@ Tips and Guidelines for Writing Recipes and ``-nativesdk`` ones, whenever possible. This avoids having to maintain multiple recipe files at the same time. +- Recipes should have tasks which are idempotent, i.e. that executing a given task + multiple times shouldn't change the end result. The build environment is built upon + this assumption and breaking it can cause obscure build failures. + +- For idempotence when modifying files in tasks, it is usually best to: +
documentation/contributor-guide/recipe-style-guide.rst Tips and Guidelines for Writing Recipes · line 275
Quoted 10 lines
documentation/contributor-guide/recipe-style-guide.rst +8
-0+ - copy a file ``X`` to ``X.orig`` (only if it doesn't exist already) + - then, copy ``X.orig`` back to ``X``, + - and, finally, modify ``X``. + + This ensures if rerun the task always has the same end result and the + original file can be preserved to reuse. It also guards against an + interrupted build corrupting the file. + Patch Upstream Status =====================
FWIW, fine by me, thanks.
Richard