Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions exports/taskfiles/utils/remote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ tasks:
# @param {string} FILE_SHA256 Content hash to verify the downloaded tar file against.
# @param {string} [CHECKSUM_FILE={{.OUTPUT_DIR}}.md5] File path to store the checksum of the
# downloaded tar file.
# @param {string[]} [CHECKSUM_EXCLUDE_PATTERNS] Path wildcard patterns, relative to `OUTPUT_DIR`,
# to exclude from the checksum.
Comment on lines +61 to +62
Copy link
Member

Choose a reason for hiding this comment

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

Hm, are they relative to OUTPUT_DIR?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, CHECKSUM_EXCLUDE_PATTERNS is relative to OUTPUT_DIR. By looking at the checksum:validate task's docstring:

# @param {string[]} [EXCLUDE_PATTERNS] Path wildcard patterns, relative to any `INCLUDE_PATTERNS`,
# to exclude from the checksum.

Since OUTPUT_DIR is passed as one of the INCLUDE_PATTERNS to the checksum tasks, and the docstring states that EXCLUDE_PATTERNS are "relative to any INCLUDE_PATTERNS", the CHECKSUM_EXCLUDE_PATTERNS are indeed relative to OUTPUT_DIR.

or are you saying that this can be better expressed?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, no, I just got confused with INCLUDE_PATTERNS.

# @param {string[]} [EXCLUDE_PATTERNS] Path wildcard patterns that should not be extracted.
# @param {string[]} [INCLUDE_PATTERNS] Path wildcard patterns to extract.
# @param {int} [NUM_COMPONENTS_TO_STRIP=1] Number of leading path components to strip from the
Expand All @@ -74,6 +76,8 @@ tasks:
{{default (printf "%s.tar.gz" .OUTPUT_DIR) .TAR_FILE}}

# Path patterns
CHECKSUM_EXCLUDE_PATTERNS:
ref: "default (list) .CHECKSUM_EXCLUDE_PATTERNS"
EXCLUDE_PATTERNS:
ref: "default (list) .EXCLUDE_PATTERNS"
INCLUDE_PATTERNS:
Expand All @@ -97,6 +101,8 @@ tasks:
vars:
CHECKSUM_FILE: "{{.CHECKSUM_FILE}}"
INCLUDE_PATTERNS: ["{{.OUTPUT_DIR}}"]
EXCLUDE_PATTERNS:
ref: ".CHECKSUM_EXCLUDE_PATTERNS"
cmds:
- |-
rm -rf "{{.OUTPUT_DIR}}"
Expand All @@ -123,6 +129,8 @@ tasks:
vars:
CHECKSUM_FILE: "{{.CHECKSUM_FILE}}"
INCLUDE_PATTERNS: ["{{.OUTPUT_DIR}}"]
EXCLUDE_PATTERNS:
ref: ".CHECKSUM_EXCLUDE_PATTERNS"

# Uses curl to download a zip file from the given URL and extracts its contents.
#
Expand All @@ -131,6 +139,8 @@ tasks:
# @param {string} FILE_SHA256 Content hash to verify the downloaded zip file against.
# @param {string} [CHECKSUM_FILE={{.OUTPUT_DIR}}.md5] File path to store the checksum of the
# downloaded zip file.
# @param {string[]} [CHECKSUM_EXCLUDE_PATTERNS] Path wildcard patterns, relative to `OUTPUT_DIR`,
# to exclude from the checksum.
# @param {string[]} [EXCLUDE_PATTERNS] Path wildcard patterns that should not be extracted.
# @param {string[]} [INCLUDE_PATTERNS] Path wildcard patterns to extract.
# @param {string} [ZIP_FILE={{.OUTPUT_DIR}}.zip] Path where the zip file should be stored.
Expand All @@ -145,6 +155,8 @@ tasks:
{{default (printf "%s.zip" .OUTPUT_DIR) .ZIP_FILE}}

# Path patterns
CHECKSUM_EXCLUDE_PATTERNS:
ref: "default (list) .CHECKSUM_EXCLUDE_PATTERNS"
EXCLUDE_PATTERNS:
ref: "default (list) .EXCLUDE_PATTERNS"
INCLUDE_PATTERNS:
Expand All @@ -164,6 +176,8 @@ tasks:
vars:
CHECKSUM_FILE: "{{.CHECKSUM_FILE}}"
INCLUDE_PATTERNS: ["{{.OUTPUT_DIR}}"]
EXCLUDE_PATTERNS:
ref: ".CHECKSUM_EXCLUDE_PATTERNS"
cmds:
- |-
rm -rf "{{.OUTPUT_DIR}}"
Expand All @@ -185,3 +199,5 @@ tasks:
vars:
CHECKSUM_FILE: "{{.CHECKSUM_FILE}}"
INCLUDE_PATTERNS: ["{{.OUTPUT_DIR}}"]
EXCLUDE_PATTERNS:
ref: ".CHECKSUM_EXCLUDE_PATTERNS"
36 changes: 36 additions & 0 deletions taskfiles/remote/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,42 @@ tasks:
- "test -e '{{.OUTPUT_DIR}}/{{.G_EXTRACTED_ZIP_CODEOWNERS_PATH}}'"
- "test -e '{{.OUTPUT_DIR}}/{{.G_EXTRACTED_ZIP_PULL_REQUEST_TEMPLATE_PATH}}'"

