mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-03 08:37:03 +02:00
ci: 🧠
This commit is contained in:
parent
bca345c66e
commit
b7d97d9dd0
4 changed files with 56 additions and 12 deletions
38
.ci/scripts/check_chart_version.mjs
Executable file
38
.ci/scripts/check_chart_version.mjs
Executable file
|
@ -0,0 +1,38 @@
|
||||||
|
#!/usr/bin/env zx
|
||||||
|
import 'zx/globals'
|
||||||
|
const chart = argv["_"][0]
|
||||||
|
|
||||||
|
argv.debug ? $.verbose = true : $.verbose = false
|
||||||
|
|
||||||
|
if (chart == undefined) {
|
||||||
|
console.log(chalk.redBright(`ERROR: `) + `No chart provided to validate!`)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultBranch = argv.default_branch || await $`git remote show origin | awk '/HEAD branch/ {print $NF}'`
|
||||||
|
const chartYamlPath = `${chart}/Chart.yaml`
|
||||||
|
|
||||||
|
if (!await fs.pathExists(chartYamlPath)) {
|
||||||
|
console.log(chalk.redBright(`ERROR: `) + `${chartYamlPath} does not exist!`)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const getOriginalChartYamlProcessOutput = await $`git show origin/${defaultBranch}:./${chartYamlPath}`
|
||||||
|
const originalChartYamlContent = Buffer.from(getOriginalChartYamlProcessOutput.stdout, 'utf-8').toString();
|
||||||
|
const originalChartYaml = await YAML.parse(originalChartYamlContent)
|
||||||
|
echo `Original version: ${originalChartYaml.version}`
|
||||||
|
|
||||||
|
const updatedChartYamlContent = await fs.readFile(chartYamlPath, 'utf8')
|
||||||
|
const updatedChartYaml = await YAML.parse(updatedChartYamlContent)
|
||||||
|
if (!updatedChartYaml.version) {
|
||||||
|
console.log(chalk.redBright(`ERROR: `) + `${chartYamlPath} does not contain a version!`)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
echo `New version: ${updatedChartYaml.version}`
|
||||||
|
|
||||||
|
if (updatedChartYaml.version == originalChartYaml.version) {
|
||||||
|
console.log(chalk.redBright(`ERROR: `) + `Chart version has not been updated!`)
|
||||||
|
process.exit(1)
|
||||||
|
} else {
|
||||||
|
console.log(chalk.greenBright(`OK: `) + `Chart version has been updated!`)
|
||||||
|
}
|
13
.github/workflows/charts-lint.yaml
vendored
13
.github/workflows/charts-lint.yaml
vendored
|
@ -42,11 +42,11 @@ jobs:
|
||||||
echo "::set-output name=detected::true"
|
echo "::set-output name=detected::true"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
lint-charts:
|
lint-chart:
|
||||||
needs:
|
needs:
|
||||||
- generate-lint-matrix
|
- generate-lint-matrix
|
||||||
if: needs.generate-lint-matrix.outputs.detected == 'true'
|
if: needs.generate-lint-matrix.outputs.detected == 'true'
|
||||||
name: Lint charts
|
name: Lint chart
|
||||||
strategy:
|
strategy:
|
||||||
matrix: ${{ fromJson(needs.generate-lint-matrix.outputs.lint-matrix) }}
|
matrix: ${{ fromJson(needs.generate-lint-matrix.outputs.lint-matrix) }}
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
@ -65,6 +65,11 @@ jobs:
|
||||||
helmv3
|
helmv3
|
||||||
helm: "${{ env.HELM_VERSION }}"
|
helm: "${{ env.HELM_VERSION }}"
|
||||||
|
|
||||||
|
- name: Check chart version update
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
npx zx .ci/scripts/check_chart_version.mjs "charts/${{ matrix.chart }}"
|
||||||
|
|
||||||
- name: Set up chart-testing
|
- name: Set up chart-testing
|
||||||
uses: helm/chart-testing-action@v2.2.1
|
uses: helm/chart-testing-action@v2.2.1
|
||||||
|
|
||||||
|
@ -75,12 +80,12 @@ jobs:
|
||||||
lint_success:
|
lint_success:
|
||||||
needs:
|
needs:
|
||||||
- generate-lint-matrix
|
- generate-lint-matrix
|
||||||
- lint-charts
|
- lint-chart
|
||||||
if: |
|
if: |
|
||||||
always()
|
always()
|
||||||
name: Lint successful
|
name: Lint successful
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Check lint matrix status
|
- name: Check lint matrix status
|
||||||
if: ${{ (needs.generate-lint-matrix.outputs.detected == 'true') && (needs.lint-charts.result != 'success') }}
|
if: ${{ (needs.generate-lint-matrix.outputs.detected == 'true') && (needs.lint-chart.result != 'success') }}
|
||||||
run: exit 1
|
run: exit 1
|
||||||
|
|
16
.github/workflows/charts-test.yaml
vendored
16
.github/workflows/charts-test.yaml
vendored
|
@ -47,11 +47,11 @@ jobs:
|
||||||
echo "::set-output name=detected::true"
|
echo "::set-output name=detected::true"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
install-charts:
|
install-chart:
|
||||||
needs:
|
needs:
|
||||||
- generate-test-matrix
|
- generate-test-matrix
|
||||||
if: needs.generate-test-matrix.outputs.detected == 'true'
|
if: needs.generate-test-matrix.outputs.detected == 'true'
|
||||||
name: Install charts
|
name: Install chart
|
||||||
strategy:
|
strategy:
|
||||||
matrix: ${{ fromJson(needs.generate-test-matrix.outputs.install-matrix) }}
|
matrix: ${{ fromJson(needs.generate-test-matrix.outputs.install-matrix) }}
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
@ -95,18 +95,18 @@ jobs:
|
||||||
install_success:
|
install_success:
|
||||||
needs:
|
needs:
|
||||||
- generate-test-matrix
|
- generate-test-matrix
|
||||||
- install-charts
|
- install-chart
|
||||||
if: |
|
if: |
|
||||||
always()
|
always()
|
||||||
name: Install successful
|
name: Install successful
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Check install matrix status
|
- name: Check install matrix status
|
||||||
if: ${{ (needs.generate-test-matrix.outputs.detected == 'true') && (needs.install-charts.result != 'success') }}
|
if: ${{ (needs.generate-test-matrix.outputs.detected == 'true') && (needs.install-chart.result != 'success') }}
|
||||||
run: exit 1
|
run: exit 1
|
||||||
|
|
||||||
unittest:
|
unittest-chart:
|
||||||
name: Run unit tests
|
name: Unit-test chart
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
needs:
|
needs:
|
||||||
- generate-test-matrix
|
- generate-test-matrix
|
||||||
|
@ -139,12 +139,12 @@ jobs:
|
||||||
unittest_success:
|
unittest_success:
|
||||||
needs:
|
needs:
|
||||||
- generate-test-matrix
|
- generate-test-matrix
|
||||||
- unittest
|
- unittest-chart
|
||||||
if: |
|
if: |
|
||||||
always()
|
always()
|
||||||
name: Unittest successful
|
name: Unittest successful
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Check unittest matrix status
|
- name: Check unittest matrix status
|
||||||
if: ${{ (needs.generate-test-matrix.outputs.detected == 'true') && (needs.unittest.result != 'success') }}
|
if: ${{ (needs.generate-test-matrix.outputs.detected == 'true') && (needs.unittest-chart.result != 'success') }}
|
||||||
run: exit 1
|
run: exit 1
|
||||||
|
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
node_modules/
|
Loading…
Add table
Add a link
Reference in a new issue