|
| 1 | +--- |
| 2 | +name: Dockerfile lint and build |
| 3 | + |
| 4 | +on: |
| 5 | + pull_request: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + |
| 9 | +jobs: |
| 10 | + lint: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: Checkout |
| 14 | + uses: actions/checkout@v5 |
| 15 | + |
| 16 | + - uses: hadolint/[email protected] |
| 17 | + |
| 18 | + build: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + needs: lint |
| 21 | + permissions: |
| 22 | + contents: read |
| 23 | + packages: write |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v5 |
| 27 | + |
| 28 | + - name: Set up Docker Buildx |
| 29 | + uses: docker/setup-buildx-action@v3 |
| 30 | + |
| 31 | + - name: Log in to GHCR |
| 32 | + uses: docker/login-action@v3 |
| 33 | + with: |
| 34 | + registry: ghcr.io |
| 35 | + username: ${{ github.actor }} |
| 36 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + |
| 38 | + - name: Build and push Docker image |
| 39 | + uses: docker/build-push-action@v5 |
| 40 | + with: |
| 41 | + context: . |
| 42 | + push: true |
| 43 | + tags: ghcr.io/${{ github.repository }}:pr-${{ github.event.pull_request.number }} |
| 44 | + cache-from: type=gha |
| 45 | + cache-to: type=gha,mode=max |
| 46 | + |
| 47 | + helm-docs: |
| 48 | + runs-on: ubuntu-latest |
| 49 | + steps: |
| 50 | + - name: Checkout |
| 51 | + uses: actions/checkout@v5 |
| 52 | + |
| 53 | + - name: Run helm-docs |
| 54 | + uses: losisin/helm-docs-github-action@v1 |
| 55 | + |
| 56 | + - name: Run prettier over the re-generated docs |
| 57 | + |
| 58 | + with: |
| 59 | + prettier_options: --write kubernetes/chart/zulip/README.md |
| 60 | + no_commit: True |
| 61 | + |
| 62 | + - name: Check for any diff |
| 63 | + run: | |
| 64 | + if ! git diff --exit-code; then |
| 65 | + echo "Changes found!" |
| 66 | + git status |
| 67 | + git diff |
| 68 | + exit 1 |
| 69 | + fi |
| 70 | +
|
| 71 | + helm-test: |
| 72 | + runs-on: ubuntu-latest |
| 73 | + needs: |
| 74 | + - helm-docs |
| 75 | + - build |
| 76 | + steps: |
| 77 | + - name: Checkout |
| 78 | + uses: actions/checkout@v5 |
| 79 | + with: |
| 80 | + fetch-depth: 0 |
| 81 | + |
| 82 | + - name: Set up Helm |
| 83 | + |
| 84 | + with: |
| 85 | + version: v3.17.0 |
| 86 | + |
| 87 | + |
| 88 | + with: |
| 89 | + python-version: "3.x" |
| 90 | + check-latest: true |
| 91 | + |
| 92 | + - name: Set up chart-testing |
| 93 | + |
| 94 | + with: |
| 95 | + version: 3.14.0 |
| 96 | + yamllint_version: 1.37.1 |
| 97 | + yamale_version: 6.0.0 |
| 98 | + |
| 99 | + - name: Set up helm repos |
| 100 | + run: | |
| 101 | + helm repo add groundhog2k https://groundhog2k.github.io/helm-charts/ |
| 102 | +
|
| 103 | + - name: Run chart-testing (list-changed) |
| 104 | + id: list-changed |
| 105 | + run: | |
| 106 | + changed=$(ct list-changed --chart-dirs kubernetes/chart \ |
| 107 | + --target-branch ${{ github.event.repository.default_branch }}) |
| 108 | + if [[ -n "$changed" ]]; then |
| 109 | + echo "changed=true" >> "$GITHUB_OUTPUT" |
| 110 | + fi |
| 111 | +
|
| 112 | + - name: Run chart-testing (lint) |
| 113 | + if: steps.list-changed.outputs.changed == 'true' |
| 114 | + run: | |
| 115 | + ct lint --github-groups \ |
| 116 | + --chart-dirs kubernetes/chart \ |
| 117 | + --target-branch ${{ github.event.repository.default_branch }} \ |
| 118 | + --lint-conf lintconf.yaml |
| 119 | +
|
| 120 | + - name: Create kind cluster |
| 121 | + uses: helm/kind-action@v1 |
| 122 | + |
| 123 | + - name: Log in to GHCR |
| 124 | + uses: docker/login-action@v3 |
| 125 | + with: |
| 126 | + registry: ghcr.io |
| 127 | + username: ${{ github.actor }} |
| 128 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 129 | + |
| 130 | + - name: Load image into kind |
| 131 | + run: | |
| 132 | + docker pull ghcr.io/${{ github.repository }}:pr-${{ github.event.pull_request.number }} |
| 133 | + kind load docker-image ghcr.io/${{ github.repository }}:pr-${{ github.event.pull_request.number }} --name chart-testing |
| 134 | +
|
| 135 | + - name: Run chart-testing (install) |
| 136 | + id: chart-testing-install |
| 137 | + run: | |
| 138 | + ct install --github-groups \ |
| 139 | + --chart-dirs kubernetes/chart \ |
| 140 | + --all \ |
| 141 | + --helm-extra-set-args "--set image.tag=pr-${{ github.event.pull_request.number }}" \ |
| 142 | + --skip-clean-up |
| 143 | +
|
| 144 | + - name: Fetch logs |
| 145 | + if: success() || failure() |
| 146 | + continue-on-error: true |
| 147 | + run: | |
| 148 | + namespace=$(helm list --all-namespaces --output json \ |
| 149 | + | jq -r '[.[] | select(.namespace | startswith("zulip-"))][0].namespace') |
| 150 | + kubectl get pods -n "$namespace" |
| 151 | + for pod in $(kubectl get pods -n "$namespace" -o name); do |
| 152 | + kubectl describe "$pod" -n "$namespace" |
| 153 | + done |
| 154 | + pod=$(kubectl get pods -n "$namespace" -l app.kubernetes.io/name=zulip --output name) |
| 155 | + kubectl -n "$namespace" logs "$pod" |
| 156 | + kubectl -n "$namespace" exec "$pod" -c zulip -- cat /var/log/zulip/errors.log |
0 commit comments