generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 20
162 lines (147 loc) · 6.28 KB
/
build-targets.yaml
File metadata and controls
162 lines (147 loc) · 6.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: Build Code Editor Targets
on:
workflow_dispatch:
jobs:
build:
name: Build Code Editor Targets
runs-on: ubuntu-22.04
strategy:
matrix:
build-target: [code-editor-server, code-editor-sagemaker-server, code-editor-web-embedded, code-editor-web-embedded-with-terminal]
exclude:
# Only build SageMaker for now, remove the excluded targets when needed in the future.
- build-target: code-editor-server
- build-target: code-editor-web-embedded
- build-target: code-editor-web-embedded-with-terminal
steps:
- name: Start Build Workflow
env:
BUILD_TARGET: ${{ matrix.build-target }}
run: |
echo "Starting Build Workflow for target: $BUILD_TARGET"
- name: Setup swap
run: |
# Remove existing swap if present
sudo swapoff -a || true
sudo rm -f /swapfile /mnt/swapfile || true
# Create new swap
sudo fallocate -l 12G /mnt/swapfile
sudo chmod 600 /mnt/swapfile
sudo mkswap /mnt/swapfile
sudo swapon /mnt/swapfile
free -h
- name: Set up build environment
run: |
echo "Installing required dependencies"
sudo apt-get update
sudo apt-get install -y quilt libkrb5-dev libx11-dev libxkbfile-dev libxml2-utils
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Run patches script
env:
BUILD_TARGET: ${{ matrix.build-target }}
run: |
./scripts/prepare-src.sh "$BUILD_TARGET"
# Verify CSP line exists in target TypeScript file
- name: Check CSP configuration in webClientServer.ts
if: matrix.build-target == 'code-editor-sagemaker-server'
run: |
TARGET_FILE="code-editor-src/src/vs/server/node/webClientServer.ts"
REQUIRED_TEXT="connect-src \\'self\\' ws: wss: https://main.vscode-cdn.net http://localhost:* https://localhost:* https://login.microsoftonline.com/ https://update.code.visualstudio.com https://*.vscode-unpkg.net/ https://default.exp-tas.com/vscode/ab https://vscode-sync.trafficmanager.net https://vscode-sync-insiders.trafficmanager.net https://*.gallerycdn.vsassets.io https://marketplace.visualstudio.com https://openvsxorg.blob.core.windows.net https://az764295.vo.msecnd.net https://code.visualstudio.com https://*.gallery.vsassets.io https://*.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com https://*.servicebus.windows.net/ https://vscode.blob.core.windows.net https://vscode.search.windows.net https://vsmarketplacebadges.dev https://vscode.download.prss.microsoft.com https://download.visualstudio.microsoft.com https://*.vscode-unpkg.net https://open-vsx.org;"
if [ ! -f "$TARGET_FILE" ]; then
echo "❌ FAIL: Target file $TARGET_FILE does not exist."
exit 1
fi
if grep -F "$REQUIRED_TEXT" "$TARGET_FILE" > /dev/null; then
echo "✅ PASS: Required CSP text exists."
else
echo "❌ FAIL: Required CSP text NOT found in $TARGET_FILE"
exit 1
fi
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: 'code-editor-src/package-lock.json'
- name: Install code editor dependencies
run: |
cd code-editor-src
echo "Installing dependencies" && npm ci
- name: Build artifacts
env:
BUILD_TARGET: ${{ matrix.build-target }}
run: |
./scripts/build-artifacts.sh "$BUILD_TARGET"
- name: Prepare artifacts to upload
env:
MATRIX_BUILD_TARGET: ${{ matrix.build-target }}
run: |
CODE_EDITOR_BUILD_TARGET=$(./scripts/determine-build-target.sh "$MATRIX_BUILD_TARGET")
tar -czf "${MATRIX_BUILD_TARGET}-src.tar.gz" ./code-editor-src
tar -czf "${MATRIX_BUILD_TARGET}-build.tar.gz" "./$CODE_EDITOR_BUILD_TARGET"
- name: Upload src artifact
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-${{ matrix.build-target }}-src
path: ${{ matrix.build-target }}-src.tar.gz
retention-days: 90
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-${{ matrix.build-target }}-build
path: ${{ matrix.build-target }}-build.tar.gz
retention-days: 90
smoke-tests:
name: Trigger Smoke Tests
runs-on: ubuntu-latest
needs: build
if: success()
permissions:
actions: write
steps:
- name: Trigger SageMaker smoke tests
env:
GH_TOKEN: ${{ github.token }}
run: |
gh workflow run smoke-tests-sagemaker.yaml \
--repo ${{ github.repository }} \
--ref ${{ github.ref }}
handle-failures:
name: Handle Failures
runs-on: ubuntu-latest
needs: build
environment: build-targets-workflow-env
if: failure()
permissions:
id-token: write # Required for OIDC
env:
REPOSITORY: ${{ github.repository }}
AWS_ROLE_TO_ASSUME: ${{ secrets.AWS_ROLE_TO_ASSUME }}
steps:
- name: Check if protected branch
id: check-branch
run: |
if [[ "$GITHUB_REF_NAME" == "main" ]] || [[ "$GITHUB_REF_NAME" =~ ^[0-9]+\.[0-9]+$ ]]; then
echo "is_protected=true" >> $GITHUB_OUTPUT
else
echo "is_protected=false" >> $GITHUB_OUTPUT
fi
- name: Use role credentials for metrics
id: aws-creds
continue-on-error: ${{ env.REPOSITORY != 'aws/code-editor' }}
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_ROLE_TO_ASSUME }}
role-duration-seconds: 900
aws-region: us-east-1
- name: Report failure
if: steps.aws-creds.outcome == 'success' && steps.check-branch.outputs.is_protected == 'true'
run: |
aws cloudwatch put-metric-data \
--namespace "GitHub/Workflows" \
--metric-name "ExecutionsFailed" \
--dimensions "Repository=$REPOSITORY,Workflow=BuildTargets" \
--value 1