Skip to content

test: add minor version upgrade to the upgrade matrix #3377

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
7 changes: 3 additions & 4 deletions .github/actions/generate-chart-matrix/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ runs:

ls -d ${{ inputs.charts-path }} | while read chart_dir; do
if [[ $(echo ${ALL_MODIFIED_FILES} | grep "${chart_dir}") ]]; then
camunda_version="$(basename ${chart_dir} | sed 's/camunda-platform-//')";
echo "Camunda version: ${camunda_version}"
echo "${camunda_version}" >> matrix_versions.txt;
echo ${chart_dir} >> matrix_versions.txt
fi
done

matrix="$(cat matrix_versions.txt | jq --slurp --compact-output --raw-input 'split("\n") | .[:-1]')"
cd scripts/generate-gha-matrix/
matrix="$(cat ../../matrix_versions.txt | go run .)"
echo "matrix=${matrix}" | tee -a $GITHUB_OUTPUT
2 changes: 1 addition & 1 deletion .github/workflows/chart-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
# Create a tmp file and ensure it's empty.
echo "" > "${matrix_file}"

echo '${{ steps.generate-chart-versions.outputs.matrix }}' | jq -cr '.[]' | while read -r dir_id; do
echo '${{ steps.generate-chart-versions.outputs.matrix }}' | jq -cr '.[].version' | while read -r dir_id; do
chart_file="charts/camunda-platform-${dir_id}/Chart.yaml"

# Extract version info.
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/test-chart-version-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@ on:
description: Chart version to test
required: true
type: string
previous-helm-version:
description: Previous helm version to upgrade from in minor upgrade test
required: false
type: string
pr_number:
description: Pull Request number. Required due to a github bug that is not giving the concurrency group the pull_request number from the github event
required: true
type: string
previous-helm-dir:
description: base directory of the previous helm version to upgrade from for references to test values.yamls
required: false
type: string

concurrency:
group: ${{ github.workflow }}-${{ inputs.pr_number }}-${{ inputs.chart-version }}
Expand Down Expand Up @@ -57,3 +65,24 @@ jobs:
camunda-helm-dir: "camunda-platform-${{ inputs.chart-version }}"
camunda-helm-git-ref: "${{ github.event.pull_request.head.sha }}"
caller-git-ref: "${{ github.event.pull_request.head.sha }}"

minor-upgrade-integration:
name: Camunda ${{ inputs.chart-version }} - Minor upgrade Integration Test
needs: [validation, unit]
permissions:
contents: read
id-token: write
deployments: write
secrets: inherit
uses: ./.github/workflows/test-integration-template.yaml
with:
identifier: "${{ github.event.pull_request.number }}-minr-${{ inputs.chart-version }}"
deployment-ttl: "${{ contains(github.event.pull_request.labels.*.name, 'test-persistent') && '1w' || '' }}"
platforms: "gke"
flows: "upgrade"
camunda-helm-dir: "camunda-platform-${{ inputs.chart-version }}"
camunda-helm-git-ref: "${{ github.event.pull_request.head.sha }}"
camunda-helm-upgrade-version: "${{ inputs.previous-helm-version }}"
camunda-upgrade-helm-dir: "${{ inputs.previous-helm-dir }}"
caller-git-ref: "${{ github.event.pull_request.head.sha }}"

