|
| 1 | +name: pr-build |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: |
| 6 | + - opened |
| 7 | + - synchronize |
| 8 | + - reopened |
| 9 | + |
| 10 | +permissions: {} |
| 11 | + |
| 12 | +jobs: |
| 13 | + lint-chart: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Harden Runner |
| 17 | + uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1 |
| 18 | + with: |
| 19 | + egress-policy: audit |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 |
| 22 | + with: |
| 23 | + fetch-depth: 0 |
| 24 | + |
| 25 | + - name: Set up Helm |
| 26 | + uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 #v3.5 |
| 27 | + with: |
| 28 | + version: v3.4.0 |
| 29 | + |
| 30 | + - uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0 |
| 31 | + with: |
| 32 | + python-version: 3.13 |
| 33 | + |
| 34 | + - name: Set up chart-testing |
| 35 | + uses: helm/chart-testing-action@0d28d3144d3a25ea2cc349d6e59901c4ff469b3b # v2.7.0 |
| 36 | + |
| 37 | + - name: Run chart-testing (list-changed) |
| 38 | + id: list-changed |
| 39 | + run: | |
| 40 | + changed=$(ct list-changed --target-branch=master --chart-dirs chart) |
| 41 | + if [[ -n "$changed" ]]; then |
| 42 | + echo "::set-output name=changed::true" |
| 43 | + fi |
| 44 | + - name: Run chart-testing (lint) |
| 45 | + run: ct lint --target-branch=master --chart-dirs chart --check-version-increment=false |
| 46 | + |
| 47 | + fmt: |
| 48 | + runs-on: ubuntu-latest |
| 49 | + steps: |
| 50 | + - name: Harden Runner |
| 51 | + uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1 |
| 52 | + with: |
| 53 | + egress-policy: audit |
| 54 | + - name: Checkout |
| 55 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 |
| 56 | + - name: Setup Go |
| 57 | + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 |
| 58 | + with: |
| 59 | + go-version: 1.25.x |
| 60 | + - name: fmt |
| 61 | + run: make fmt |
| 62 | + - name: vet |
| 63 | + run: make vet |
| 64 | + - name: lint |
| 65 | + run: make lint |
| 66 | + - name: Check if working tree is dirty |
| 67 | + run: | |
| 68 | + if [[ $(git diff --stat) != '' ]]; then |
| 69 | + git --no-pager diff |
| 70 | + echo 'run <make test> and commit changes' |
| 71 | + exit 1 |
| 72 | + fi |
| 73 | +
|
| 74 | + test: |
| 75 | + runs-on: ubuntu-latest |
| 76 | + strategy: |
| 77 | + matrix: |
| 78 | + kubernetes-version: |
| 79 | + - "1.27" |
| 80 | + - "1.28" |
| 81 | + - "1.29" |
| 82 | + - "1.30" |
| 83 | + steps: |
| 84 | + - name: Harden Runner |
| 85 | + uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1 |
| 86 | + with: |
| 87 | + egress-policy: audit |
| 88 | + - name: Checkout |
| 89 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 |
| 90 | + - name: Setup Go |
| 91 | + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 |
| 92 | + with: |
| 93 | + go-version: 1.25.x |
| 94 | + - name: run test |
| 95 | + run: make test ENVTEST_K8S_VERSION=${{ matrix.kubernetes-version }} |
| 96 | + |
| 97 | + build: |
| 98 | + runs-on: ubuntu-latest |
| 99 | + outputs: |
| 100 | + profiles: ${{ steps.profiles.outputs.matrix }} |
| 101 | + steps: |
| 102 | + - name: Harden Runner |
| 103 | + uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1 |
| 104 | + with: |
| 105 | + egress-policy: audit |
| 106 | + - name: Checkout |
| 107 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 |
| 108 | + - name: Setup Go |
| 109 | + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 |
| 110 | + with: |
| 111 | + go-version: 1.25.x |
| 112 | + - name: build |
| 113 | + run: make build |
| 114 | + - name: Check if working tree is dirty |
| 115 | + run: | |
| 116 | + if [[ $(git diff --stat) != '' ]]; then |
| 117 | + git --no-pager diff |
| 118 | + echo 'run <make test> and commit changes' |
| 119 | + exit 1 |
| 120 | + fi |
| 121 | + - name: Build container image |
| 122 | + run: | |
| 123 | + make docker-build |
| 124 | + - name: Create image tarball |
| 125 | + run: | |
| 126 | + docker save --output apollo-controller-container.tar apollo-controller:latest |
| 127 | + - name: Upload image |
| 128 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 129 | + with: |
| 130 | + name: apollo-controller-container |
| 131 | + path: apollo-controller-container.tar |
| 132 | + - id: profiles |
| 133 | + name: Determine test profiles |
| 134 | + run: | |
| 135 | + profiles=$(ls config/tests/cases | jq -R -s -c 'split("\n")[:-1]') |
| 136 | + echo $profiles |
| 137 | + echo "::set-output name=matrix::$profiles" |
| 138 | +
|
| 139 | + e2e-tests: |
| 140 | + runs-on: ubuntu-latest |
| 141 | + needs: |
| 142 | + - build |
| 143 | + strategy: |
| 144 | + matrix: |
| 145 | + profile: ${{ fromJson(needs.build.outputs.profiles) }} |
| 146 | + steps: |
| 147 | + - name: Harden Runner |
| 148 | + uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1 |
| 149 | + with: |
| 150 | + egress-policy: audit |
| 151 | + - name: Checkout |
| 152 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 |
| 153 | + - name: Setup Go |
| 154 | + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 |
| 155 | + with: |
| 156 | + go-version: 1.25.x |
| 157 | + - name: Setup Kubernetes |
| 158 | + uses: engineerd/setup-kind@aa272fe2a7309878ffc2a81c56cfe3ef108ae7d0 #v0.5.0 |
| 159 | + with: |
| 160 | + version: v0.17.0 |
| 161 | + - name: Download apollo-controller container |
| 162 | + uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9 |
| 163 | + with: |
| 164 | + name: apollo-controller-container |
| 165 | + path: /tmp |
| 166 | + - name: Load images |
| 167 | + run: | |
| 168 | + docker load --input /tmp/apollo-controller-container.tar |
| 169 | + docker image ls -a |
| 170 | + - name: Setup Kustomize |
| 171 | + uses: imranismail/setup-kustomize@2ba527d4d055ab63514ba50a99456fc35684947f # v2.1.0 |
| 172 | + - name: Run test |
| 173 | + run: | |
| 174 | + make kind-test TEST_PROFILE=${{ matrix.profile }} |
| 175 | + - name: Debug failure |
| 176 | + if: failure() |
| 177 | + run: | |
| 178 | + kubectl -n kube-system describe pods |
| 179 | + kubectl -n swagger-system describe pods |
| 180 | + kubectl -n swagger-system get all |
| 181 | + kubectl -n swagger-system logs deploy/apollo-controller |
| 182 | + kubectl -n swagger-system get swaggerhubs -o yaml |
| 183 | +
|
| 184 | + test-chart: |
| 185 | + runs-on: ubuntu-latest |
| 186 | + needs: |
| 187 | + - build |
| 188 | + - lint-chart |
| 189 | + steps: |
| 190 | + - name: Harden Runner |
| 191 | + uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1 |
| 192 | + with: |
| 193 | + egress-policy: audit |
| 194 | + - name: Checkout |
| 195 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 |
| 196 | + with: |
| 197 | + fetch-depth: 0 |
| 198 | + |
| 199 | + - name: Set up Helm |
| 200 | + uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 #v3.5 |
| 201 | + |
| 202 | + - uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0 |
| 203 | + with: |
| 204 | + python-version: 3.13 |
| 205 | + |
| 206 | + - name: Set up chart-testing |
| 207 | + uses: helm/chart-testing-action@0d28d3144d3a25ea2cc349d6e59901c4ff469b3b # v2.7.0 |
| 208 | + |
| 209 | + - name: Create kind cluster |
| 210 | + uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3 # v1.12.0 |
| 211 | + |
| 212 | + - name: Download apollo-controller container |
| 213 | + uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9 |
| 214 | + with: |
| 215 | + name: apollo-controller-container |
| 216 | + path: /tmp |
| 217 | + |
| 218 | + - name: Load image |
| 219 | + run: | |
| 220 | + docker load --input /tmp/apollo-controller-container.tar |
| 221 | + docker tag apollo-controller:latest ghcr.io/doodlescheduling/apollo-controller:v0.0.0 |
| 222 | + kind load docker-image ghcr.io/doodlescheduling/apollo-controller:v0.0.0 --name chart-testing |
| 223 | + docker image ls -a |
| 224 | + |
| 225 | + - name: Run chart-testing (install) |
| 226 | + run: ct install --target-branch=master --chart-dirs chart |
| 227 | + |
| 228 | + test-success: |
| 229 | + runs-on: ubuntu-latest |
| 230 | + needs: [test, e2e-tests] |
| 231 | + steps: |
| 232 | + - run: echo "all tests succeeded" |
0 commit comments