| name: Merge Queue | |
| on: | |
| pull_request: | |
| types: [labeled, unlabeled, synchronize, reopened, ready_for_review] | |
| push: | |
| branches: [main] | |
| jobs: | |
| merge-queue: | |
| runs-on: ubuntu-latest | |
| if: github.event.pull_request.draft == false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| sparse-checkout: | | |
| deployment/ | |
| platform/ | |
| systemd/ | |
| .github/ | |
| - name: Determine PR class | |
| id: classify | |
| run: | | |
| # Class A: High risk changes | |
| if [[ -n "$(git diff --name-only origin/main...HEAD | grep -E '(deployment/environments/|systemd/|platform/.*/dto/)')" ]]; then | |
| echo "class=a" >> $GITHUB_OUTPUT | |
| # Class B: Medium risk changes | |
| elif [[ -n "$(git diff --name-only origin/main...HEAD | grep -E '(platform/.*/scripts/|platform/.*/configs/)')" ]]; then | |
| echo "class=b" >> $GITHUB_OUTPUT | |
| # Class C: Low risk changes | |
| else | |
| echo "class=c" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Run DTO schema validation | |
| if: steps.classify.outputs.class != 'c' | |
| run: | | |
| python3 /data/adaptai/deployment/generators/validate_dto.py | |
| - name: Check generator freshness | |
| if: steps.classify.outputs.class != 'c' | |
| run: | | |
| python3 /data/adaptai/deployment/generators/check_freshness.py | |
| - name: Run port collision scan | |
| if: steps.classify.outputs.class != 'c' | |
| run: | | |
| python3 /data/adaptai/deployment/generators/scan_ports.py | |
| - name: Check runbook presence | |
| if: steps.classify.outputs.class != 'c' | |
| run: | | |
| python3 /data/adaptai/deployment/generators/check_runbooks.py | |
| - name: Validate systemd/supervisor syntax | |
| if: steps.classify.outputs.class != 'c' | |
| run: | | |
| python3 /data/adaptai/deployment/generators/validate_units.py | |
| - name: Queue management | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| # Add to appropriate queue based on class | |
| python3 /data/adaptai/.github/scripts/queue_manager.py \ | |
| --pr ${{ github.event.pull_request.number }} \ | |
| --class ${{ steps.classify.outputs.class }} \ | |
| --action add | |
| - name: Process Class A queue (serial) | |
| if: steps.classify.outputs.class == 'a' | |
| run: | | |
| python3 /data/adaptai/.github/scripts/process_queue.py --class a --batch-size 1 | |
| - name: Process Class B queue (batched) | |
| if: steps.classify.outputs.class == 'b' | |
| run: | | |
| python3 /data/adaptai/.github/scripts/process_queue.py --class b --batch-size 3 | |
| - name: Process Class C queue (batched) | |
| if: steps.classify.outputs.class == 'c' | |
| run: | | |
| python3 /data/adaptai/.github/scripts/process_queue.py --class c --batch-size 5 | |
| - name: Check for pause-needed label | |
| if: contains(github.event.pull_request.labels.*.name, 'pause-needed') | |
| run: | | |
| echo "PR has pause-needed label - blocking merge" | |
| exit 1 | |
| - name: Verify CODEOWNERS approval | |
| run: | | |
| python3 /data/adaptai/.github/scripts/verify_codeowners.py |