6 changes: 4 additions & 2 deletions .github/workflows/test-chart-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ jobs:
needs: init
strategy:
fail-fast: false
matrix:
version: ${{ fromJson(needs.init.outputs.matrix) }}
matrix:
include: ${{ fromJson(needs.init.outputs.matrix) }}
uses: ./.github/workflows/test-chart-version-template.yaml
secrets: inherit
with:
chart-version: "${{ matrix.version }}"
previous-helm-version: "${{ matrix.previousHelmVersion }}"
pr_number: "${{ github.event.pull_request.number }}" # Required as there is a github bug that prevent the concurrency group on the sub workflow getting the pull_request number from the github event
previous-helm-dir: "${{ matrix.previousHelmDir }}"
19 changes: 16 additions & 3 deletions .github/workflows/test-integration-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ on:
required: false
default: camunda-platform-8.8
type: string
# directory to get values.yaml from during minor upgrade flow
camunda-upgrade-helm-dir:
required: false
description: During upgrade, the path towards the chart base dir that contains values.yamls
default: ""
type: string
camunda-helm-git-ref:
required: false
default: main
Expand Down Expand Up @@ -240,12 +246,14 @@ jobs:
id: test-type-vars
uses: ./.github/actions/test-type-vars
with:
chart-dir: "${{ inputs.camunda-helm-dir }}"
chart-dir: "${{ inputs.camunda-upgrade-helm-dir || inputs.camunda-helm-dir }}"
- name: Add Helm repos and dependencies
run: |
export chartPath="charts/${{ inputs.camunda-helm-dir }}"
export chartPath="charts/$CHART_PATH"
make helm.repos-add
make helm.dependency-update
env:
CHART_PATH: ${{ inputs.camunda-upgrade-helm-dir || inputs.camunda-helm-dir }}
- name: Create test namespace
run: |
echo $TEST_NAMESPACE
Expand Down Expand Up @@ -332,14 +340,19 @@ jobs:
if: matrix.scenario.flow == 'upgrade'
run: |
task -d ${CI_TASKS_BASE_DIR}/chart-full-setup upgrade.pre
- name: Set test type vars
id: test-type-vars-2
uses: ./.github/actions/test-type-vars
with:
chart-dir: "${{ inputs.camunda-helm-dir }}"
- name: 🌟 Upgrade Camunda chart 🌟
if: matrix.scenario.flow == 'upgrade'
env:
TEST_OPENSHIFT_POST_RENDER: ${{ inputs.camunda-helm-post-render }}
TEST_HELM_EXTRA_ARGS: >-
${{ env.TEST_HELM_EXTRA_ARGS_UPGRADE }}
--set global.ingress.host=${{ steps.vars.outputs.ingress-host }}
--values ${{ steps.test-type-vars.outputs.valuesBaseDir }}/infra/values-infra-${{ inputs.infra-type }}.yaml
--values ${{ steps.test-type-vars-2.outputs.valuesBaseDir }}/infra/values-infra-${{ inputs.infra-type }}.yaml
--values /tmp/extra-values-file.yaml
run: |
task -d ${CI_TASKS_BASE_DIR}/chart-full-setup upgrade.exec
Expand Down
1 change: 1 addition & 0 deletions charts/camunda-platform-8.5/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ annotations:
description: "Add global.extraManifests support for injecting arbitrary YAML"
- kind: fixed
description: "Changing helper function for identityURL"
test: test
2 changes: 1 addition & 1 deletion charts/camunda-platform-8.5/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,7 @@ Please see the corresponding [release guide](../../docs/release.md) to find out
| `postgresql.enabled` | if true, a PostgreSQL database will be deployed as part of the Helm release by using the dependency chart | `false` |
| `postgresql.nameOverride` | defines the name of the Postgres resources (names will be prefixed with the release name), see https://github.com/bitnami/charts/tree/main/bitnami/postgresql#common-parameters | `postgresql-web-modeler` |
| `postgresql.image.repository` | PostgreSQL repo | `bitnami/postgresql` |
| `postgresql.image.tag` | PostgreSQL image tag | `14.17.0-debian-12-r10` |
| `postgresql.image.tag` | PostgreSQL image tag | `14.17.0-debian-12-r15` |
| `postgresql.auth` | configuration of the database authentication | |
| `postgresql.auth.username` | defines the name of the database user to be created for WebModeler | `web-modeler` |
| `postgresql.auth.password` | can be used to provide the database user's password; a random password will be generated if left empty / ignored if `postgresql.auth.existingSecret` is set | `""` |
Expand Down
11 changes: 11 additions & 0 deletions scripts/generate-gha-matrix/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

PHONY: test

build:
go build

run:
go run .

test:
go test *.go
25 changes: 25 additions & 0 deletions scripts/generate-gha-matrix/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"fmt"
)

type ProcessError string

func (e ProcessError) Error() string {
return "process: " + string(e)
}

func ProcessErrorf(msg string, args ...interface{}) error {
return ProcessError(fmt.Sprintf(msg, args...))
}

type VersionParsingError string

func (e VersionParsingError) Error() string {
return "versions: " + string(e)
}

func VersionParsingErrorf(msg string, args ...interface{}) error {
return VersionParsingError(fmt.Sprintf(msg, args...))
}
27 changes: 27 additions & 0 deletions scripts/generate-gha-matrix/generate-gha-matrix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package main

import (
"encoding/json"
"fmt"
)

/*
This script accepts input piped into it and outputs a github-actions readable
matrix of tests to run.

ex: echo charts/camunda-platform-8.3 charts/camunda-platform-8.4 charts/camunda-platform-8.8 | go run . | jq
*/
func main() {
input := parseInput()

output, err := processInputs(input)
if err != nil {
panic(err)
}

final, err := json.Marshal(output)
if err != nil {
panic(err)
}
fmt.Println(string(final))
}
15 changes: 15 additions & 0 deletions scripts/generate-gha-matrix/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module github.com/camunda/camunda-platform-helm/scripts/generate-gha-matrix

go 1.23.7

