chore(logs): bumps otelcol image #709
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: "E2E Flux/Helm" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| plugin: | |
| description: "Target Plugin" | |
| required: true | |
| default: "kube-monitoring" | |
| type: string | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| push: | |
| branches: | |
| - main | |
| env: | |
| REGISTRY: ghcr.io | |
| PYTHON_VERSION: "3.13" | |
| CT_CONFIG: .github/configs/helm-chart-testing.yaml | |
| E2E_PATH: .github/e2e | |
| jobs: | |
| e2e-flux-helm: | |
| runs-on: [ ubuntu-latest ] | |
| steps: | |
| - name: Set up Helm | |
| uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4.3.1 | |
| with: | |
| version: "v3.19.2" | |
| - name: Set up Flux CLI | |
| uses: fluxcd/flux2/action@8454b02a32e48d775b9f563cb51fdcb1787b5b93 # v2.7.5 | |
| - name: Set up chart-testing | |
| uses: helm/chart-testing-action@6ec842c01de15ebb84c8627d2744a0c2f2755c9f # v2.8.0 | |
| - name: Run Git Checkout | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Validate plugin input | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| set -euo pipefail | |
| PLUGIN="${{ inputs.plugin }}" | |
| [[ -n "$PLUGIN" ]] || { echo "plugin input empty"; exit 1; } | |
| # Allow only safe characters to prevent path traversal | |
| if [[ ! "$PLUGIN" =~ ^[a-zA-Z0-9._-]+$ ]]; then | |
| echo "Invalid plugin name '$PLUGIN' (allowed: a-zA-Z0-9._-)" >&2 | |
| exit 1 | |
| fi | |
| # Must exist as a directory and contain charts/ subdir | |
| if [[ ! -d "$PLUGIN" ]]; then | |
| echo "Directory '$PLUGIN' not found in repo root"; ls -1; exit 1 | |
| fi | |
| if [[ ! -d "$PLUGIN/charts" ]]; then | |
| echo "Directory '$PLUGIN/charts' not found"; ls -1 "$PLUGIN"; exit 1 | |
| fi | |
| echo "✅ Plugin '$PLUGIN' validated." | |
| - name: Run chart-testing (list-changed) | |
| id: list-changed | |
| run: | | |
| # If manually triggered with a plugin input, force that chart as "changed" | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ inputs.plugin }}" ]]; then | |
| forced="${{ inputs.plugin }}/charts" | |
| echo "Manual run: forcing changed chart path: $forced" | |
| echo "$forced" > changed_charts.txt | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| cat changed_charts.txt | |
| exit 0 | |
| fi | |
| changed_charts=$(ct list-changed --config ${{ env.CT_CONFIG }} --target-branch ${{ github.event.repository.default_branch }}) | |
| if [[ -n "$changed_charts" ]]; then | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| echo "$changed_charts" > changed_charts.txt | |
| fi | |
| - name: Verify only one chart changed | |
| if: steps.list-changed.outputs.changed == 'true' | |
| id: chart | |
| run: | | |
| set -euo pipefail | |
| count=$(wc -l < changed_charts.txt | tr -d ' ') | |
| if [[ "$count" -ne 1 ]]; then | |
| echo "Expected exactly 1 changed chart, found $count:" | |
| cat changed_charts.txt | |
| exit 1 | |
| fi | |
| chart_dir="$(head -n1 changed_charts.txt | tr -d '\r')" | |
| chart_yaml="$chart_dir/Chart.yaml" | |
| if [[ ! -f "$chart_yaml" ]]; then | |
| echo "No Chart.yaml at $chart_yaml" | |
| exit 1 | |
| fi | |
| plugin_name="$(yq e '.name' "$chart_yaml")" | |
| # Set outputs | |
| { | |
| echo "chart_dir=$chart_dir" | |
| echo "chart_yaml=$chart_yaml" | |
| echo "plugin_dir=$(dirname "$chart_dir")" | |
| echo "plugin_name=$plugin_name" | |
| } >> "$GITHUB_OUTPUT" | |
| echo "Single changed chart: $chart_dir (name=$plugin_name)" | |
| - name: Create kind cluster | |
| if: steps.list-changed.outputs.changed == 'true' | |
| uses: helm/kind-action@92086f6be054225fa813e0a4b13787fc9088faab # v1.13.0 | |
| - name: Install plugin dependencies (if any) | |
| if: steps.list-changed.outputs.changed == 'true' | |
| run: | | |
| set -euo pipefail | |
| plugin_dir=${{ steps.chart.outputs.plugin_dir }} | |
| dep_file="${plugin_dir}/test-dependencies.yaml" | |
| if [[ ! -f "$dep_file" ]]; then | |
| echo "ℹ️ No test-dependencies.yaml for $plugin_dir" | |
| exit 0 | |
| fi | |
| echo "🔍 Found test-dependencies.yaml for $plugin_dir" | |
| deps=$(yq eval '.dependencies[]' "$dep_file" 2>/dev/null || true) | |
| if [[ -z "$deps" ]]; then | |
| echo "⚠️ No dependencies listed." | |
| exit 0 | |
| fi | |
| values_present=$(yq eval '.values' "$dep_file" 2>/dev/null || true) | |
| for dep in $deps; do | |
| echo "📦 Installing dependent plugin: $dep" | |
| if [[ ! -d "$dep/charts" ]]; then | |
| echo "❌ Expected directory ./$dep/charts" >&2 | |
| exit 1 | |
| fi | |
| if [[ -n "$values_present" && "$values_present" != "null" ]]; then | |
| helm upgrade --install "$dep" "./$dep/charts" --values <(yq eval '.values' "$dep_file") --wait | |
| else | |
| helm upgrade --install "$dep" "./$dep/charts" --wait | |
| fi | |
| done | |
| - name: Install Flux | |
| if: steps.list-changed.outputs.changed == 'true' | |
| run: flux install | |
| - name: Register Flux GitRepository | |
| if: steps.list-changed.outputs.changed == 'true' | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| # Determine branch (PR vs push) | |
| export branch="${{ github.head_ref || github.ref_name }}" | |
| export repo=${{ github.repository }} | |
| yq eval '.spec.url = "https://github.com/" + strenv(repo) | | |
| .spec.ref.branch= strenv(branch)' \ | |
| ${{ env.E2E_PATH }}/gitrepository.yaml | kubectl apply -f - | |
| kubectl -n flux-system get gitrepository workspace -o yaml | |
| - name: Create HelmRelease | |
| if: steps.list-changed.outputs.changed == 'true' | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| chart_yaml=${{ steps.chart.outputs.chart_yaml }} | |
| export chart_dir=${{ steps.chart.outputs.chart_dir }} | |
| export name=${{ steps.chart.outputs.plugin_name }} | |
| export version="$(yq e '.version' "$chart_yaml")" | |
| export VALUES_FILE="${chart_dir}/ci/test-values.yaml" | |
| yq eval '.metadata.name = strenv(name) | | |
| .spec.releaseName = strenv(name) | | |
| .spec.chart.spec.chart= "./" + strenv(chart_dir) | | |
| .spec.chart.spec.version= strenv(version) | | |
| .spec.values= load(strenv(VALUES_FILE))' \ | |
| ${{ env.E2E_PATH }}/helmrelease.yaml | kubectl apply -f - | |
| kubectl -n flux-system get helmrelease ${name} -o yaml | |
| - name: Wait for GitRepository & HelmRelease Ready | |
| if: steps.list-changed.outputs.changed == 'true' | |
| run: | | |
| set -euo pipefail | |
| hr_name=${{ steps.chart.outputs.plugin_name }} | |
| echo "Waiting for GitRepository workspace..." | |
| if ! kubectl -n flux-system wait gitrepository/workspace --for=condition=Ready --timeout=1m; then | |
| echo "GitRepository not Ready:" | |
| kubectl -n flux-system get gitrepository workspace -o yaml || true | |
| kubectl -n flux-system logs deploy/source-controller | tail -n 200 || true | |
| exit 1 | |
| fi | |
| echo "Waiting for HelmRelease $hr_name..." | |
| if ! kubectl -n flux-system wait helmrelease/"$hr_name" --for=condition=Ready --timeout=1m; then | |
| echo "HelmRelease not Ready diagnostics:" | |
| kubectl -n flux-system get helmrelease "$hr_name" -o yaml || true | |
| kubectl -n flux-system logs deploy/helm-controller | tail -n 200 || true | |
| exit 1 | |
| fi | |
| echo "HelmRelease $hr_name Ready." | |
| - name: Run Helm tests | |
| if: steps.list-changed.outputs.changed == 'true' | |
| run: | | |
| set -euo pipefail | |
| release="${{ steps.chart.outputs.plugin_name }}" | |
| echo "Running helm tests for release: $release (namespace: flux-system)" | |
| helm status "$release" -n flux-system | |
| # Run tests (if no test hooks defined this will be a no-op) | |
| helm test "$release" -n flux-system --timeout 5m || { | |
| echo "Helm tests failed, collecting diagnostics..." | |
| kubectl get pods -n flux-system -o wide || true | |
| kubectl logs -l app.kubernetes.io/instance="$release" -n flux-system --tail=200 || true | |
| exit 1 | |
| } | |
| - name: Print pod logs on failure | |
| if: failure() && steps.list-changed.outputs.changed == 'true' | |
| run: | | |
| kubectl get pods -n default || true | |
| helm list -n flux-system | |
| kubectl -n flux-system get gitrepository workspace -o yaml || true | |
| kubectl -n flux-system get helmrelease ${{ steps.chart.outputs.plugin_name }} -o yaml || true | |
| kubectl -n flux-system logs deploy/source-controller | tail -n 200 || true | |
| kubectl -n flux-system logs deploy/helm-controller | tail -n 200 || true | |
| kubectl get deployments -n default | |
| kubectl get services -n default | |
| echo | |
| for pod in $(kubectl get pods -n default --field-selector=status.phase!=Succeeded,status.phase!=Running -o jsonpath='{.items[*].metadata.name}'); do | |
| echo "Logs for pod $pod:" | |
| kubectl logs -n default $pod --all-containers=true || true | |
| done |