Skip to content

Commit 0ee8cd2

Browse files
authored
ci: update chart index and improve checks (#1963)
1 parent 40a3d20 commit 0ee8cd2

File tree

2 files changed

+56
-16
lines changed

2 files changed

+56
-16
lines changed

chart/chart-index/Chart.yaml

+6-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies:
1515
version: 0.23.0
1616
repository: https://cloudnative-pg.github.io/charts
1717
- name: external-dns
18-
version: 6.20.4
18+
version: 8.3.9
1919
repository: https://charts.bitnami.com/bitnami
2020
- name: falco
2121
version: 3.8.5
@@ -30,10 +30,10 @@ dependencies:
3030
version: 1.16.2
3131
repository: https://helm.goharbor.io
3232
- name: ingress-nginx
33-
version: 4.6.1
33+
version: 4.11.2
3434
repository: https://kubernetes.github.io/ingress-nginx
3535
- name: jaeger-operator
36-
version: 2.57.0
36+
version: 2.46.0
3737
repository: https://jaegertracing.github.io/helm-charts
3838
- name: kiali-operator
3939
version: 1.86.1
@@ -42,7 +42,7 @@ dependencies:
4242
version: 0.1.0
4343
repository: https://knative.github.io/operator
4444
- name: kube-prometheus-stack
45-
version: 46.4.1
45+
version: 65.2.0
4646
repository: https://prometheus-community.github.io/helm-charts
4747
- name: kured
4848
version: 4.6.0
@@ -61,7 +61,7 @@ dependencies:
6161
version: 11.10.13
6262
repository: https://charts.bitnami.com/bitnami
6363
- name: oauth2-proxy
64-
version: 3.7.4
64+
version: 7.7.24
6565
repository: https://charts.bitnami.com/bitnami
6666
- name: opentelemetry-operator
6767
alias: otel-operator
@@ -83,6 +83,7 @@ dependencies:
8383
version: 2.17.1
8484
repository: https://bitnami-labs.github.io/sealed-secrets/
8585
- name: tekton-pipeline
86+
alias: tekton-pipelines
8687
version: 1.0.2
8788
repository: https://cdfoundation.github.io/tekton-helm-chart/
8889
- name: tempo-distributed

ci/src/update-helm-chart-deps.mjs

+50-11
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,13 @@ async function main() {
4848
const ciCreateGithubPr = !env.CI_GIT_LOCAL_BRANCH_ONLY && env.CI_GH_CREATE_PR && ciCreateFeatureBranch
4949
const dependencyNameFilter = env.CI_HELM_CHART_NAME_FILTER || []
5050
const baseBranch = env.CI_GIT_BASELINE_BRANCH
51+
5152
try {
5253
// Read the Chart.yaml file
5354
const chartContent = await fs.readFile(chartFile, 'utf8')
5455
const chart = yaml.load(chartContent)
56+
const dependencyErrors = {}
57+
const fixedChartVersions = {}
5558

5659
if (!chart.dependencies || !Array.isArray(chart.dependencies)) {
5760
console.error('No dependencies found in Chart.yaml')
@@ -67,6 +70,23 @@ async function main() {
6770
continue
6871
}
6972

73+
console.log(`Pre-check for dependency ${dependency.name}`)
74+
try {
75+
const dependencyFileName = `${chartsDir}/${dependency.alias || dependency.name}/Chart.yaml`
76+
const dependencyFile = await fs.readFile(dependencyFileName, 'utf8')
77+
const dependencyChart = yaml.load(dependencyFile)
78+
if (dependencyChart.version !== currentDependencyVersion) {
79+
console.error(`Skipping update, indexed version of dependency ${dependency.name} is not consistent with chart version.`)
80+
dependencyErrors[dependency.name] = 'Indexed version of dependency is not consistent with chart version.'
81+
fixedChartVersions[dependency.name] = dependencyChart.version
82+
continue
83+
}
84+
} catch (error) {
85+
console.error(`Error checking dependency ${dependency.name}:`, error)
86+
dependencyErrors[dependency.name] = error
87+
continue
88+
}
89+
7090
console.log(`Checking updates for dependency: ${dependency.name}`)
7191
try {
7292
// Add the Helm repository (idempotent)
@@ -80,6 +100,7 @@ async function main() {
80100

81101
if (!allVersions.length) {
82102
console.error(`No valid versions found for dependency ${dependency.name}`)
103+
dependencyErrors[dependency.name] = 'No valid versions found.'
83104
continue
84105
}
85106

@@ -102,14 +123,13 @@ async function main() {
102123
continue
103124
}
104125
const branchName = `ci-update-${dependency.name}-to-${latestVersion}`
105-
if (ciPushtoBranch) {
106-
const remoteBranch = await $`git ls-remote --heads origin ${branchName}`
107-
if (remoteBranch.stdout !== '') {
108-
console.log(
109-
`Skipping updates for dependency: ${dependency.name}: the remote branch ${branchName} already exists`,
110-
)
111-
continue
112-
}
126+
const checkBranchCmd = ciPushtoBranch ? $`git ls-remote --heads origin ${branchName}` : $`git branch --list ${branchName}`
127+
const existingBranch = await checkBranchCmd
128+
if (existingBranch.stdout !== '') {
129+
console.log(
130+
`Skipping updates for dependency: ${dependency.name}: the feature branch ${branchName} already exists`,
131+
)
132+
continue
113133
}
114134

115135
console.log(`Updating ${dependency.name} from version ${currentVersion} to ${latestVersion}`)
@@ -119,7 +139,7 @@ async function main() {
119139

120140
const commitMessage = `chore(chart-deps): update ${dependency.name} to version ${latestVersion}`
121141
if (ciCreateFeatureBranch) {
122-
await $`git checkout -b ${branchName}`
142+
await $`git -c core.hooksPath=/dev/null checkout -b ${branchName}`
123143
}
124144

125145
// Write the updated Chart.yaml file
@@ -155,18 +175,37 @@ async function main() {
155175
}
156176
} catch (error) {
157177
console.error('Error updating dependencies:', error)
178+
dependencyErrors[dependency.name] = error
158179
} finally {
159180
// restore this version so it does not populate to the next chart update
160181
dependency.version = currentDependencyVersion
161182
if (ciCreateFeatureBranch) {
162183
// Reset to the main branch for the next dependency
163-
await $`git checkout ${baseBranch}`
164-
await $`git reset --hard origin/${baseBranch}`
184+
await $`git -c core.hooksPath=/dev/null checkout ${baseBranch}`
185+
await $`git reset --hard ${ciPushtoBranch ? 'origin/' : ''}${baseBranch}`
165186
}
166187
}
167188
}
168189

169190
console.log('Dependency updates complete.')
191+
if (Object.keys(dependencyErrors).length > 0) {
192+
console.log('Summary of errors encountered during the update:')
193+
Object.entries(dependencyErrors).forEach(([key, value]) => {
194+
console.log(`${key}:`, value)
195+
})
196+
}
197+
if (Object.keys(fixedChartVersions).length > 0 && !ciPushtoBranch) {
198+
console.log('Writing mismatching versions to chart index.')
199+
for (const dependency of chart.dependencies) {
200+
const fixedVersion = fixedChartVersions[dependency.name]
201+
if (fixedVersion) {
202+
dependency.version = fixedVersion
203+
}
204+
}
205+
// Write the updated Chart.yaml file
206+
const updatedChart = yaml.dump(chart)
207+
await fs.writeFile(chartFile, updatedChart, 'utf8')
208+
}
170209
} catch (error) {
171210
console.error('Error updating dependencies:', error)
172211
process.exit(1)

0 commit comments

Comments
 (0)