-
Notifications
You must be signed in to change notification settings - Fork 9
fix(taskfiles): Output unexpected errors in checksum tasks; Call gtar on macOS (fixes #67); Add unit tests for checksum tasks.
#81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
c72511e
Improve checksum compute and validate error handling; add unit tests.
davidlion 394d45f
Fix yaml lint; sanity check
davidlion 3b5a816
one more sanity check
davidlion 9c935f9
one more
davidlion 07b88fc
last one
davidlion 20802e7
remove test
davidlion a2ff6f4
Fix err log.
davidlion 194440e
Drop mktemp due to task bug.
davidlion 3a92d53
Add force to rm tmp files.
davidlion c31ef24
sub shells
davidlion 07fd3e4
Update readme with macos requirements.
davidlion 4ec6588
Tweak default list handling.
davidlion 93a6296
readme tweak
davidlion 5a230b9
doc string tweaks
davidlion 01280e1
fix sub shell and indentation.
davidlion b6df417
Add -f when removing checksum on failed compute.
davidlion 882c5be
Merge remote-tracking branch 'upstream/main' into checksum-fix
davidlion fbe8a72
Undo testing comment.
davidlion 8534c24
Apply suggestions from code review.
davidlion 40d4579
Merge remote-tracking branch 'upstream/main' into checksum-fix
davidlion bbb32bc
Add individual checksum task to tests.
davidlion d53221e
Merge remote-tracking branch 'upstream/main' into checksum-fix
davidlion 3871d7d
Apply suggestions from code review.
davidlion 35e3773
Merge branch 'main' into checksum-fix
davidlion d07138e
Address review comments and tweak if statements.
davidlion 8363fc4
Add pipefail note to compute.
davidlion 3bd67a0
Fix coderabbit nits.
davidlion 8f70d9b
Apply suggestions from code review.
davidlion 8a51626
Reflow test. Change writing tmp_err_log to append.
davidlion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| version: "3" | ||
|
|
||
| includes: | ||
| checksum: | ||
| internal: true | ||
| taskfile: "../../exports/taskfiles/utils/checksum.yaml" | ||
|
|
||
| tasks: | ||
| default: | ||
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| cmds: | ||
| - task: "checksum-test-rerun" | ||
| - task: "checksum-test-skip" | ||
| - task: "checksum-test-update" | ||
|
|
||
| checksum-test-rerun: | ||
| vars: | ||
| OUTPUT_DIR: "{{.G_OUTPUT_DIR}}/{{.TASK | replace \":\" \"#\"}}" | ||
| SRC_DIR: "{{.OUTPUT_DIR}}/src" | ||
|
|
||
| CHECKSUM_FILE: "{{.SRC_DIR}}.md5" | ||
| CHECKSUM_FILE_REF: "{{.CHECKSUM_FILE}}.ref" | ||
| FILE_0: "{{.SRC_DIR}}/0.txt" | ||
| FILE_1: "{{.SRC_DIR}}/1.txt" | ||
| cmds: | ||
| - task: "checksum-test-init" | ||
| vars: | ||
| OUTPUT_DIR: "{{.OUTPUT_DIR}}" | ||
| - task: "create-dir-with-checksum" | ||
| vars: | ||
| CHECKSUM_FILE: "{{.CHECKSUM_FILE}}" | ||
| FILE_PATH: "{{.FILE_0}}" | ||
| - "mv '{{.CHECKSUM_FILE}}' '{{.CHECKSUM_FILE_REF}}'" | ||
| - task: "create-dir-with-checksum" | ||
| vars: | ||
| CHECKSUM_FILE: "{{.CHECKSUM_FILE}}" | ||
| FILE_PATH: "{{.FILE_1}}" | ||
|
|
||
| # Test create-dir-with-checksum ran the second time and created a different checksum. | ||
| - "test ! -e '{{.FILE_0}}'" | ||
| - "test -e '{{.FILE_1}}'" | ||
| - |- | ||
| if ! cmp -s '{{.CHECKSUM_FILE}}' '{{.CHECKSUM_FILE_REF}}'; then | ||
| exit 0 | ||
| fi | ||
| exit 1 | ||
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| checksum-test-skip: | ||
| vars: | ||
| OUTPUT_DIR: "{{.G_OUTPUT_DIR}}/{{.TASK | replace \":\" \"#\"}}" | ||
| SRC_DIR: "{{.OUTPUT_DIR}}/src" | ||
|
|
||
| CHECKSUM_FILE: "{{.SRC_DIR}}.md5" | ||
| CHECKSUM_MOD_TS: "{{.CHECKSUM_FILE}}-mod-ts.txt" | ||
| FILE_0: "{{.SRC_DIR}}/0.txt" | ||
| FILE_1: "{{.SRC_DIR}}/1.txt" | ||
| cmds: | ||
| - task: "checksum-test-init" | ||
| vars: | ||
| OUTPUT_DIR: "{{.OUTPUT_DIR}}" | ||
| - task: "create-dir-with-checksum" | ||
| vars: | ||
| CHECKSUM_FILE: "{{.CHECKSUM_FILE}}" | ||
| FILE_PATH: "{{.FILE_0}}" | ||
| - "date -r '{{.CHECKSUM_FILE}}' > '{{.CHECKSUM_MOD_TS}}'" | ||
| - task: "create-dir-with-checksum" | ||
| vars: | ||
| CHECKSUM_FILE: "{{.CHECKSUM_FILE}}" | ||
| FILE_PATH: "{{.FILE_1}}" | ||
|
|
||
| # Test create-dir-with-checksum didn't run the second time and the checksum is unmodified. | ||
| - "test -e '{{.FILE_0}}'" | ||
| - "test ! -e '{{.FILE_1}}'" | ||
| - "cmp -s '{{.CHECKSUM_MOD_TS}}' <(date -r '{{.CHECKSUM_FILE}}')" | ||
|
|
||
| checksum-test-update: | ||
| vars: | ||
| OUTPUT_DIR: "{{.G_OUTPUT_DIR}}/{{.TASK | replace \":\" \"#\"}}" | ||
| SRC_DIR: "{{.OUTPUT_DIR}}/src" | ||
|
|
||
| CHECKSUM_FILE: "{{.SRC_DIR}}.md5" | ||
| CHECKSUM_FILE_REF0: "{{.CHECKSUM_FILE}}.ref0" | ||
| CHECKSUM_FILE_REF1: "{{.CHECKSUM_FILE}}.ref1" | ||
| FILE_0: "{{.SRC_DIR}}/0.txt" | ||
| FILE_1: "{{.SRC_DIR}}/1.txt" | ||
| cmds: | ||
| - task: "checksum-test-init" | ||
| vars: | ||
| OUTPUT_DIR: "{{.OUTPUT_DIR}}" | ||
| - task: "create-dir-with-checksum" | ||
| vars: | ||
| CHECKSUM_FILE: "{{.CHECKSUM_FILE}}" | ||
| FILE_PATH: "{{.FILE_0}}" | ||
| - "cp '{{.CHECKSUM_FILE}}' '{{.CHECKSUM_FILE_REF0}}'" | ||
|
|
||
| - "cat '{{.CHECKSUM_FILE}}' > '{{.FILE_0}}'" | ||
| - task: "checksum:compute" | ||
| vars: | ||
| CHECKSUM_FILE: "{{.CHECKSUM_FILE}}" | ||
| INCLUDE_PATTERNS: ["{{.SRC_DIR}}"] | ||
| - "cp '{{.CHECKSUM_FILE}}' '{{.CHECKSUM_FILE_REF1}}'" | ||
|
|
||
| - task: "create-dir-with-checksum" | ||
| vars: | ||
| CHECKSUM_FILE: "{{.CHECKSUM_FILE}}" | ||
| FILE_PATH: "{{.FILE_1}}" | ||
|
|
||
| # Test create-dir-with-checksum didn't run the second time and the updated checksum is | ||
| # different from the original. | ||
| - "test -e '{{.FILE_0}}'" | ||
| - "test ! -e '{{.FILE_1}}'" | ||
| - "cmp -s '{{.FILE_0}}' '{{.CHECKSUM_FILE_REF0}}'" | ||
| - "cmp -s '{{.CHECKSUM_FILE}}' '{{.CHECKSUM_FILE_REF1}}'" | ||
| - |- | ||
| if ! cmp -s '{{.CHECKSUM_FILE}}' '{{.CHECKSUM_FILE_REF0}}'; then | ||
| exit 0 | ||
| fi | ||
| exit 1 | ||
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| checksum-test-init: | ||
| internal: true | ||
| requires: | ||
| vars: ["OUTPUT_DIR"] | ||
| cmds: | ||
| - "rm -rf '{{.OUTPUT_DIR}}'" | ||
| - "mkdir -p '{{.OUTPUT_DIR}}'" | ||
|
|
||
| create-dir-with-checksum: | ||
| internal: true | ||
| vars: | ||
| DIR: "{{dir .FILE_PATH}}" | ||
| requires: | ||
| vars: ["CHECKSUM_FILE", "FILE_PATH"] | ||
| sources: ["{{.TASKFILE}}"] | ||
| generates: ["{{.CHECKSUM_FILE}}"] | ||
| deps: | ||
| - task: "checksum:validate" | ||
| vars: | ||
| CHECKSUM_FILE: "{{.CHECKSUM_FILE}}" | ||
| INCLUDE_PATTERNS: ["{{.DIR}}"] | ||
| cmds: | ||
| - |- | ||
| rm -rf "{{.DIR}}" | ||
| mkdir -p "{{.DIR}}" | ||
| touch "{{.FILE_PATH}}" | ||
| - task: "checksum:compute" | ||
| vars: | ||
| CHECKSUM_FILE: "{{.CHECKSUM_FILE}}" | ||
| INCLUDE_PATTERNS: ["{{.DIR}}"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.