11# Workflow name
2- name : Build sagemaker-code-editor and Generate Artifact
2+ name : Build
33
4-
5-
6- # This workflow is triggered on pushes and pull requests.
4+ # This workflow is triggered on pushes and pull requests to the main branch.
75on :
86 push :
9- branches :
10- - ' ** '
7+ # branches:
8+ # - main
119 pull_request :
12- branches :
13- - ' ** '
10+ # branches:
11+ # - main
1412
1513# Concurrency settings to cancel in-progress runs for the same PR or branch
1614# This prevents wasting resources on outdated commits.
@@ -19,10 +17,42 @@ concurrency:
1917 cancel-in-progress : ${{ github.event_name == 'pull_request' }}
2018
2119jobs :
20+ # Run unit tests before building the application
21+
22+ run-unit-tests :
23+ name : Run unit tests
24+ runs-on : ubuntu-latest
25+ steps :
26+ # Checkout repository code
27+ - name : Checkout code
28+ uses : actions/checkout@v4
29+
30+ # Verify CSP line exists in target TypeScript file
31+ - name : Check CSP configuration in webClientServer.ts
32+ run : |
33+ TARGET_FILE="patched-vscode/src/vs/server/node/webClientServer.ts"
34+ 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;'"
35+
36+ if [ ! -f "$TARGET_FILE" ]; then
37+ echo "❌ FAIL: Target file $TARGET_FILE does not exist."
38+ exit 1
39+ fi
40+
41+ if grep -F "$REQUIRED_TEXT" "$TARGET_FILE" > /dev/null; then
42+ echo "✅ PASS: Required CSP text exists."
43+ else
44+ echo "❌ FAIL: Required CSP text NOT found in $TARGET_FILE"
45+ exit 1
46+ fi
47+
48+
49+
2250 # The main job for building the application
2351 build :
2452 name : Build sagemaker-code-editor
2553 runs-on : ubuntu-latest
54+ # Ensure unit tests pass before building
55+ needs : run-unit-tests
2656 timeout-minutes : 180
2757 env :
2858 # Environment variable to optimize the build process
@@ -40,15 +70,15 @@ jobs:
4070 run : |
4171 sudo apt-get update
4272 sudo apt-get install -y make gcc g++ libx11-dev xorg-dev libxkbfile-dev libsecret-1-dev libkrb5-dev python3 jq perl gettext automake autoconf quilt
73+
4374 # Step 3: Set up the Node.js environment. Version 20 is specified.
4475 - name : Set up Node.js
4576 uses : actions/setup-node@v4
4677 with :
4778 node-version : 20
4879
49- # Step 4: Cache Node.js modules to speed up subsequent builds.
50- # The cache is invalidated if the lock file changes.
51- - name : Cache node modules
80+ # Step 4: Cache Yarn dependencies to speed up subsequent builds.
81+ - name : Cache Yarn dependencies
5282 uses : actions/cache@v4
5383 with :
5484 path : |
6191 if [ -d patches ] && [ "$(ls -A patches)" ]; then
6292 quilt push -a || true
6393 fi
94+
6495 # Step 6: Generate a version string for this specific build.
6596 # It's based on the commit SHA to create a unique identifier.
6697 - name : Set Development Version
70101 VERSION="0.0.0-dev-${SHORT_SHA}"
71102 echo "VERSION=$VERSION" >> $GITHUB_ENV
72103 echo "Generated version for this build: $VERSION"
104+
73105 # Step 7: The main build process for vscode.
74106 - name : Build vscode
75107 run : |
@@ -78,14 +110,23 @@ jobs:
78110 export UV_THREADPOOL_SIZE=4
79111 npm i -g node-gyp
80112 yarn install --network-concurrency 1
113+
114+ # Remove and re-add ripgrep
81115 VSCODE_RIPGREP_VERSION=$(jq -r '.dependencies."@vscode/ripgrep"' package.json)
82116 mv package.json package.json.orig
83117 jq 'del(.dependencies."@vscode/ripgrep")' package.json.orig > package.json
118+
119+ # Re-run install to remove ripgrep
84120 yarn install
121+
122+ # Add ripgrep back
85123 yarn add --ignore-scripts "@vscode/ripgrep@${VSCODE_RIPGREP_VERSION}"
124+
86125 ARCH_ALIAS=linux-x64
126+ # Run the gulp build task
87127 yarn gulp vscode-reh-web-${ARCH_ALIAS}-min
88- # Step 8: Find the exact path of the build output directory.
128+
129+ # Step 8: Find the exact path of the original build output directory.
89130 - name : Find build output
90131 id : find_output
91132 run : |
@@ -96,19 +137,43 @@ jobs:
96137 fi
97138 echo "Build output found at: $BUILD_PATH"
98139 echo "build_path=$BUILD_PATH" >> $GITHUB_OUTPUT
99- # Step 9: Create a compressed tarball of the build output.
140+
141+ # Step 9: Rename the build output directory to sagemaker-code-editor
142+ - name : Rename build output directory
143+ id : rename_output
144+ run : |
145+ ORIG_PATH="${{ steps.find_output.outputs.build_path }}"
146+ PARENT_DIR=$(dirname "$ORIG_PATH")
147+ mv "$ORIG_PATH" "$PARENT_DIR/sagemaker-code-editor"
148+ echo "Renamed build output directory to: $PARENT_DIR/sagemaker-code-editor"
149+ echo "build_path=$PARENT_DIR/sagemaker-code-editor" >> $GITHUB_OUTPUT
150+
151+ # Step 10: Create a compressed tarball of the renamed build output.
100152 - name : Create tarball archive
101153 run : |
102- TARBALL="vscode-reh-web-linux-x64 -${{ env.VERSION }}.tar.gz"
103- BUILD_DIR_PATH="${{ steps.find_output .outputs.build_path }}"
154+ TARBALL="sagemaker-code-editor -${{ env.VERSION }}.tar.gz"
155+ BUILD_DIR_PATH="${{ steps.rename_output .outputs.build_path }}"
104156 PARENT_DIR=$(dirname "$BUILD_DIR_PATH")
105157 BUILD_DIR_NAME=$(basename "$BUILD_DIR_PATH")
106158 echo "Creating '$TARBALL' from '$BUILD_DIR_NAME' in '$PARENT_DIR'"
107159 tar czf $TARBALL -C "$PARENT_DIR" "$BUILD_DIR_NAME"
108- # Step 10: Upload the tarball as a build artifact.
109- # This allows you to download the result from the workflow run summary page .
160+
161+ # Step 11: Upload the tarball as a build artifact .
110162 - name : Upload build artifact
111163 uses : actions/upload-artifact@v4
112164 with :
113- name : vscode-reh-web-linux-x64-${{ env.VERSION }}
114- path : vscode-reh-web-linux-x64-${{ env.VERSION }}.tar.gz
165+ name : yarn-package
166+ path : sagemaker-code-editor-${{ env.VERSION }}.tar.gz
167+ # Run end-to-end tests after the build is complete
168+ run-e2e-tests :
169+ name : Run e2e tests
170+ runs-on : ubuntu-latest
171+ needs : build # Ensure e2e tests run after build
172+ steps :
173+ # Checkout repository code
174+ - name : Checkout code
175+ uses : actions/checkout@v4
176+
177+ # Output placeholder message for e2e tests
178+ - name : Test of e2e test
179+ run : echo "Test of e2e test"
0 commit comments