feat(fork): sync from upstream #212
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: "Pull Request" | |
| on: | |
| pull_request_target: | |
| types: | |
| - opened | |
| - reopened | |
| - synchronize | |
| branches: | |
| - main | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| jobs: | |
| lint-test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| permissions: | |
| contents: read | |
| outputs: | |
| changed: ${{ steps.list-changed.outputs.changed }} | |
| changedCharts: ${{ steps.list-changed.outputs.changedCharts }} | |
| steps: | |
| - name: Setup Helm | |
| uses: Azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4.3.1 | |
| - name: Checkout pull request branch | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| repository: ${{github.event.pull_request.head.repo.full_name}} | |
| fetch-depth: 0 | |
| - name: Fetch upstream main branch | |
| run: | | |
| # Fetch the base repository's target branch and update origin/main to point to it | |
| git remote set-url origin https://github.com/CloudPirates-io/helm-charts.git | |
| git fetch origin ${{ github.event.repository.default_branch }} | |
| # Re-add the fork as a remote and checkout the PR branch | |
| git remote add fork https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git || true | |
| git fetch fork ${{ github.head_ref }} | |
| # Python is required because `ct lint` runs Yamale (https://github.com/23andMe/Yamale) and | |
| # yamllint (https://github.com/adrienverge/yamllint) which require Python | |
| - name: Set up Python | |
| uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 | |
| with: | |
| python-version: 3.11 | |
| - name: Set up chart-testing-action | |
| uses: helm/chart-testing-action@0d28d3144d3a25ea2cc349d6e59901c4ff469b3b # v2.7.0 | |
| - name: Get changed charts | |
| id: list-changed | |
| run: | | |
| changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) | |
| if [[ -n "$changed" ]]; then | |
| echo "Changed charts:" | |
| echo "$changed" | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| echo 'changedCharts<<EOF' >> $GITHUB_OUTPUT | |
| echo $changed >> $GITHUB_OUTPUT | |
| echo 'EOF' >> $GITHUB_OUTPUT | |
| else | |
| echo "No chart changes detected" | |
| fi | |
| - name: Cache Helm plugins | |
| if: steps.list-changed.outputs.changed == 'true' | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: ~/.local/share/helm/plugins | |
| key: ${{ runner.os }}-helm-plugins-${{ hashFiles('**/plugin.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-helm-plugins- | |
| - name: Installing plugin helm-unittest | |
| if: steps.list-changed.outputs.changed == 'true' | |
| run: | | |
| if ! helm plugin list | grep -q unittest; then | |
| helm plugin install https://github.com/helm-unittest/helm-unittest | |
| else | |
| echo "helm-unittest plugin already installed" | |
| fi | |
| - name: Run chart testing (lint & unittest) | |
| if: steps.list-changed.outputs.changed == 'true' | |
| run: | | |
| ct lint --target-branch ${{ github.event.repository.default_branch }} --validate-maintainers=false --additional-commands 'helm unittest {{ .Path }}' | |
| integration-test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| permissions: | |
| contents: read | |
| needs: [lint-test] | |
| if: needs.lint-test.outputs.changed == 'true' | |
| steps: | |
| - name: Checkout pull request branch | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| repository: ${{github.event.pull_request.head.repo.full_name}} | |
| fetch-depth: 0 | |
| - name: Setup Helm | |
| uses: Azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4.3.1 | |
| - name: Setup kubectl | |
| uses: azure/setup-kubectl@776406bce94f63e41d621b960d78ee25c8b76ede # v4.0.1 | |
| - name: Login to Docker Hub to avoid rate limits | |
| uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 | |
| with: | |
| username: ${{ secrets.REGISTRY_USER }} | |
| password: ${{ secrets.REGISTRY_PASSWORD }} | |
| - name: Create kind cluster | |
| uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3 # v1.12.0 | |
| with: | |
| cluster_name: helm-chart-test | |
| wait: 300s | |
| - name: Cache Helm plugins | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: ~/.local/share/helm/plugins | |
| key: ${{ runner.os }}-helm-plugins-${{ hashFiles('**/plugin.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-helm-plugins- | |
| - name: Installing plugin helm-unittest | |
| run: | | |
| if ! helm plugin list | grep -q unittest; then | |
| helm plugin install https://github.com/helm-unittest/helm-unittest | |
| else | |
| echo "helm-unittest plugin already installed" | |
| fi | |
| - name: Run integration tests | |
| env: | |
| CHANGED_CHARTS: ${{ needs.lint-test.outputs.changedCharts }} | |
| run: | | |
| # Make script executable | |
| chmod +x ./test-charts.sh | |
| # Test each changed chart | |
| for chart_directory in ${CHANGED_CHARTS}; do | |
| CHART_NAME=${chart_directory#charts/} | |
| echo "Testing chart: $CHART_NAME" | |
| # Check if integration test is disabled for this chart | |
| if [ -f "${chart_directory}/.disable-unittest" ]; then | |
| echo "⏩ Skipping integration test for $CHART_NAME (.disable-unittest found)" | |
| continue | |
| fi | |
| # Run test script without cluster creation (kind-action already created it) | |
| # and without cleanup (let GitHub Actions handle it) | |
| ./test-charts.sh "$CHART_NAME" --no-cleanup | |
| done |