download-and-extract-zip-test-checksum-exclude:
vars:
OUTPUT_DIR: "{{.G_OUTPUT_DIR}}/{{.TASK | replace \":\" \"#\"}}"
CHECKSUM_FILE: "{{.OUTPUT_DIR}}.md5"
cmds:
- task: "download-and-extract-zip-test-cleaner"
vars:
OUTPUT_DIR: "{{.OUTPUT_DIR}}"

# Download the zip file, extract all files, and compute the checksum with some exclude
# patterns.
- task: "remote:download-and-extract-zip"
vars:
CHECKSUM_EXCLUDE_PATTERNS: &checksum_exclude_patterns
- ".github/CODEOWNERS"
- ".github/PULL_REQUEST_TEMPLATE.md"
OUTPUT_DIR: "{{.OUTPUT_DIR}}"
URL: "{{.G_TEST_ZIP_FILE_URL}}"
FILE_SHA256: "{{.G_TEST_ZIP_FILE_SHA256}}"
- "mv '{{.CHECKSUM_FILE}}' '{{.CHECKSUM_FILE}}.ref'"
Comment on lines +95 to +105
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

❓ Verification inconclusive

Ensure checksum exclude patterns align with extracted file paths.

The anchored patterns ".github/CODEOWNERS" and ".github/PULL_REQUEST_TEMPLATE.md" may not match the top-level folder prefix (e.g. yscope-dev-utils-main/.github/...). To guarantee the exclude rules apply both during extraction and in checksum computation, update the anchor to use a wildcard or reference the existing vars:

  vars:
-   CHECKSUM_EXCLUDE_PATTERNS: &checksum_exclude_patterns
-     - ".github/CODEOWNERS"
-     - ".github/PULL_REQUEST_TEMPLATE.md"
+   CHECKSUM_EXCLUDE_PATTERNS: &checksum_exclude_patterns
+     - "*/.github/CODEOWNERS"
+     - "*/.github/PULL_REQUEST_TEMPLATE.md"

Run a quick grep on the extracted directory name to confirm your anchors match:


🏁 Script executed:

rg -A1 'yscope-dev-utils-main' -g '*.md'

Length of output: 40


Ensure checksum exclude patterns align with extracted file paths.

The anchored patterns ".github/CODEOWNERS" and ".github/PULL_REQUEST_TEMPLATE.md" may not match the top-level folder prefix (e.g. yscope-dev-utils-main/.github/...). To guarantee the exclude rules apply both during extraction and in checksum computation, update the anchor to use a wildcard or reference the existing vars:

  vars:
-   CHECKSUM_EXCLUDE_PATTERNS: &checksum_exclude_patterns
-     - ".github/CODEOWNERS"
-     - ".github/PULL_REQUEST_TEMPLATE.md"
+   CHECKSUM_EXCLUDE_PATTERNS: &checksum_exclude_patterns
+     - "*/.github/CODEOWNERS"
+     - "*/.github/PULL_REQUEST_TEMPLATE.md"

Run a quick grep on the extracted directory name to confirm your anchors match:

rg -A1 'yscope-dev-utils-main' -g '*.md'
🤖 Prompt for AI Agents
In taskfiles/remote/tests.yaml around lines 95 to 105, the anchored checksum
exclude patterns do not account for the top-level extracted folder prefix,
causing mismatches during checksum computation. Update the
CHECKSUM_EXCLUDE_PATTERNS anchor to include a wildcard prefix (e.g.,
"yscope-dev-utils-main/.github/CODEOWNERS") or adjust the patterns to match the
actual extracted file paths. Verify the updated patterns by running a grep or
ripgrep command on the extracted directory to ensure they correctly exclude the
intended files.


# Download the zip file again, extract files excluding some files, and compute the checksum
# with the same exclude patterns.
- task: "remote:download-and-extract-zip"
vars:
CHECKSUM_EXCLUDE_PATTERNS: *checksum_exclude_patterns
EXCLUDE_PATTERNS:
- "*/CODEOWNERS"
- "{{.G_EXTRACTED_ZIP_PULL_REQUEST_TEMPLATE_PATH}}"
OUTPUT_DIR: "{{.OUTPUT_DIR}}"
URL: "{{.G_TEST_ZIP_FILE_URL}}"
FILE_SHA256: "{{.G_TEST_ZIP_FILE_SHA256}}"

# Test that the checksum file was created and matches the reference checksum file.
- "diff -q '{{.CHECKSUM_FILE}}' '{{.CHECKSUM_FILE}}.ref'"

# Cleans up the files output by download-and-extract-zip (assuming their default paths weren't
# changed).
#
Expand Down