Skip to content

Commit 36f96be

Browse files
authored
Separate PR check workflows (#5399)
* Update PR check workflow file Update workflow file as Github default branch controls all the workflows in other branchs now * Separate PR check workflow file * remove old pr check file
1 parent 5b203d4 commit 36f96be

File tree

2 files changed

+108
-67
lines changed

2 files changed

+108
-67
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Sagemaker PR Checks (Master-v2)
2+
on:
3+
pull_request_target:
4+
branches:
5+
- "master-v2"
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.head_ref }}
9+
cancel-in-progress: true
10+
11+
permissions:
12+
id-token: write
13+
14+
jobs:
15+
collab-check:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
approval-env: ${{ steps.collab-check.outputs.result }}
19+
steps:
20+
- name: Collaborator Check
21+
uses: actions/github-script@v7
22+
id: collab-check
23+
with:
24+
github-token: ${{ secrets.COLLAB_CHECK_TOKEN }}
25+
result-encoding: string
26+
script: |
27+
try {
28+
const res = await github.rest.repos.checkCollaborator({
29+
owner: context.repo.owner,
30+
repo: context.repo.repo,
31+
username: "${{ github.event.pull_request.user.login }}",
32+
});
33+
console.log("Verifed ${{ github.event.pull_request.user.login }} is a repo collaborator. Auto Approving PR Checks.")
34+
return res.status == "204" ? "auto-approve" : "manual-approval"
35+
} catch (error) {
36+
console.log("${{ github.event.pull_request.user.login }} is not a collaborator. Requiring Manual Approval to run PR Checks.")
37+
return "manual-approval"
38+
}
39+
wait-for-approval:
40+
runs-on: ubuntu-latest
41+
needs: [collab-check]
42+
environment: ${{ needs.collab-check.outputs.approval-env }}
43+
steps:
44+
- run: echo "Workflow Approved! Starting PR Checks."
45+
codestyle-doc-tests:
46+
runs-on: ubuntu-latest
47+
needs: [wait-for-approval]
48+
steps:
49+
- name: Configure AWS Credentials
50+
uses: aws-actions/configure-aws-credentials@v4
51+
with:
52+
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
53+
aws-region: us-west-2
54+
role-duration-seconds: 10800
55+
- name: Run Codestyle & Doc Tests
56+
uses: aws-actions/aws-codebuild-run-build@v1
57+
with:
58+
project-name: ${{ github.event.repository.name }}-ci-codestyle-doc-tests
59+
source-version-override: 'refs/pull/${{ github.event.pull_request.number }}/head^{${{ github.event.pull_request.head.sha }}}'
60+
unit-tests:
61+
runs-on: ubuntu-latest
62+
needs: [wait-for-approval]
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
python-version: ["py39","py310","py311","py312"]
67+
steps:
68+
- name: Configure AWS Credentials
69+
uses: aws-actions/configure-aws-credentials@v4
70+
with:
71+
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
72+
aws-region: us-west-2
73+
role-duration-seconds: 10800
74+
- name: Run Unit Tests
75+
uses: aws-actions/aws-codebuild-run-build@v1
76+
with:
77+
project-name: ${{ github.event.repository.name }}-ci-unit-tests
78+
source-version-override: 'refs/pull/${{ github.event.pull_request.number }}/head^{${{ github.event.pull_request.head.sha }}}'
79+
env-vars-for-codebuild: |
80+
PY_VERSION
81+
env:
82+
PY_VERSION: ${{ matrix.python-version }}
83+
integ-tests:
84+
runs-on: ubuntu-latest
85+
needs: [wait-for-approval]
86+
steps:
87+
- name: Configure AWS Credentials
88+
uses: aws-actions/configure-aws-credentials@v4
89+
with:
90+
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
91+
aws-region: us-west-2
92+
role-duration-seconds: 10800
93+
- name: Run Integ Tests
94+
uses: aws-actions/aws-codebuild-run-build@v1
95+
with:
96+
project-name: ${{ github.event.repository.name }}-ci-integ-tests
97+
source-version-override: 'refs/pull/${{ github.event.pull_request.number }}/head^{${{ github.event.pull_request.head.sha }}}'
Lines changed: 11 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
name: Sagemaker PR Checks
1+
name: Sagemaker PR Checks (Master)
22
on:
33
pull_request_target:
44
branches:
5-
- "master*"
5+
- "master"
6+
paths:
7+
- 'sagemaker-train/**'
8+
- 'sagemaker-serve/**'
9+
- 'sagemaker-mlops/**'
10+
- 'sagemaker-core/**'
611

