|
| 1 | +name: Image Substitution Integration Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, develop] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +env: |
| 11 | + REGISTRY: asia-south1-docker.pkg.dev |
| 12 | + PROJECT_ID: test-project |
| 13 | + REPOSITORY: test-repo |
| 14 | + |
| 15 | +jobs: |
| 16 | + test-current-version: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + name: Test Current Version (Should Work) |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout repository |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Set up Node.js |
| 25 | + uses: actions/setup-node@v4 |
| 26 | + with: |
| 27 | + node-version: '18' |
| 28 | + cache: 'npm' |
| 29 | + |
| 30 | + - name: Install dependencies and build |
| 31 | + run: | |
| 32 | + npm ci |
| 33 | + npm run build |
| 34 | +
|
| 35 | + - name: Create fake kubeconfig |
| 36 | + run: | |
| 37 | + mkdir -p ~/.kube |
| 38 | + cat << EOF > ~/.kube/config |
| 39 | + apiVersion: v1 |
| 40 | + kind: Config |
| 41 | + clusters: |
| 42 | + - cluster: |
| 43 | + server: https://fake-cluster.example.com |
| 44 | + name: fake-cluster |
| 45 | + contexts: |
| 46 | + - context: |
| 47 | + cluster: fake-cluster |
| 48 | + user: fake-user |
| 49 | + name: fake-context |
| 50 | + current-context: fake-context |
| 51 | + users: |
| 52 | + - name: fake-user |
| 53 | + user: |
| 54 | + token: fake-token |
| 55 | + EOF |
| 56 | +
|
| 57 | + - name: Deploy CronJob with current version |
| 58 | + id: cronjob-current |
| 59 | + continue-on-error: true |
| 60 | + uses: ./ |
| 61 | + with: |
| 62 | + action: deploy |
| 63 | + namespace: default |
| 64 | + manifests: | |
| 65 | + test/integration/manifests/test-cronjob.yaml |
| 66 | + images: | |
| 67 | + asia-south1-docker.pkg.dev/project/repo/image:${{ github.sha }} |
| 68 | +
|
| 69 | + - name: Deploy ScaledJob with current version |
| 70 | + id: scaledjob-current |
| 71 | + continue-on-error: true |
| 72 | + uses: ./ |
| 73 | + with: |
| 74 | + action: deploy |
| 75 | + namespace: default |
| 76 | + manifests: | |
| 77 | + test/integration/manifests/test-scaledjob.yaml |
| 78 | + images: | |
| 79 | + asia-south1-docker.pkg.dev/project/repo/image:${{ github.sha }} |
| 80 | +
|
| 81 | + - name: Verify current version results |
| 82 | + run: | |
| 83 | + echo "Current version test results:" |
| 84 | + echo "CronJob outcome: ${{ steps.cronjob-current.outcome }}" |
| 85 | + echo "ScaledJob outcome: ${{ steps.scaledjob-current.outcome }}" |
| 86 | +
|
| 87 | + # Both should fail due to fake kubectl, but they should process the manifests |
| 88 | + if [[ "${{ steps.cronjob-current.outcome }}" == "failure" && "${{ steps.scaledjob-current.outcome }}" == "failure" ]]; then |
| 89 | + echo "✅ Current version processed both CronJob and ScaledJob (kubectl failures expected)" |
| 90 | + else |
| 91 | + echo "❌ Unexpected outcomes with current version" |
| 92 | + exit 1 |
| 93 | + fi |
| 94 | +
|
| 95 | + test-old-version: |
| 96 | + runs-on: ubuntu-latest |
| 97 | + name: Test Old Version v5.0.3 (Should Fail on ScaledJob) |
| 98 | + |
| 99 | + steps: |
| 100 | + - name: Checkout repository |
| 101 | + uses: actions/checkout@v4 |
| 102 | + |
| 103 | + - name: Create fake kubeconfig |
| 104 | + run: | |
| 105 | + mkdir -p ~/.kube |
| 106 | + cat << EOF > ~/.kube/config |
| 107 | + apiVersion: v1 |
| 108 | + kind: Config |
| 109 | + clusters: |
| 110 | + - cluster: |
| 111 | + server: https://fake-cluster.example.com |
| 112 | + name: fake-cluster |
| 113 | + contexts: |
| 114 | + - context: |
| 115 | + cluster: fake-cluster |
| 116 | + user: fake-user |
| 117 | + name: fake-context |
| 118 | + current-context: fake-context |
| 119 | + users: |
| 120 | + - name: fake-user |
| 121 | + user: |
| 122 | + token: fake-token |
| 123 | + EOF |
| 124 | +
|
| 125 | + - name: Deploy CronJob with old version v5.0.3 |
| 126 | + id: cronjob-old |
| 127 | + continue-on-error: true |
| 128 | + uses: azure/k8s-deploy@v5.0.3 |
| 129 | + with: |
| 130 | + action: deploy |
| 131 | + namespace: default |
| 132 | + manifests: | |
| 133 | + test/integration/manifests/test-cronjob.yaml |
| 134 | + images: | |
| 135 | + asia-south1-docker.pkg.dev/project/repo/image:${{ github.sha }} |
| 136 | +
|
| 137 | + - name: Deploy ScaledJob with old version v5.0.3 |
| 138 | + id: scaledjob-old |
| 139 | + continue-on-error: true |
| 140 | + uses: azure/k8s-deploy@v5.0.3 |
| 141 | + with: |
| 142 | + action: deploy |
| 143 | + namespace: default |
| 144 | + manifests: | |
| 145 | + test/integration/manifests/test-scaledjob.yaml |
| 146 | + images: | |
| 147 | + asia-south1-docker.pkg.dev/project/repo/image:${{ github.sha }} |
| 148 | +
|
| 149 | + - name: Verify old version results |
| 150 | + run: | |
| 151 | + echo "Old version test results:" |
| 152 | + echo "CronJob outcome: ${{ steps.cronjob-old.outcome }}" |
| 153 | + echo "ScaledJob outcome: ${{ steps.scaledjob-old.outcome }}" |
| 154 | +
|
| 155 | + # CronJob should work (kubectl failure), ScaledJob should fail earlier due to unsupported type |
| 156 | + if [[ "${{ steps.cronjob-old.outcome }}" == "failure" ]]; then |
| 157 | + echo "✅ Old version processed CronJob (kubectl failure expected)" |
| 158 | + else |
| 159 | + echo "❌ Old version CronJob had unexpected outcome" |
| 160 | + fi |
| 161 | +
|
| 162 | + if [[ "${{ steps.scaledjob-old.outcome }}" == "failure" ]]; then |
| 163 | + echo "✅ Old version failed on ScaledJob as expected (unsupported workload type)" |
| 164 | + else |
| 165 | + echo "❌ Old version should have failed on ScaledJob" |
| 166 | + exit 1 |
| 167 | + fi |
| 168 | +
|
| 169 | + echo "🎉 Version comparison test completed successfully!" |
| 170 | +
|
| 171 | + - name: Cleanup |
| 172 | + if: always() |
| 173 | + run: | |
| 174 | + echo "✅ Test completed - no cleanup needed" |
0 commit comments