|
| 1 | +name: Gitea CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - 'applications/gitea/charts/**' |
| 7 | + - 'applications/gitea/tests/**' |
| 8 | + - 'applications/gitea/Makefile' |
| 9 | + - '.github/workflows/gitea-ci.yml' |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + paths: |
| 14 | + - 'applications/gitea/charts/**' |
| 15 | + - 'applications/gitea/tests/**' |
| 16 | + - 'applications/gitea/Makefile' |
| 17 | + - '.github/workflows/gitea-ci.yml' |
| 18 | + |
| 19 | +jobs: |
| 20 | + lint-and-template: |
| 21 | + runs-on: ubuntu-22.04 |
| 22 | + defaults: |
| 23 | + run: |
| 24 | + working-directory: applications/gitea |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - name: Set up Helm |
| 30 | + uses: azure/setup-helm@v4.3.0 |
| 31 | + with: |
| 32 | + version: v3.13.3 |
| 33 | + |
| 34 | + - name: Add Helm repositories |
| 35 | + run: make add-helm-repositories |
| 36 | + |
| 37 | + - name: Update dependencies |
| 38 | + run: make update-dependencies |
| 39 | + |
| 40 | + - name: Helm lint |
| 41 | + run: helm lint ./charts/gitea |
| 42 | + |
| 43 | + - name: Helm template (default values) |
| 44 | + run: helm template gitea ./charts/gitea > /dev/null |
| 45 | + |
| 46 | + - name: Helm template (CI test values) |
| 47 | + run: helm template gitea ./charts/gitea -f tests/helm/ci-values.yaml > /dev/null |
| 48 | + |
| 49 | + helm-install-test: |
| 50 | + runs-on: ubuntu-22.04 |
| 51 | + needs: [lint-and-template] |
| 52 | + defaults: |
| 53 | + run: |
| 54 | + working-directory: applications/gitea |
| 55 | + steps: |
| 56 | + - name: Checkout |
| 57 | + uses: actions/checkout@v4 |
| 58 | + |
| 59 | + - name: Set up Helm |
| 60 | + uses: azure/setup-helm@v4.3.0 |
| 61 | + with: |
| 62 | + version: v3.13.3 |
| 63 | + |
| 64 | + - name: Set up Python |
| 65 | + uses: actions/setup-python@v5 |
| 66 | + with: |
| 67 | + python-version: "3.12" |
| 68 | + |
| 69 | + - name: Create cluster |
| 70 | + id: create-cluster |
| 71 | + uses: replicatedhq/replicated-actions/create-cluster@v1.17.0 |
| 72 | + with: |
| 73 | + api-token: ${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN }} |
| 74 | + kubernetes-distribution: k3s |
| 75 | + kubernetes-version: "1.32" |
| 76 | + cluster-name: gitea-ci-${{ github.run_id }} |
| 77 | + disk: 50 |
| 78 | + nodes: 1 |
| 79 | + ttl: 1h |
| 80 | + export-kubeconfig: true |
| 81 | + |
| 82 | + - name: Install cert-manager |
| 83 | + run: | |
| 84 | + KUBECONFIG_FILE="/tmp/kubeconfig-${{ github.run_id }}" |
| 85 | + echo "$KUBECONFIG" > "$KUBECONFIG_FILE" |
| 86 | + export KUBECONFIG="$KUBECONFIG_FILE" |
| 87 | +
|
| 88 | + helm repo add jetstack https://charts.jetstack.io |
| 89 | + helm repo update jetstack |
| 90 | + helm install cert-manager jetstack/cert-manager \ |
| 91 | + --namespace cert-manager --create-namespace \ |
| 92 | + --set crds.enabled=true \ |
| 93 | + --wait --timeout 5m |
| 94 | + env: |
| 95 | + KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }} |
| 96 | + |
| 97 | + - name: Install CloudNativePG operator |
| 98 | + run: | |
| 99 | + KUBECONFIG_FILE="/tmp/kubeconfig-${{ github.run_id }}" |
| 100 | + echo "$KUBECONFIG" > "$KUBECONFIG_FILE" |
| 101 | + export KUBECONFIG="$KUBECONFIG_FILE" |
| 102 | +
|
| 103 | + helm repo add cnpg https://cloudnative-pg.github.io/charts |
| 104 | + helm repo update cnpg |
| 105 | + helm install cnpg cnpg/cloudnative-pg \ |
| 106 | + --namespace cnpg-system --create-namespace \ |
| 107 | + --wait --timeout 5m |
| 108 | + env: |
| 109 | + KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }} |
| 110 | + |
| 111 | + - name: Install Gitea chart |
| 112 | + run: | |
| 113 | + KUBECONFIG_FILE="/tmp/kubeconfig-${{ github.run_id }}" |
| 114 | + echo "$KUBECONFIG" > "$KUBECONFIG_FILE" |
| 115 | + export KUBECONFIG="$KUBECONFIG_FILE" |
| 116 | +
|
| 117 | + make add-helm-repositories |
| 118 | + make update-dependencies |
| 119 | + helm install gitea ./charts/gitea \ |
| 120 | + -f tests/helm/ci-values.yaml \ |
| 121 | + --wait --timeout 10m |
| 122 | + env: |
| 123 | + KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }} |
| 124 | + |
| 125 | + - name: Wait for pods |
| 126 | + run: | |
| 127 | + KUBECONFIG_FILE="/tmp/kubeconfig-${{ github.run_id }}" |
| 128 | + echo "$KUBECONFIG" > "$KUBECONFIG_FILE" |
| 129 | + export KUBECONFIG="$KUBECONFIG_FILE" |
| 130 | +
|
| 131 | + echo "Waiting for Gitea deployment..." |
| 132 | + kubectl wait --for=condition=Available deployment -l app.kubernetes.io/name=gitea \ |
| 133 | + --timeout=300s |
| 134 | +
|
| 135 | + echo "Waiting for CNPG postgres cluster..." |
| 136 | + kubectl wait --for=condition=Ready pod -l cnpg.io/cluster=gitea-postgres \ |
| 137 | + --timeout=300s |
| 138 | +
|
| 139 | + echo "Waiting for Valkey..." |
| 140 | + kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=valkey \ |
| 141 | + --timeout=120s |
| 142 | + env: |
| 143 | + KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }} |
| 144 | + |
| 145 | + - name: Run smoke tests |
| 146 | + run: | |
| 147 | + KUBECONFIG_FILE="/tmp/kubeconfig-${{ github.run_id }}" |
| 148 | + echo "$KUBECONFIG" > "$KUBECONFIG_FILE" |
| 149 | + export KUBECONFIG="$KUBECONFIG_FILE" |
| 150 | +
|
| 151 | + python -m venv ./venv |
| 152 | + source ./venv/bin/activate |
| 153 | + pip install -r tests/requirements.txt |
| 154 | + python tests/smoke_test.py --release gitea --namespace default |
| 155 | + env: |
| 156 | + KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }} |
| 157 | + |
| 158 | + - name: Debug output |
| 159 | + if: failure() |
| 160 | + run: | |
| 161 | + KUBECONFIG_FILE="/tmp/kubeconfig-${{ github.run_id }}" |
| 162 | + echo "$KUBECONFIG" > "$KUBECONFIG_FILE" |
| 163 | + export KUBECONFIG="$KUBECONFIG_FILE" |
| 164 | +
|
| 165 | + echo "=== Pods ===" |
| 166 | + kubectl get pods -A |
| 167 | + echo "=== Services ===" |
| 168 | + kubectl get svc |
| 169 | + echo "=== Events ===" |
| 170 | + kubectl get events --sort-by='.lastTimestamp' | tail -40 |
| 171 | + echo "=== Gitea pod logs ===" |
| 172 | + kubectl logs -l app.kubernetes.io/name=gitea --tail=50 || true |
| 173 | + echo "=== CNPG cluster status ===" |
| 174 | + kubectl get clusters.postgresql.cnpg.io -o yaml || true |
| 175 | + echo "=== Postgres pod logs ===" |
| 176 | + kubectl logs -l cnpg.io/cluster=gitea-postgres --tail=30 || true |
| 177 | + env: |
| 178 | + KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }} |
| 179 | + |
| 180 | + - name: Remove cluster |
| 181 | + uses: replicatedhq/replicated-actions/remove-cluster@v1.17.0 |
| 182 | + if: ${{ always() && steps.create-cluster.outputs.cluster-id != '' }} |
| 183 | + with: |
| 184 | + api-token: ${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN }} |
| 185 | + cluster-id: ${{ steps.create-cluster.outputs.cluster-id }} |
0 commit comments