From eb511812edb0b23801e27181cc9b23e56617647a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Goinvic?= Date: Fri, 6 Jun 2025 11:31:49 +0200 Subject: [PATCH] ci: truncate dyff on added files --- .github/workflows/build-test.yml | 17 +++++++++++++++-- newsfragments/523.internal.md | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 newsfragments/523.internal.md diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 53867a33..e6706353 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -110,6 +110,7 @@ jobs: # helm template doesn't reliably order manifests within the same kind, so use yq to do it for us - name: Generate manifests for PR + id: generate-manifests run: | mkdir -p "$RUNNER_TEMP/new" for values in charts/matrix-stack/ci/*values.yaml; do @@ -122,6 +123,7 @@ jobs: yq ea '[.] | .[] | splitDoc' | \ yq -s "\"$RUNNER_TEMP/new/$(basename "$values" ".yaml")/\""' + ([.kind, .metadata.name] | join("-") | downcase) + ".yaml"' done + echo "output_dir=$RUNNER_TEMP/new" | tee -a "$GITHUB_OUTPUT" # We want the most recent common ancestor between the target & PR branches rather than the target branch itself # There could have been more commits to the target branch since the PR branch was created and we don't want to see @@ -156,9 +158,19 @@ jobs: tool_versions: | dyff 1.10.1 + - name: Upload new manifests + id: upload-new + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: new-manifests + path: ${{ steps.generate-manifests.outputs.output_dir }} + retention-days: 1 + - name: dyff old and new manifests id: dyff shell: bash + env: + ARTIFACT_URL: ${{ steps.upload-new.outputs.artifact-url }} run: | echo "output_dir=$RUNNER_TEMP" | tee -a "$GITHUB_OUTPUT" values_directories=$(find "$RUNNER_TEMP/old" "$RUNNER_TEMP/new" -maxdepth 1 -type d | sed -E 's|'"$RUNNER_TEMP"'/(old\|new)||' | sed -E 's|^/||' | sort | uniq) @@ -182,8 +194,9 @@ jobs: file_content=$(sed -e 's/^/+ /' < "$RUNNER_TEMP/new/$templates_file") comment_templates_body+="
$current_file (added)\n" comment_templates_body+='\n```diff\n' - comment_templates_body+=$file_content - comment_templates_body+='\n```\n
\n\n' + comment_templates_body+="# The full content of the file is available in ${ARTIFACT_URL}\n" + comment_templates_body+=$(head -n 5 <<< "$file_content") + comment_templates_body+='\n...\n```\n\n\n' continue fi diff --git a/newsfragments/523.internal.md b/newsfragments/523.internal.md new file mode 100644 index 00000000..1763cfae --- /dev/null +++ b/newsfragments/523.internal.md @@ -0,0 +1 @@ +CI: Truncate added files in dyff comment.