FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Finish setup for SageMaker E2E testing workflow (#89) · aws/code-editor@ecffd4c · GitHub

Commit ecffd4c

Browse files
authored
Finish setup for SageMaker E2E testing workflow (#89)
1 parent dd3adbc commit ecffd4c

1 file changed

Lines changed: 50 additions & 33 deletions

File tree

‎.github/workflows/smoke-tests-sagemaker.yaml‎

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
smoke-tests-sagemaker:
88
name: Run Smoke Tests for SageMaker
99
runs-on: ubuntu-latest
10-
environment: smoke-tests-sagemaker-workflow-env
10+
environment: sagemaker-e2e-tests-workflow-env
1111
permissions:
1212
id-token: write
1313
contents: read
@@ -19,8 +19,9 @@ jobs:
1919
AWS_REGION: us-east-2
2020
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
2121
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
22-
SAGEMAKER_DOMAIN_NAME: ${{ secrets.SAGEMAKER_DOMAIN_NAME }}
23-
SAGEMAKER_EXECUTION_ROLE_ARN: ${{ secrets.SAGEMAKER_EXECUTION_ROLE_ARN }}
22+
PROJECT_NAME: ${{ secrets.PROJECT_NAME }}
23+
DATAZONE_DOMAIN_ID: ${{ secrets.DATAZONE_DOMAIN_ID }}
24+
TEST_SAGEMAKER_ROLE: ${{ secrets.TEST_SAGEMAKER_ROLE }}
2425
steps:
2526
- name: Checkout code
2627
uses: actions/checkout@v4
@@ -31,7 +32,7 @@ jobs:
3132
run: |
3233
echo "Installing required dependencies"
3334
sudo apt-get update
34-
sudo apt-get install -y quilt jq
35+
sudo apt-get install -y quilt libxml2-utils jq libx11-dev libxkbfile-dev
3536
3637
- name: Setup Node.js
3738
uses: actions/setup-node@v4
@@ -58,10 +59,10 @@ jobs:
5859
fi
5960
done
6061
61-
- name: Configure AWS credentials
62+
- name: Configure ECR role AWS credentials
6263
uses: aws-actions/configure-aws-credentials@v4
6364
with:
64-
role-to-assume: ${{ secrets.SAGEMAKER_EXECUTION_ROLE_ARN }}
65+
role-to-assume: ${{ secrets.TEST_ECR_ROLE }}
6566
aws-region: ${{ env.AWS_REGION }}
6667

6768
- name: Extract artifacts
@@ -102,26 +103,44 @@ jobs:
102103
rm -rf $COMMIT_SHA-$SAGEMAKER_ARTIFACT_PREFIX-build
103104
echo "Local build artifacts cleaned up"
104105
106+
- name: Configure SageMaker role AWS credentials
107+
uses: aws-actions/configure-aws-credentials@v4
108+
with:
109+
role-to-assume: ${{ secrets.TEST_SAGEMAKER_ROLE }}
110+
aws-region: ${{ env.AWS_REGION }}
111+
105112
- name: Create SageMaker code editor image
106113
run: |
107-
# Find SageMaker domain by name
108-
DOMAIN_ID=$(aws sagemaker list-domains --query "Domains[?DomainName=='$SAGEMAKER_DOMAIN_NAME'].DomainId" --output text)
114+
# Fetch DataZone project ID
115+
PROJECT_ID=$(aws datazone list-projects --domain-identifier "$DATAZONE_DOMAIN_ID" --name "$PROJECT_NAME" --query 'items[0].id' --output text)
116+
117+
if [ -z "$PROJECT_ID" ] || [ "$PROJECT_ID" = "None" ]; then
118+
echo "Error: DataZone project not found"
119+
exit 1
120+
fi
121+
122+
echo "DataZone project found successfully"
123+
echo "::add-mask::$PROJECT_ID"
124+
125+
# Find SageMaker domain by project ID (domain name contains project ID)
126+
DOMAIN_ID=$(aws sagemaker list-domains --query "Domains[?contains(DomainName, '$PROJECT_ID')].DomainId" --output text)
109127
110128
if [ -z "$DOMAIN_ID" ]; then
111-
echo "Error: SageMaker domain not found"
129+
echo "Error: SageMaker domain not found for project ID"
112130
exit 1
113131
fi
114132
115133
echo "SageMaker domain found successfully"
116134
echo "::add-mask::$DOMAIN_ID"
117135
echo "SAGEMAKER_DOMAIN_ID=$DOMAIN_ID" >> $GITHUB_ENV
136+
echo "PROJECT_ID=$PROJECT_ID" >> $GITHUB_ENV
118137
119138
# Create SageMaker image
120139
BRANCH_NAME=$(echo "$GH_REF_NAME" | sed 's/[^a-zA-Z0-9-]/-/g')
121140
IMAGE_NAME="$BRANCH_NAME-${COMMIT_SHA}"
122141
aws sagemaker create-image \
123142
--image-name "$IMAGE_NAME" \
124-
--role-arn $SAGEMAKER_EXECUTION_ROLE_ARN
143+
--role-arn $TEST_SAGEMAKER_ROLE
125144
126145
# Wait for image to be ready (max 30 retries = 5 minutes)
127146
echo "Waiting for SageMaker image to be ready..."
@@ -321,18 +340,6 @@ jobs:
321340
exit 1
322341
fi
323342
324-
# Get DataZone domain ID and project information
325-
DATAZONE_DOMAIN_ID=$(aws datazone list-domains --query "items[?name=='$DATAZONE_DOMAIN_NAME'].id" --output text)
326-
echo "::add-mask::$DATAZONE_DOMAIN_ID"
327-
328-
if [ -z "$DATAZONE_DOMAIN_ID" ]; then
329-
echo "Error: DataZone domain not found"
330-
exit 1
331-
fi
332-
333-
# Extract project ID from SageMaker domain name
334-
PROJECT_ID=$(echo "$SAGEMAKER_DOMAIN_NAME" | cut -d'-' -f2)
335-
336343
DATAZONE_URL="https://${DATAZONE_DOMAIN_ID}.sagemaker.us-west-2.on.aws/projects/${PROJECT_ID}/compute?type=spaces"
337344
338345
# Apply E2E testing patches
@@ -353,10 +360,10 @@ jobs:
353360
npx playwright install
354361
SSO_USERNAME="$SSO_USERNAME" SSO_PASSWORD="$SSO_PASSWORD" DATAZONE_URL="$DATAZONE_URL" SPACE_NAME="$SAGEMAKER_SPACE_NAME" VSCODE_REMOTE_SERVER_PATH="sagemaker" npm run mocha -- --web --headless
355362

356-
- name: Cleanup resources
363+
- name: Clean up SageMaker resources
357364
if: always()
358365
run: |
359-
echo "Starting cleanup of resources..."
366+
echo "Starting SageMaker cleanup..."
360367
CLEANUP_FAILED=0
361368
362369
# Delete app first
@@ -406,18 +413,28 @@ jobs:
406413
aws sagemaker delete-image \
407414
--image-name "$SAGEMAKER_IMAGE_NAME" || CLEANUP_FAILED=1
408415
409-
# Delete ECR image
410-
echo "Deleting ECR image..."
416+
if [ $CLEANUP_FAILED -eq 1 ]; then
417+
echo "SageMaker cleanup completed with some failures"
418+
else
419+
echo "SageMaker cleanup completed successfully"
420+
fi
421+
422+
- name: Configure ECR role for cleanup
423+
if: always()
424+
uses: aws-actions/configure-aws-credentials@v4
425+
with:
426+
role-to-assume: ${{ secrets.TEST_ECR_ROLE }}
427+
aws-region: ${{ env.AWS_REGION }}
428+
429+
- name: Clean up ECR resources
430+
if: always()
431+
run: |
432+
echo "Starting ECR cleanup..."
411433
BRANCH_NAME=$(echo "$GH_REF_NAME" | sed 's/[^a-zA-Z0-9-]/-/g')
412434
IMAGE_TAG="$BRANCH_NAME-$COMMIT_SHA"
413435
aws ecr batch-delete-image \
414436
--repository-name "$ECR_REPOSITORY" \
415-
--image-ids imageTag="$IMAGE_TAG" || CLEANUP_FAILED=1
437+
--image-ids imageTag="$IMAGE_TAG" || echo "ECR cleanup failed"
416438
417-
if [ $CLEANUP_FAILED -eq 1 ]; then
418-
echo "Cleanup completed with some failures"
419-
exit 1
420-
else
421-
echo "Cleanup completed successfully"
422-
fi
439+
echo "ECR cleanup completed"
423440

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL