|
| 1 | +name: Test InProd Run Changesets Action |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - develop |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +jobs: |
| 14 | + unit-tests: |
| 15 | + name: Unit Tests |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Setup Node.js |
| 21 | + uses: actions/setup-node@v4 |
| 22 | + with: |
| 23 | + node-version: '20' |
| 24 | + cache: 'npm' |
| 25 | + |
| 26 | + - name: Install dependencies |
| 27 | + run: npm ci |
| 28 | + |
| 29 | + - name: Run unit tests |
| 30 | + run: npm test |
| 31 | + |
| 32 | + - name: Run tests with coverage |
| 33 | + run: npm run test:coverage |
| 34 | + |
| 35 | + - name: Verify dist is up to date |
| 36 | + run: | |
| 37 | + npm run build |
| 38 | + if [ -n "$(git diff --name-only dist/)" ]; then |
| 39 | + echo "::error::dist/index.js is out of date. Run 'npm run build' and commit the result." |
| 40 | + git diff --stat dist/ |
| 41 | + exit 1 |
| 42 | + fi |
| 43 | + echo "✓ dist/index.js is up to date" |
| 44 | +
|
| 45 | + test-action-no-wait: |
| 46 | + name: Test Action - Submit Only (No Wait) |
| 47 | + runs-on: ubuntu-latest |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v4 |
| 50 | + |
| 51 | + - name: Create test changeset file |
| 52 | + run: | |
| 53 | + mkdir -p changesets |
| 54 | + cat > changesets/test-queue.yaml << 'EOF' |
| 55 | + name: Test Queue Creation |
| 56 | + environment: Development |
| 57 | + enforcing: true |
| 58 | + run_type: stop |
| 59 | + action: |
| 60 | + - action: gencloud-create |
| 61 | + object_type: RoutingQueue |
| 62 | + data: |
| 63 | + name: Test Support Queue |
| 64 | + division: |
| 65 | + lookup_method: empty |
| 66 | + value: null |
| 67 | + variable: [] |
| 68 | + EOF |
| 69 | +
|
| 70 | + - name: Submit changeset (no wait) |
| 71 | + id: inprod-submit |
| 72 | + uses: ./ |
| 73 | + with: |
| 74 | + api_key: ${{ secrets.INPROD_API_KEY || 'test-api-key' }} |
| 75 | + base_url: https://your-company.inprod.io |
| 76 | + changeset_file: changesets/test-queue.yaml |
| 77 | + validate_before_execute: false |
| 78 | + wait_for_completion: false |
| 79 | + |
| 80 | + - name: Display submission result |
| 81 | + run: | |
| 82 | + echo "Task ID: ${{ steps.inprod-submit.outputs.task_id }}" |
| 83 | + echo "Status: ${{ steps.inprod-submit.outputs.status }}" |
| 84 | +
|
| 85 | + test-action-with-file: |
| 86 | + name: Test Action - Changeset from File |
| 87 | + runs-on: ubuntu-latest |
| 88 | + steps: |
| 89 | + - uses: actions/checkout@v4 |
| 90 | + |
| 91 | + - name: Create test changeset file |
| 92 | + run: | |
| 93 | + mkdir -p changesets |
| 94 | + cat > changesets/test-queue.yaml << 'EOF' |
| 95 | + name: Test Queue from File |
| 96 | + environment: Development |
| 97 | + enforcing: true |
| 98 | + run_type: stop |
| 99 | + action: |
| 100 | + - action: gencloud-create |
| 101 | + object_type: RoutingQueue |
| 102 | + data: |
| 103 | + name: File Test Queue |
| 104 | + division: |
| 105 | + lookup_method: empty |
| 106 | + value: null |
| 107 | + variable: [] |
| 108 | + EOF |
| 109 | +
|
| 110 | + - name: Submit changeset from file (no wait) |
| 111 | + id: inprod-file |
| 112 | + uses: ./ |
| 113 | + with: |
| 114 | + api_key: ${{ secrets.INPROD_API_KEY || 'test-api-key' }} |
| 115 | + base_url: https://your-company.inprod.io |
| 116 | + changeset_file: changesets/test-queue.yaml |
| 117 | + environment: Development |
| 118 | + validate_before_execute: false |
| 119 | + wait_for_completion: false |
| 120 | + continue-on-error: true |
| 121 | + |
| 122 | + - name: Display result |
| 123 | + run: | |
| 124 | + echo "Task ID: ${{ steps.inprod-file.outputs.task_id }}" |
| 125 | + echo "Status: ${{ steps.inprod-file.outputs.status }}" |
| 126 | +
|
| 127 | + test-validate-only: |
| 128 | + name: Test Action - Validate Only |
| 129 | + runs-on: ubuntu-latest |
| 130 | + if: github.event_name == 'workflow_dispatch' |
| 131 | + steps: |
| 132 | + - uses: actions/checkout@v4 |
| 133 | + |
| 134 | + - name: Create test changeset file |
| 135 | + run: | |
| 136 | + mkdir -p changesets |
| 137 | + cat > changesets/validate-test.yaml << 'EOF' |
| 138 | + name: Validate Only Test |
| 139 | + environment: Development |
| 140 | + enforcing: true |
| 141 | + run_type: stop |
| 142 | + action: |
| 143 | + - action: gencloud-create |
| 144 | + object_type: RoutingQueue |
| 145 | + data: |
| 146 | + name: Validation Test Queue |
| 147 | + division: |
| 148 | + lookup_method: empty |
| 149 | + value: null |
| 150 | + variable: [] |
| 151 | + EOF |
| 152 | +
|
| 153 | + - name: Validate changeset only |
| 154 | + id: inprod-validate |
| 155 | + uses: ./ |
| 156 | + with: |
| 157 | + api_key: ${{ secrets.INPROD_API_KEY || 'test-api-key' }} |
| 158 | + base_url: https://your-company.inprod.io |
| 159 | + changeset_file: changesets/validate-test.yaml |
| 160 | + environment: Development |
| 161 | + validate_only: true |
| 162 | + polling_timeout_minutes: 5 |
| 163 | + |
| 164 | + - name: Display validation result |
| 165 | + run: | |
| 166 | + echo "Task ID: ${{ steps.inprod-validate.outputs.task_id }}" |
| 167 | + echo "Status: ${{ steps.inprod-validate.outputs.status }}" |
| 168 | + echo "Result: ${{ steps.inprod-validate.outputs.result }}" |
| 169 | +
|
| 170 | + test-action-with-wait: |
| 171 | + name: Test Action - With Wait for Completion |
| 172 | + runs-on: ubuntu-latest |
| 173 | + if: github.event_name == 'workflow_dispatch' |
| 174 | + steps: |
| 175 | + - uses: actions/checkout@v4 |
| 176 | + |
| 177 | + - name: Create test changeset file |
| 178 | + run: | |
| 179 | + mkdir -p changesets |
| 180 | + cat > changesets/wait-test.yaml << 'EOF' |
| 181 | + name: Test Queue Update |
| 182 | + environment: Development |
| 183 | + enforcing: true |
| 184 | + run_type: stop |
| 185 | + action: |
| 186 | + - action: gencloud-create |
| 187 | + object_type: RoutingQueue |
| 188 | + data: |
| 189 | + name: Updated Test Queue |
| 190 | + division: |
| 191 | + lookup_method: empty |
| 192 | + value: null |
| 193 | + variable: [] |
| 194 | + EOF |
| 195 | +
|
| 196 | + - name: Execute changeset with wait |
| 197 | + id: inprod-execute |
| 198 | + uses: ./ |
| 199 | + with: |
| 200 | + api_key: ${{ secrets.INPROD_API_KEY || 'test-api-key' }} |
| 201 | + base_url: https://your-company.inprod.io |
| 202 | + changeset_file: changesets/wait-test.yaml |
| 203 | + environment: Development |
| 204 | + wait_for_completion: true |
| 205 | + polling_timeout_minutes: 5 |
| 206 | + |
| 207 | + - name: Display execution result |
| 208 | + run: | |
| 209 | + echo "Task ID: ${{ steps.inprod-execute.outputs.task_id }}" |
| 210 | + echo "Status: ${{ steps.inprod-execute.outputs.status }}" |
| 211 | + echo "Result: ${{ steps.inprod-execute.outputs.result }}" |
| 212 | +
|
| 213 | + - name: Check execution success |
| 214 | + if: steps.inprod-execute.outputs.status == 'SUCCESS' |
| 215 | + run: | |
| 216 | + echo "✓ Changeset execution succeeded!" |
| 217 | + echo "Result details:" |
| 218 | + echo "${{ steps.inprod-execute.outputs.result }}" | jq '.' |
| 219 | +
|
| 220 | + - name: Handle execution failure |
| 221 | + if: failure() |
| 222 | + run: | |
| 223 | + echo "✗ Changeset execution failed. Check logs above." |
| 224 | + exit 1 |
| 225 | +
|
| 226 | + validate-inputs: |
| 227 | + name: Validate Action Inputs |
| 228 | + runs-on: ubuntu-latest |
| 229 | + steps: |
| 230 | + - uses: actions/checkout@v4 |
| 231 | + |
| 232 | + - name: Create test changeset files |
| 233 | + run: | |
| 234 | + mkdir -p changesets |
| 235 | + cat > changesets/minimal.yaml << 'EOF' |
| 236 | + name: Minimal Test |
| 237 | + environment: Development |
| 238 | + action: [] |
| 239 | + variable: [] |
| 240 | + EOF |
| 241 | + cat > changesets/timeout-test.yaml << 'EOF' |
| 242 | + name: Timeout Test |
| 243 | + environment: Development |
| 244 | + action: [] |
| 245 | + variable: [] |
| 246 | + EOF |
| 247 | +
|
| 248 | + - name: Test with minimal inputs |
| 249 | + id: minimal |
| 250 | + uses: ./ |
| 251 | + with: |
| 252 | + api_key: test-key-123 |
| 253 | + base_url: https://test.inprod.io |
| 254 | + changeset_file: changesets/minimal.yaml |
| 255 | + validate_before_execute: false |
| 256 | + wait_for_completion: false |
| 257 | + continue-on-error: true |
| 258 | + |
| 259 | + - name: Test with timeout configuration |
| 260 | + id: timeout-config |
| 261 | + uses: ./ |
| 262 | + with: |
| 263 | + api_key: test-key-456 |
| 264 | + base_url: https://test.inprod.io |
| 265 | + changeset_file: changesets/timeout-test.yaml |
| 266 | + validate_before_execute: false |
| 267 | + wait_for_completion: false |
| 268 | + polling_timeout_minutes: 30 |
| 269 | + continue-on-error: true |
| 270 | + |
| 271 | + - name: Display test results |
| 272 | + run: | |
| 273 | + echo "Minimal inputs test completed" |
| 274 | + echo "Timeout configuration test completed" |
| 275 | +
|
| 276 | + test-error-handling: |
| 277 | + name: Test Error Handling |
| 278 | + runs-on: ubuntu-latest |
| 279 | + steps: |
| 280 | + - uses: actions/checkout@v4 |
| 281 | + |
| 282 | + - name: Test missing changeset file input (should fail) |
| 283 | + id: missing-input |
| 284 | + uses: ./ |
| 285 | + with: |
| 286 | + api_key: test-key |
| 287 | + base_url: https://test.inprod.io |
| 288 | + continue-on-error: true |
| 289 | + |
| 290 | + - name: Verify error was caught |
| 291 | + if: steps.missing-input.outcome == 'failure' |
| 292 | + run: | |
| 293 | + echo "✓ Error handling works - missing input caught as expected" |
| 294 | +
|
| 295 | + - name: Create test changeset for URL validation |
| 296 | + run: | |
| 297 | + mkdir -p changesets |
| 298 | + cat > changesets/url-test.yaml << 'EOF' |
| 299 | + name: Test |
| 300 | + action: [] |
| 301 | + EOF |
| 302 | +
|
| 303 | + - name: Test invalid URL format |
| 304 | + id: invalid-url |
| 305 | + uses: ./ |
| 306 | + with: |
| 307 | + api_key: test-key |
| 308 | + base_url: 'not-a-valid-url' |
| 309 | + changeset_file: changesets/url-test.yaml |
| 310 | + continue-on-error: true |
| 311 | + |
| 312 | + - name: Verify URL validation |
| 313 | + run: | |
| 314 | + if [ "${{ steps.invalid-url.outcome }}" == "failure" ]; then |
| 315 | + echo "✓ URL validation works - invalid URL caught as expected" |
| 316 | + else |
| 317 | + echo "✗ URL validation failed" |
| 318 | + exit 1 |
| 319 | + fi |
| 320 | +
|
| 321 | + - name: Test missing changeset file |
| 322 | + id: missing-file |
| 323 | + uses: ./ |
| 324 | + with: |
| 325 | + api_key: test-key |
| 326 | + base_url: https://test.inprod.io |
| 327 | + changeset_file: nonexistent/file.yaml |
| 328 | + continue-on-error: true |
| 329 | + |
| 330 | + - name: Verify file not found error |
| 331 | + run: | |
| 332 | + if [ "${{ steps.missing-file.outcome }}" == "failure" ]; then |
| 333 | + echo "✓ File not found error works as expected" |
| 334 | + else |
| 335 | + echo "✗ File not found error not caught" |
| 336 | + exit 1 |
| 337 | + fi |
0 commit comments