Skip to content
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

ci: refactor pipeline #39

Merged
merged 6 commits into from
Dec 11, 2022
Merged
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
8 changes: 0 additions & 8 deletions .github/depedabot.yml

This file was deleted.

16 changes: 8 additions & 8 deletions .github/scripts/generate-chart-exclude-string.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ chartPath="$1"
projectRootPath=$(git rev-parse --show-toplevel)
chartDir="$projectRootPath/charts"

excludePaths=$( \
find "$chartDir" -type d -mindepth 1 -maxdepth 1 \
| sed "s~$projectRootPath/~~" \
| egrep -v "^$chartPath$" \
| awk -F "/" '{ print $2 }' \
| tr '\n' ',' \
| sed 's/,$//g' \
excludePaths=$(
find "$chartDir" -type d -mindepth 1 -maxdepth 1 |
sed "s~$projectRootPath/~~" |
grep -Ev "^$chartPath$" |
awk -F "/" '{ print $2 }' |
tr '\n' ',' |
sed 's/,$//g'
)

echo "$excludePaths"
echo "$excludePaths"
2 changes: 1 addition & 1 deletion .github/scripts/generate-config-test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

ciChanged=false
changedCharts=$(jq -c . < stubs/changed-charts.json)
changedCharts=$(jq -c . <stubs/changed-charts.json)

./generate-config.sh "$ciChanged" "$changedCharts"
64 changes: 36 additions & 28 deletions .github/scripts/generate-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,49 @@ changedCharts=$2

projectRootPath=$(git rev-parse --show-toplevel)
if [ "$ciChanged" == false ]; then
charts=($(echo "$changedCharts" \
| jq -r .[] \
| awk -F '/' '{ print $1"/"$2 }' \
| sort \
| uniq) \
)
chartStr=$(echo "$changedCharts" |
jq -r .[] |
awk -F '/' '{ print $1"/"$2 }' |
sort |
uniq)
charts=()
while IFS='' read -r line; do charts+=("$line"); done < <(echo "$chartStr")
else
charts=($(find "$projectRootPath/charts" -type d -mindepth 1 -maxdepth 1 | sed "s~$projectRootPath/~~"))
chartStr=$(find "$projectRootPath/charts" -type d -mindepth 1 -maxdepth 1 | sed "s~$projectRootPath/~~")
charts=()
while IFS='' read -r line; do charts+=("$line"); done < <(echo "$chartStr")
fi

index=0
chartsJsonArray=()
matrixJsonArray=()
for chartPath in "${charts[@]}"; do
chartName=$(basename $chartPath)
settings=$(yq -o=json '.' "$projectRootPath/$chartPath/ci.yaml")
chartJson=$(jq --null-input \
--arg name "$chartName" \
--arg path "$chartPath" \
--argjson settings "$settings" \
'{"name": $name, "path": $path, "settings": $settings}' \
)
chartsJsonArray+=("$chartJson")
versions=($(echo "$settings" | jq -r -c '.kubernetes.supportedVersions[]'))
for version in "${versions[@]}"; do
matrixJson=$(jq --null-input \
--arg index "$index" \
--arg name "$chartName" \
--arg path "$chartPath" \
--arg version "$version" \
'{"sourceIndex": $index, "name": $name, "path": $path, "version": $version}' \
)
matrixJsonArray+=("$matrixJson")
done
index=$((index+1))
chartName=$(basename "$chartPath")
settings=$(yq -o=json '.' "$projectRootPath/$chartPath/ci.yaml")
chartJson=$(
jq --null-input \
--arg name "$chartName" \
--arg path "$chartPath" \
--argjson settings "$settings" \
'{"name": $name, "path": $path, "settings": $settings}'
)
chartsJsonArray+=("$chartJson")
versions=()
versionsStr=$(echo "$settings" | jq -r -c '.kubernetes.supportedVersions[]')
while IFS='' read -r line; do versions+=("$line"); done < <(echo "$versionsStr")

for version in "${versions[@]}"; do
matrixJson=$(
jq --null-input \
--arg index "$index" \
--arg name "$chartName" \
--arg path "$chartPath" \
--arg version "$version" \
'{"sourceIndex": $index, "name": $name, "path": $path, "version": $version}'
)
matrixJsonArray+=("$matrixJson")
done
index=$((index + 1))
done

chartsObject=$(echo "${chartsJsonArray[@]}" | jq -c -s '{charts: .}')
Expand Down
9 changes: 7 additions & 2 deletions .github/scripts/install-custom-resource-definitions-test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/usr/bin/env bash

index=3
configuration=$(jq -c . < stubs/configuration.json)
index=1
configuration=$(jq -c . <stubs/configuration.json)

./install-custom-resource-definitions.sh "$index" "$configuration"

index=4
configuration=$(jq -c . <stubs/configuration.json)

./install-custom-resource-definitions.sh "$index" "$configuration"
6 changes: 4 additions & 2 deletions .github/scripts/install-custom-resource-definitions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
index="$1"
json="$2"

crds=($(echo "$json" | jq -r -c ".charts[$index].settings.kubernetes.customResourceDefinitions[]"))
crdsStr=$(echo "$json" | jq -r -c ".charts[$index].settings.kubernetes.customResourceDefinitions[]")
crds=()
while IFS='' read -r line; do [[ -n "$line" ]] && crds+=("$line"); done < <(echo "$crdsStr")
for crd in "${crds[@]}"; do
kubectl create -f "$crd"
kubectl create -f "$crd"
done
Loading