require (
github.com/Masterminds/semver/v3 v3.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/stretchr/testify v1.10.0 // indirect
golang.org/x/mod v0.24.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
helm.sh/helm/v3 v3.17.3 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
20 changes: 20 additions & 0 deletions scripts/generate-gha-matrix/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0=
github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
helm.sh/helm/v3 v3.17.3 h1:3n5rW3D0ArjFl0p4/oWO8IbY/HKaNNwJtOQFdH2AZHg=
helm.sh/helm/v3 v3.17.3/go.mod h1:+uJKMH/UiMzZQOALR3XUf3BLIoczI2RKKD6bMhPh4G8=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
18 changes: 18 additions & 0 deletions scripts/generate-gha-matrix/inputs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
"bufio"
"os"
)

func parseInput() Input {
stdinReader := bufio.NewReader(os.Stdin)
scanner := bufio.NewScanner(stdinReader)
scanner.Split(bufio.ScanWords)

var input Input
for scanner.Scan() {
input.HelmChartModifiedDirectories = append(input.HelmChartModifiedDirectories, scanner.Text())
}
return input
}
31 changes: 31 additions & 0 deletions scripts/generate-gha-matrix/process.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package main

import (
"helm.sh/helm/v3/pkg/chart/loader"
)

func processInputs(input Input) ([]Output, error) {
var output []Output
for _, modifiedDir := range input.HelmChartModifiedDirectories {
chart, err := loader.Load("../../" + modifiedDir)
if err != nil {
return nil, ProcessErrorf("failed to load chart for modified dir %s : %s", modifiedDir, err)
}

version := getCamundaVersion(chart)
previousVersion, err := getPreviousHelmChartVersion(chart, version)
if err != nil {
return nil, ProcessErrorf("failed to get previous helm chart metadata for version %s : %s", version, err)
}

matrixRunVector := Output{
CamundaVersion: version,
HelmChartVersion: chart.Metadata.Version,
PreviousHelmChartVersion: previousVersion.Version,
PreviousHelmChartDir: previousVersion.Dir,
}

output = append(output, matrixRunVector)
}
return output, nil
}
30 changes: 30 additions & 0 deletions scripts/generate-gha-matrix/process_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"github.com/stretchr/testify/require"
"testing"
)

func TestProcess(t *testing.T) {
inputs := Input{
HelmChartModifiedDirectories: []string{"charts/camunda-platform-8.8"},
}

outputs, err := processInputs(inputs)
require.NoError(t, err)

require.Len(t, outputs, 1)
require.Contains(t, outputs[0].CamundaVersion, "8.8")
require.Contains(t, outputs[0].HelmChartVersion, "13")
require.Contains(t, outputs[0].PreviousHelmChartVersion, "12")
}

func TestProcessInvalidChartDir(t *testing.T) {
inputs := Input{
HelmChartModifiedDirectories: []string{"charts/invalid"},
}

outputs, err := processInputs(inputs)
require.NotNil(t, err)
require.Nil(t, outputs)
}
17 changes: 17 additions & 0 deletions scripts/generate-gha-matrix/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main

type Input struct {
HelmChartModifiedDirectories []string
}

type Output struct {
CamundaVersion string `json:"version"`
HelmChartVersion string `json:"chartVersion"`
PreviousHelmChartVersion string `json:"previousHelmVersion"`
PreviousHelmChartDir string `json:"previousHelmDir"`
}

type ChartVersion struct {
Version string
Dir string
}
42 changes: 42 additions & 0 deletions scripts/generate-gha-matrix/versions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package main

import (
"golang.org/x/mod/semver"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chart/loader"
"strconv"
"strings"
)

func getCamundaVersion(chart *chart.Chart) string {
var version string
if chart.Values["zeebe"] == nil {
version = "v" + chart.Values["core"].(map[string]interface{})["image"].(map[string]interface{})["tag"].(string)
} else {
version = "v" + chart.Values["zeebe"].(map[string]interface{})["image"].(map[string]interface{})["tag"].(string)
}
camundaVersionParsed := semver.MajorMinor(version)
camundaVersionParsed = strings.TrimPrefix(camundaVersionParsed, "v")
return camundaVersionParsed
}

func getPreviousHelmChartVersion(chart *chart.Chart, version string) (*ChartVersion, error) {
camundaVersionFloat, err := strconv.ParseFloat(version, 64)
if err != nil {
return nil, VersionParsingErrorf("failed to parse version from input: %s", err)
}
previousVersionFloat := (camundaVersionFloat*10 - 1) / 10
previousCamundaVersion := strconv.FormatFloat(previousVersionFloat, 'f', -1, 64)
previousChartDir := "camunda-platform-" + previousCamundaVersion
previousChart, err := loader.Load("../../charts/" + previousChartDir)
if err != nil {
return nil, VersionParsingErrorf("failed to load the previous chart: %s", err)
}
previousChartVersionSemver := "v" + previousChart.Metadata.Version
previousVersionMajor := semver.Major(previousChartVersionSemver)
previousVersionMajor = strings.TrimPrefix(previousVersionMajor, "v")
return &ChartVersion{
Version: previousVersionMajor,
Dir: previousChartDir,
}, nil
}
Loading
Loading