mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-04 17:07:04 +02:00
More CI improvements
This commit is contained in:
parent
d83abae451
commit
bcded223a6
41 changed files with 359 additions and 120 deletions
|
@ -97,8 +97,10 @@ function filterChangedCharts(files, parentFolder) {
|
|||
let changedCharts = [];
|
||||
filteredChartFiles.forEach((file) => {
|
||||
const absoluteParentFolder = path.resolve(parentFolder);
|
||||
const absoluteChartFolder = path.resolve(path.dirname(file));
|
||||
const chart = absoluteChartFolder.slice(absoluteParentFolder.length + 1);
|
||||
const absoluteFileDirname = path.resolve(path.dirname(file));
|
||||
const relativeFileDirname = absoluteFileDirname.slice(absoluteParentFolder.length + 1);
|
||||
const chartPathParts = relativeFileDirname.split("/");
|
||||
const chart = `${chartPathParts[0]}/${chartPathParts[1]}`;
|
||||
changedCharts.push(chart);
|
||||
});
|
||||
// Return only unique items
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -71,8 +71,12 @@ function filterChangedCharts(files: string[], parentFolder: string) {
|
|||
let changedCharts: string[] = [];
|
||||
filteredChartFiles.forEach((file) => {
|
||||
const absoluteParentFolder = path.resolve(parentFolder);
|
||||
const absoluteChartFolder = path.resolve(path.dirname(file));
|
||||
const chart = absoluteChartFolder.slice(absoluteParentFolder.length + 1);
|
||||
const absoluteFileDirname = path.resolve(path.dirname(file));
|
||||
const relativeFileDirname = absoluteFileDirname.slice(
|
||||
absoluteParentFolder.length + 1
|
||||
);
|
||||
const chartPathParts = relativeFileDirname.split("/");
|
||||
const chart = `${chartPathParts[0]}/${chartPathParts[1]}`;
|
||||
changedCharts.push(chart);
|
||||
});
|
||||
|
||||
|
|
35
.github/actions/override-chart-deps/action.yaml
vendored
Normal file
35
.github/actions/override-chart-deps/action.yaml
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
name: "Override chart dependencies"
|
||||
description: "Overrides the dependencies for a Helm chart"
|
||||
inputs:
|
||||
chart:
|
||||
required: true
|
||||
description: "Which chart to override the dependencies for"
|
||||
overrides:
|
||||
required: true
|
||||
description: "A JSON encoded list of dependency overrides"
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Override dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
overrides=( $(yq --null-input e -o=j -I=0 '${{ inputs.overrides }}[]' ) )
|
||||
chartFile="charts/${{ matrix.chart }}/Chart.yaml"
|
||||
|
||||
if [[ ! -f ${chartFile} ]]; then
|
||||
echo "Could not find ${chartFile}"!
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for override in "${overrides[@]}"; do
|
||||
name=$(echo "$override" | yq e '.name' -)
|
||||
repository=$(echo "$override" | yq e '.repository' -)
|
||||
version=$(echo "$override" | yq e '.version' -)
|
||||
|
||||
yq -i "(.dependencies[] | select(.name == \"$name\").repository) |= \"$repository\"" "${chartFile}"
|
||||
yq -i "(.dependencies[] | select(.name == \"$name\").version) |= \"$version\"" "${chartFile}"
|
||||
done
|
||||
|
||||
echo "Resulting chart:"
|
||||
cat ${chartFile}
|
35
.github/workflows/charts-test.yaml
vendored
35
.github/workflows/charts-test.yaml
vendored
|
@ -9,8 +9,14 @@ on:
|
|||
chartsToTest:
|
||||
description: >
|
||||
A JSON encoded array of charts to lint
|
||||
required: true
|
||||
type: string
|
||||
required: true
|
||||
overrideDeps:
|
||||
description: >
|
||||
A JSON encoded array of dependencies to override before testing
|
||||
type: string
|
||||
required: false
|
||||
default: '[]'
|
||||
|
||||
env:
|
||||
HELM_VERSION: 3.9.2
|
||||
|
@ -19,7 +25,7 @@ jobs:
|
|||
install-chart:
|
||||
name: Install chart
|
||||
runs-on: ubuntu-22.04
|
||||
if: ${{ inputs.chartsToTest != '' && inputs.chartsToTest != '[]' }}
|
||||
if: ${{ inputs.chartsToTest != '[]' && inputs.chartsToTest != '' }}
|
||||
strategy:
|
||||
matrix:
|
||||
chart: ${{ fromJSON(inputs.chartsToTest) }}
|
||||
|
@ -57,6 +63,13 @@ jobs:
|
|||
run: |
|
||||
kubectl taint --all=true nodes node.cloudprovider.kubernetes.io/uninitialized- || true
|
||||
|
||||
- name: Override chart dependencies
|
||||
uses: ./.github/actions/override-chart-deps
|
||||
if: ${{ inputs.overrideDeps != '[]' }}
|
||||
with:
|
||||
chart: ${{ matrix.chart }}
|
||||
overrides: ${{ inputs.overrideDeps }}
|
||||
|
||||
- name: Run chart-testing (install)
|
||||
run: ct install --config .ci/ct/ct.yaml --charts "charts/${{ matrix.chart }}"
|
||||
|
||||
|
@ -70,13 +83,13 @@ jobs:
|
|||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Check install matrix status
|
||||
if: ${{ (inputs.chartsToTest != '' && inputs.chartsToTest != '[]') && needs.install-chart.result != 'success' }}
|
||||
if: ${{ (inputs.chartsToTest != '[]' && inputs.chartsToTest != '') && needs.install-chart.result != 'success' }}
|
||||
run: exit 1
|
||||
|
||||
unittest-chart:
|
||||
name: Unit-test chart
|
||||
runs-on: ubuntu-20.04
|
||||
if: ${{ inputs.chartsToTest != '' && inputs.chartsToTest != '[]' }}
|
||||
if: ${{ inputs.chartsToTest != '[]' && inputs.chartsToTest != '' }}
|
||||
strategy:
|
||||
matrix:
|
||||
chart: ${{ fromJSON(inputs.chartsToTest) }}
|
||||
|
@ -95,12 +108,18 @@ jobs:
|
|||
helmv3
|
||||
helm: "${{ env.HELM_VERSION }}"
|
||||
|
||||
- name: Override chart dependencies
|
||||
uses: ./.github/actions/override-chart-deps
|
||||
if: ${{ inputs.overrideDeps != '[]' }}
|
||||
with:
|
||||
chart: ${{ matrix.chart }}
|
||||
overrides: ${{ inputs.overrideDeps }}
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
helm plugin install https://github.com/vbehar/helm3-unittest --version v1.0.16
|
||||
cd "charts/${{ matrix.chart }}"
|
||||
helm dep update
|
||||
helm unittest -f "tests/**/*_test.yaml" .
|
||||
helm dep update "charts/${{ matrix.chart }}"
|
||||
helm unittest -f "tests/**/*_test.yaml" "charts/${{ matrix.chart }}"
|
||||
|
||||
# Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7
|
||||
unittest_success:
|
||||
|
@ -112,5 +131,5 @@ jobs:
|
|||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Check unittest matrix status
|
||||
if: ${{ (inputs.chartsToTest != '' && inputs.chartsToTest != '[]') && needs.unittest-chart.result != 'success' }}
|
||||
if: ${{ (inputs.chartsToTest != '[]' && inputs.chartsToTest != '') && needs.unittest-chart.result != 'success' }}
|
||||
run: exit 1
|
||||
|
|
18
.github/workflows/pr-validate.yaml
vendored
18
.github/workflows/pr-validate.yaml
vendored
|
@ -53,3 +53,21 @@ jobs:
|
|||
with:
|
||||
checkoutCommit: ${{ github.sha }}
|
||||
chartsToTest: ${{ needs.pr-metadata.outputs.chartsToInstall }}
|
||||
|
||||
library-charts-test:
|
||||
uses: bjw-s/helm-charts/.github/workflows/charts-test.yaml@main
|
||||
needs:
|
||||
- pr-metadata
|
||||
with:
|
||||
checkoutCommit: ${{ github.sha }}
|
||||
chartsToTest: |-
|
||||
${{
|
||||
(
|
||||
contains(fromJSON(needs.pr-metadata.outputs.addedOrModifiedCharts), 'library/common') &&
|
||||
'["other/kah-common-chart"]'
|
||||
) || '[]'
|
||||
}}
|
||||
overrideDeps: |-
|
||||
[
|
||||
{"name": "common", "repository": "file://../../library/common", "version": "*"}
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue