|
| 1 | +name: "Pipeline - Scikit-learn" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + config-file: |
| 7 | + description: "Path to image config YAML" |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + tag-suffix: |
| 11 | + description: "CI tag suffix (run_id or pr-NUMBER)" |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + build: |
| 15 | + description: "Whether to build the image (false = skip build, test against prod)" |
| 16 | + required: false |
| 17 | + type: boolean |
| 18 | + default: true |
| 19 | + run-sanity-test: |
| 20 | + description: "Run sanity tests" |
| 21 | + required: false |
| 22 | + type: boolean |
| 23 | + default: true |
| 24 | + run-security-test: |
| 25 | + description: "Run security tests" |
| 26 | + required: false |
| 27 | + type: boolean |
| 28 | + default: true |
| 29 | + run-telemetry-test: |
| 30 | + description: "Run telemetry tests" |
| 31 | + required: false |
| 32 | + type: boolean |
| 33 | + default: true |
| 34 | + run-unit-test: |
| 35 | + description: "Run unit tests (clones sagemaker-scikit-learn-container)" |
| 36 | + required: false |
| 37 | + type: boolean |
| 38 | + default: true |
| 39 | + run-integ-test: |
| 40 | + description: "Run integration tests (local Docker)" |
| 41 | + required: false |
| 42 | + type: boolean |
| 43 | + default: true |
| 44 | + release: |
| 45 | + description: "Run release job after tests pass" |
| 46 | + required: false |
| 47 | + type: boolean |
| 48 | + default: false |
| 49 | + outputs: |
| 50 | + image-uri: |
| 51 | + description: "Built image URI (empty if build was skipped)" |
| 52 | + value: ${{ jobs.build.outputs.image-uri }} |
| 53 | + |
| 54 | +jobs: |
| 55 | + build: |
| 56 | + if: ${{ inputs.build }} |
| 57 | + concurrency: |
| 58 | + group: ${{ github.workflow }}-build-${{ inputs.config-file }}-${{ github.ref }} |
| 59 | + cancel-in-progress: true |
| 60 | + runs-on: |
| 61 | + - codebuild-runner-${{ github.run_id }}-${{ github.run_attempt }} |
| 62 | + fleet:x86-build-runner |
| 63 | + buildspec-override:true |
| 64 | + timeout-minutes: 60 |
| 65 | + outputs: |
| 66 | + image-uri: ${{ steps.build.outputs.image-uri }} |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v6 |
| 69 | + - id: build |
| 70 | + uses: ./.github/actions/build-image |
| 71 | + with: |
| 72 | + config-file: ${{ inputs.config-file }} |
| 73 | + aws-account-id: ${{ vars.CI_AWS_ACCOUNT_ID }} |
| 74 | + aws-region: ${{ vars.AWS_REGION }} |
| 75 | + tag-suffix: ${{ inputs.tag-suffix }} |
| 76 | + |
| 77 | + sanity-test: |
| 78 | + if: ${{ always() && !failure() && !cancelled() && inputs.run-sanity-test }} |
| 79 | + needs: [build] |
| 80 | + concurrency: |
| 81 | + group: ${{ github.workflow }}-sanity-test-${{ inputs.config-file }}-${{ github.ref }} |
| 82 | + cancel-in-progress: true |
| 83 | + uses: ./.github/workflows/_reusable.sanity-tests.yml |
| 84 | + with: |
| 85 | + config-file: ${{ inputs.config-file }} |
| 86 | + image-uri: ${{ needs.build.outputs.image-uri || '' }} |
| 87 | + |
| 88 | + security-test: |
| 89 | + if: ${{ always() && !failure() && !cancelled() && inputs.run-security-test }} |
| 90 | + needs: [build] |
| 91 | + concurrency: |
| 92 | + group: ${{ github.workflow }}-security-test-${{ inputs.config-file }}-${{ github.ref }} |
| 93 | + cancel-in-progress: true |
| 94 | + uses: ./.github/workflows/_reusable.security-tests.yml |
| 95 | + with: |
| 96 | + config-file: ${{ inputs.config-file }} |
| 97 | + image-uri: ${{ needs.build.outputs.image-uri || '' }} |
| 98 | + |
| 99 | + # TODO: Re-enable telemetry tests after sklearn telemetry setup is verified |
| 100 | + # telemetry-test: |
| 101 | + # if: ${{ always() && !failure() && !cancelled() && inputs.run-telemetry-test }} |
| 102 | + # needs: [build] |
| 103 | + # concurrency: |
| 104 | + # group: ${{ github.workflow }}-telemetry-test-${{ inputs.config-file }}-${{ github.ref }} |
| 105 | + # cancel-in-progress: false |
| 106 | + # uses: ./.github/workflows/_reusable.telemetry-tests.yml |
| 107 | + # with: |
| 108 | + # config-file: ${{ inputs.config-file }} |
| 109 | + # image-uri: ${{ needs.build.outputs.image-uri || '' }} |
| 110 | + |
| 111 | + unit-test: |
| 112 | + if: ${{ always() && !failure() && !cancelled() && inputs.run-unit-test }} |
| 113 | + needs: [build] |
| 114 | + concurrency: |
| 115 | + group: ${{ github.workflow }}-unit-test-${{ inputs.config-file }}-${{ github.ref }} |
| 116 | + cancel-in-progress: true |
| 117 | + uses: ./.github/workflows/sklearn.tests-unit.yml |
| 118 | + with: |
| 119 | + config-file: ${{ inputs.config-file }} |
| 120 | + image-uri: ${{ needs.build.outputs.image-uri || '' }} |
| 121 | + |
| 122 | + # Local integration tests — lightweight, runs on PRs (local Docker compose) |
| 123 | + integ-test: |
| 124 | + if: ${{ always() && !failure() && !cancelled() && inputs.run-integ-test }} |
| 125 | + needs: [build] |
| 126 | + concurrency: |
| 127 | + group: ${{ github.workflow }}-integ-test-${{ inputs.config-file }}-${{ github.ref }} |
| 128 | + cancel-in-progress: true |
| 129 | + uses: ./.github/workflows/sklearn.tests-integ-local.yml |
| 130 | + with: |
| 131 | + config-file: ${{ inputs.config-file }} |
| 132 | + image-uri: ${{ needs.build.outputs.image-uri || '' }} |
| 133 | + |
| 134 | + release-gate: |
| 135 | + if: >- |
| 136 | + github.ref == 'refs/heads/main' && |
| 137 | + (contains(github.workflow_ref, '.autorelease') || contains(github.workflow_ref, '.dispatch-release')) && |
| 138 | + !contains(github.workflow_ref, '.pr') && |
| 139 | + inputs.release && |
| 140 | + !failure() && !cancelled() && |
| 141 | + needs.build.result == 'success' |
| 142 | + needs: [build, sanity-test, security-test, unit-test, integ-test] |
| 143 | + runs-on: ubuntu-latest |
| 144 | + outputs: |
| 145 | + environment: ${{ steps.check.outputs.environment }} |
| 146 | + release-spec: ${{ steps.spec.outputs.release-spec }} |
| 147 | + should-release: ${{ steps.check.outputs.should-release }} |
| 148 | + steps: |
| 149 | + - uses: actions/checkout@v6 |
| 150 | + - id: check |
| 151 | + run: | |
| 152 | + SHOULD_RELEASE=$(yq '.release.release' "${{ inputs.config-file }}") |
| 153 | + ENVIRONMENT=$(yq '.release.environment' "${{ inputs.config-file }}") |
| 154 | + echo "should-release=${SHOULD_RELEASE}" >> $GITHUB_OUTPUT |
| 155 | + echo "environment=${ENVIRONMENT}" >> $GITHUB_OUTPUT |
| 156 | + - id: spec |
| 157 | + if: steps.check.outputs.should-release == 'true' |
| 158 | + uses: ./.github/actions/generate-release-spec |
| 159 | + with: |
| 160 | + config-file: ${{ inputs.config-file }} |
| 161 | + |
| 162 | + release: |
| 163 | + if: ${{ !failure() && !cancelled() && needs.release-gate.outputs.should-release == 'true' }} |
| 164 | + needs: [build, release-gate] |
| 165 | + uses: ./.github/workflows/_reusable.release-image.yml |
| 166 | + with: |
| 167 | + source-image-uri: ${{ needs.build.outputs.image-uri }} |
| 168 | + release-spec: ${{ needs.release-gate.outputs.release-spec }} |
| 169 | + environment: ${{ needs.release-gate.outputs.environment }} |
| 170 | + aws-region: ${{ vars.AWS_REGION }} |
| 171 | + secrets: inherit |
0 commit comments