712
concurrency:
813
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.head_ref }}
@@ -45,26 +50,24 @@ jobs:
4550
detect-changes:
4651
runs-on: ubuntu-latest
4752
needs: [wait-for-approval]
48-
if: github.event.pull_request.base.ref != 'master-v2'
4953
outputs:
5054
submodules: ${{ steps.check-changes.outputs.submodules }}
5155
steps:
5256
- uses: actions/checkout@v3
5357
with:
5458
fetch-depth: 0
55-
token: ${{ secrets.GH_PAT }} # or use appropriate token
56-
ref: ${{ github.event.pull_request.base.ref }} # Target branch (master-v3)
59+
token: ${{ secrets.GH_PAT }}
60+
ref: ${{ github.event.pull_request.base.ref }}
5761
- name: Detect Changes
5862
id: check-changes
5963
run: |
60-
set -e # Exit on error
64+
set -e
6165
62-
# Debug information
6366
echo "Target Branch: ${{ github.event.pull_request.base.ref }}"
6467
echo "Current Target SHA: $(git rev-parse HEAD)"
6568
echo "PR Number: ${{ github.event.pull_request.number }}"
6669
echo "PR Latest SHA: ${{ github.event.pull_request.head.sha }}"
67-
# Fetch PR without creating a branch
70+
6871
git fetch origin pull/${{ github.event.pull_request.number }}/head
6972
CHANGES=$(git diff --name-only HEAD FETCH_HEAD)
7073
@@ -122,23 +125,6 @@ jobs:
122125
project-name: ${{ github.event.repository.name }}-ci-${{ matrix.submodule }}-codestyle-doc-tests
123126
source-version-override: 'refs/pull/${{ github.event.pull_request.number }}/head^{${{ github.event.pull_request.head.sha }}}'
124127

125-
codestyle-doc-tests-v2:
126-
runs-on: ubuntu-latest
127-
needs: [wait-for-approval]
128-
if: github.event.pull_request.base.ref == 'master-v2'
129-
steps:
130-
- name: Configure AWS Credentials
131-
uses: aws-actions/configure-aws-credentials@v4
132-
with:
133-
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
134-
aws-region: us-west-2
135-
role-duration-seconds: 10800
136-
- name: Run Codestyle & Doc Tests
137-
uses: aws-actions/aws-codebuild-run-build@v1
138-
with:
139-
project-name: ${{ github.event.repository.name }}-ci-codestyle-doc-tests
140-
source-version-override: 'refs/pull/${{ github.event.pull_request.number }}/head^{${{ github.event.pull_request.head.sha }}}'
141-
142128
unit-tests:
143129
runs-on: ubuntu-latest
144130
needs: [detect-changes]
@@ -161,31 +147,6 @@ jobs:
161147
project-name: ${{ github.event.repository.name }}-ci-${{ matrix.submodule }}-unit-tests
162148
source-version-override: 'refs/pull/${{ github.event.pull_request.number }}/head^{${{ github.event.pull_request.head.sha }}}'
163149

164-
unit-tests-v2:
165-
runs-on: ubuntu-latest
166-
needs: [wait-for-approval]
167-
if: github.event.pull_request.base.ref == 'master-v2'
168-
strategy:
169-
fail-fast: false
170-
matrix:
171-
python-version: ["py39","py310","py311","py312"]
172-
steps:
173-
- name: Configure AWS Credentials
174-
uses: aws-actions/configure-aws-credentials@v4
175-
with:
176-
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
177-
aws-region: us-west-2
178-
role-duration-seconds: 10800
179-
- name: Run Unit Tests
180-
uses: aws-actions/aws-codebuild-run-build@v1
181-
with:
182-
project-name: ${{ github.event.repository.name }}-ci-unit-tests
183-
source-version-override: 'refs/pull/${{ github.event.pull_request.number }}/head^{${{ github.event.pull_request.head.sha }}}'
184-
env-vars-for-codebuild: |
185-
PY_VERSION
186-
env:
187-
PY_VERSION: ${{ matrix.python-version }}
188-
189150
integ-tests:
190151
runs-on: ubuntu-latest
191152
needs: [detect-changes]
@@ -207,20 +168,3 @@ jobs:
207168
with:
208169
project-name: ${{ github.event.repository.name }}-ci-${{ matrix.submodule }}-integ-tests
209170
source-version-override: 'refs/pull/${{ github.event.pull_request.number }}/head^{${{ github.event.pull_request.head.sha }}}'
210-
211-
integ-tests-v2:
212-
runs-on: ubuntu-latest
213-
needs: [wait-for-approval]
214-
if: github.event.pull_request.base.ref == 'master-v2'
215-
steps:
216-
- name: Configure AWS Credentials
217-
uses: aws-actions/configure-aws-credentials@v4
218-
with:
219-
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
220-
aws-region: us-west-2
221-
role-duration-seconds: 10800
222-
- name: Run Integ Tests
223-
uses: aws-actions/aws-codebuild-run-build@v1
224-
with:
225-
project-name: ${{ github.event.repository.name }}-ci-integ-tests
226-
source-version-override: 'refs/pull/${{ github.event.pull_request.number }}/head^{${{ github.event.pull_request.head.sha }}}'

0 commit comments

Comments
 (0)