K8SPSMDB-1470: revert dependency between crds and operator charts #2352
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Lint and Test Charts | |
| on: | |
| pull_request: | |
| path-ignore: | |
| - 'charts/gcp-marketplace/**' | |
| - 'charts/everest/**' | |
| - 'charts/pmm-ha/**' | |
| - 'charts/pmm-ha-dependencies/**' | |
| jobs: | |
| lint-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Helm | |
| uses: azure/setup-helm@v4.3.1 | |
| with: | |
| version: v3.20.0 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.9' | |
| - name: Set up chart-testing | |
| uses: helm/chart-testing-action@v2.6.1 | |
| - name: Run chart-testing (list-changed) | |
| id: list-changed | |
| run: | | |
| changed=$(ct list-changed --config .github/ct.yaml) | |
| if [[ -n "$changed" ]]; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Run chart-testing (lint) | |
| run: ct lint --config .github/ct.yaml --lint-conf .github/lintconf.yaml --excluded-charts=everest,pmm-ha,pmm-ha-dependencies | |
| - name: Create kind cluster | |
| uses: helm/kind-action@v1.10.0 | |
| # Only build a kind cluster if there are chart changes to test. | |
| if: steps.list-changed.outputs.changed == 'true' | |
| - name: Run db-chart-testing (install) | |
| run: | | |
| echo "Base branch is $GITHUB_BASE_REF" | |
| excluded_charts=("everest") | |
| # Exclude -operator-crds; they are installed in the next step with --take-ownership | |
| while IFS= read -r crd; do [[ -n "$crd" ]] && excluded_charts+=("$crd"); done <<< "$(ct list-changed --config .github/ct.yaml | sed 's:^charts/::' | grep '\-operator-crds$' || true)" | |
| OPERATOR_INSTALL=$(ct list-changed --config .github/ct.yaml | sed -E 's:charts/::' | awk '/(-db|-operator)$/ { sub(/-db$/, "-operator"); print }' | sort -u) | |
| echo "The charts to install: $OPERATOR_INSTALL" | |
| if [ -n "$OPERATOR_INSTALL" ]; then | |
| for operator in $OPERATOR_INSTALL; do | |
| HELM_ARGS=() | |
| if [[ "$GITHUB_BASE_REF" == release-* ]]; then | |
| IMAGE_REPOSITORY_OLD=$(yq e '.operatorImageRepository' "charts/$operator/values.yaml" | awk -F/ '{print $NF}') | |
| IMAGE_REPOSITORY=$(yq e '.image.repository' "charts/$operator/values.yaml" | awk -F/ '{print $NF}') | |
| if [ -n "$IMAGE_REPOSITORY_OLD" ]; then | |
| HELM_ARGS=( | |
| --set "operatorImageRepository=perconalab/$IMAGE_REPOSITORY_OLD" | |
| --set "image=perconalab/$IMAGE_REPOSITORY_OLD:main" | |
| ) | |
| fi | |
| if [ -n "$IMAGE_REPOSITORY" ]; then | |
| HELM_ARGS=( | |
| --set "image.repository=perconalab/$IMAGE_REPOSITORY" | |
| --set "image.tag=main" | |
| ) | |
| fi | |
| echo "${HELM_ARGS[@]}" | |
| fi | |
| echo "Installing $operator with Helm args: ${HELM_ARGS[@]}" | |
| helm install --namespace default $operator charts/$operator/. --wait --debug "${HELM_ARGS[@]}" | |
| excluded_charts+=($operator) | |
| done | |
| fi | |
| ct install --config .github/ct.yaml --excluded-charts=$(IFS=,; echo "${excluded_charts[*]}") | |
| if [ -n "$OPERATOR_INSTALL" ]; then | |
| for operator in $OPERATOR_INSTALL; do helm uninstall --namespace default $operator; done | |
| fi | |
| - name: Run crd-chart-testing (install) | |
| run: | | |
| CRD_INSTALL=$(ct list-changed --config .github/ct.yaml | sed 's:^charts/::' | grep '\-operator-crds$') | |
| if [ -n "$CRD_INSTALL" ]; then | |
| for crd in $CRD_INSTALL; do | |
| helm install --namespace default $crd charts/$crd/. --take-ownership | |
| helm uninstall --namespace default $crd | |
| done | |
| fi | |
| - name: Build chart package | |
| run: | | |
| changed=$(ct list-changed --config .github/ct.yaml) | |
| [ $(echo -n "$changed" | grep -c '^') == 1 ] && helm package $changed || echo "skipping package" | |
| - name: Upload helm chart | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| path: ./*.tgz | |
| retention-days: 30 | |
| if-no-files-found: ignore |