Skip to content

Commit

Permalink
chore(deps): update helm release argo-cd to v6.8.0 (#138)
Browse files Browse the repository at this point in the history
* Update Helm release argo-cd to v6.8.0

* solve 'comment is too long'

* Update gitops-diff.yaml

* Update gitops-diff.yaml

* Update gitops-diff.yaml

* Update gitops-diff.yaml

* Update gitops-diff.yaml

* Update gitops-diff.yaml

* Update gitops-diff.yaml

* Create create-pr-comment-file.sh

* Update gitops-diff.yaml

* Update gitops-diff.yaml

* Update create-pr-comment-file.sh

* Update gitops-diff.yaml

* create pr comments with body limits respected

Signed-off-by: Johannes Kleinlercher <[email protected]>

* use pr-comment-file.sh from repo without downloading

Signed-off-by: Johannes Kleinlercher <[email protected]>

* fix double suffix

Signed-off-by: Johannes Kleinlercher <[email protected]>

* fix output

Signed-off-by: Johannes Kleinlercher <[email protected]>

* run sequentially so diff comments are in their right order

Signed-off-by: Johannes Kleinlercher <[email protected]>

* add outputs variable

Signed-off-by: Johannes Kleinlercher <[email protected]>

* use upload and download because matrix jobs need comment-files

Signed-off-by: Johannes Kleinlercher <[email protected]>

* default values not in matrix action

Signed-off-by: Johannes Kleinlercher <[email protected]>

* define dependency to diff

Signed-off-by: Johannes Kleinlercher <[email protected]>

* show values diff after rendered template diff

Signed-off-by: Johannes Kleinlercher <[email protected]>

* split on diff so you know what was compared

Signed-off-by: Johannes Kleinlercher <[email protected]>

* don't compare with values.yaml, because it is already used by default

Signed-off-by: Johannes Kleinlercher <[email protected]>

---------

Signed-off-by: Johannes Kleinlercher <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Johannes Kleinlercher <[email protected]>
  • Loading branch information
renovate[bot] and jkleinlercher authored May 9, 2024
1 parent 0519dea commit f312148
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 33 deletions.
85 changes: 85 additions & 0 deletions .github/create-pr-comment-file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash

mkdir -p out/pr
mkdir -p out/target
mkdir -p out-default-values/pr
mkdir -p out-default-values/target
mkdir -p comment-files
for env in pr target; do
cd ${env}/platform-apps/charts
for chart in $( ls ); do
echo ${chart}
helm dependency update ${chart}
for value in $( find ${chart} -type f -name "values-*" ); do
valuefile=$( basename ${value} )
helm template ${chart} -f ${value} > ../../../out/${env}/${chart}_${valuefile}.out
done
# get default values of subchart
helm show values ${chart}/charts/* > ../../../out-default-values/${env}/${chart}_default-values.out || true
done
cd -
done
diff -U 7 -r out-default-values/target out-default-values/pr > out/default-values-diff.txt || true
diff -U 7 -r out/target out/pr > out/diff.txt || true
csplit -f comment-files/comment out/diff.txt --elide-empty-files /^diff\ \-U/ '{*}'

comment_files_csplit=$( find comment-files -type f | sort )

# Define the maximum size in bytes
MAX_SIZE=131072

# Initialize output file counter and base name
OUTPUT_BASE_NAME="combined_file"
output_file_count=1
OUTPUT_FILE="${OUTPUT_BASE_NAME}_${output_file_count}.txt"

# Remove existing files with the same base name to start fresh
rm -f "${OUTPUT_BASE_NAME}_*.txt"

# Current size of the output file
current_size=0

# Loop through all the files passed as arguments to the script
for file in ${comment_files_csplit}; do
if [ -f "$file" ]; then # Check if the argument is a valid file
# Get the size of the file to be added
file_size=$(stat -c %s "$file")

# Check if adding this file will exceed the limit
if (( current_size + file_size > MAX_SIZE )); then
# Start a new output file
output_file_count=$((output_file_count + 1))
OUTPUT_FILE="${OUTPUT_BASE_NAME}_${output_file_count}.txt"
current_size=0 # Reset current size for the new output file

echo "Reached size limit. Creating new output file: $OUTPUT_FILE."
fi

# Concatenate the file to the current output file
cat "$file" >> "$OUTPUT_FILE"

# Update the current size
current_size=$((current_size + file_size))

echo "Added '$file' to '$OUTPUT_FILE'. Current size: $current_size bytes."
else
echo "'$file' is not a valid file. Skipping."
fi
done

echo "Concatenation completed. Total output files: $output_file_count."

combined_files=$( ls combined_file* )
for combined_file in ${combined_files} ; do
sed 's/DESCRIPTION_HERE/Changes Rendered Chart/g' pr/.github/pr-diff-template.txt > out/comment-diff-${combined_file}
sed -e "/DIFF_HERE/{r ${combined_file}" -e "d}" out/comment-diff-${combined_file} > comment-files/comment-result-${combined_file}
done

# default values comparison (we assume they will not be bigger than comment size limit)
sed 's/DESCRIPTION_HERE/Changes Default Values/g' pr/.github/pr-diff-template.txt > out/comment-diff-default-values.txt
sed -e "/DIFF_HERE/{r out/default-values-diff.txt" -e "d}" out/comment-diff-default-values.txt > comment-files/comment-default-values-result.txt


# output for matrix build
echo "matrix={\"comment-files\": $( jq -n '$ARGS.positional' --args $( ls comment-files/comment-result-* ) | tr "\n" " ")}" >> $GITHUB_OUTPUT

File renamed without changes.
64 changes: 35 additions & 29 deletions .github/workflows/gitops-diff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ name: Diff GitOps
jobs:
diff:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.diffStep.outputs.matrix }}
steps:
- name: Checkout PR
uses: actions/checkout@v4
Expand All @@ -23,45 +25,49 @@ jobs:
ref: ${{ github.event.pull_request.base.ref }}

- name: diff charts
id: diffStep
shell: bash
run: |
wget https://raw.githubusercontent.com/suxess-it/sx-cnp-oss/main/.github/Pr-diff-template.txt
mkdir -p out/pr
mkdir -p out/target
mkdir -p out-default-values/pr
mkdir -p out-default-values/target
for env in pr target; do
cd ${env}/platform-apps/charts
for chart in $( ls ); do
echo ${chart}
helm dependency update ${chart}
for value in $( find ${chart} -type f -name "values*" ); do
valuefile=$( basename ${value} )
helm template ${chart} -f ${value} > ../../../out/${env}/${chart}_${valuefile}.out
done
# get default values of subchart
helm show values ${chart}/charts/* > ../../../out-default-values/${env}/${chart}_default-values.out || true
done
cd -
done
diff -U 7 -r out-default-values/target out-default-values/pr > out/default-values-diff.txt || true
diff -U 7 -r out/target out/pr > out/diff.txt || true
sed 's/DESCRIPTION_HERE/Changes Rendered Chart/g' Pr-diff-template.txt > out/comment-diff.txt
sed -e "/DIFF_HERE/{r out/diff.txt" -e "d}" out/comment-diff.txt > out/comment-result.txt
sed 's/DESCRIPTION_HERE/Changes Default Values/g' Pr-diff-template.txt > out/comment-diff-default-values.txt
sed -e "/DIFF_HERE/{r out/default-values-diff.txt" -e "d}" out/comment-diff-default-values.txt > out/comment-default-values-result.txt
bash pr/.github/create-pr-comment-file.sh
- name: PR comment rendered chart with file
uses: thollander/actions-comment-pull-request@v2
- uses: actions/upload-artifact@v4
with:
name: comment-files-artifact
path: comment-files/

create-template-render-diff-comment:
needs: diff
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJSON(needs.diff.outputs.matrix)}}
max-parallel: 1
steps:

- uses: actions/download-artifact@v4
with:
name: comment-files-artifact
path: comment-files/

- uses: thollander/actions-comment-pull-request@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filePath: out/comment-result.txt
filePath: ${{matrix.comment-files}}


create-default-value-diff-comment:
needs: create-template-render-diff-comment
runs-on: ubuntu-latest
steps:

- uses: actions/download-artifact@v4
with:
name: comment-files-artifact
path: comment-files/

- name: PR comment default values with file
uses: thollander/actions-comment-pull-request@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filePath: out/comment-default-values-result.txt
filePath: comment-files/comment-default-values-result.txt
6 changes: 3 additions & 3 deletions platform-apps/charts/argocd/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: argo-cd
repository: https://argoproj.github.io/argo-helm
version: 6.7.18
digest: sha256:b6f661f88a3ea5d69f67e91bd9b3e538dea7d85d79abd486ed04e65b35f20ab3
generated: "2024-04-30T17:44:02.308037142Z"
version: 6.8.0
digest: sha256:6a6ad8cb1e483618b6756d8d4813530e7c1d83c3b23c885fd068bbac73195021
generated: "2024-05-08T08:26:21.980977019Z"
2 changes: 1 addition & 1 deletion platform-apps/charts/argocd/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ appVersion: "1.0.0"

dependencies:
- name: argo-cd
version: 6.7.18
version: 6.8.0
repository: https://argoproj.github.io/argo-helm

0 comments on commit f312148

Please sign in to comment.