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,28 +70,24 @@ 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
79+ # Use npm for caching, not yarn
80+ cache : ' npm'
81+ cache-dependency-path : ' **/package-lock.json'
4882
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
52- uses : actions/cache@v4
53- with :
54- path : |
55- vscode/node_modules
56- key : ${{ runner.os }}-node20-${{ hashFiles('vscode/package.json', 'vscode/yarn.lock') }}
57-
58- # Step 5: Apply patches from the 'patches' directory if it exists.
83+ # Step 4: Apply patches from the 'patches' directory if it exists.
5984 - name : Apply patches (if any)
6085 run : |
6186 if [ -d patches ] && [ "$(ls -A patches)" ]; then
6287 quilt push -a || true
6388 fi
64- # Step 6: Generate a version string for this specific build.
89+
90+ # Step 5: Generate a version string for this specific build.
6591 # It's based on the commit SHA to create a unique identifier.
6692 - name : Set Development Version
6793 id : version
@@ -70,22 +96,33 @@ jobs:
7096 VERSION="0.0.0-dev-${SHORT_SHA}"
7197 echo "VERSION=$VERSION" >> $GITHUB_ENV
7298 echo "Generated version for this build: $VERSION"
73- # Step 7: The main build process for vscode.
99+
100+ # Step 6: The main build process for vscode, now using npm.
74101 - name : Build vscode
75102 run : |
76103 cd vscode
77104 export DISABLE_V8_COMPILE_CACHE=1
78105 export UV_THREADPOOL_SIZE=4
79- npm i -g node-gyp
80- yarn install --network-concurrency 1
106+
107+ # Install dependencies using npm
108+ npm install
109+
110+ # The logic for temporarily removing and re-adding ripgrep remains
81111 VSCODE_RIPGREP_VERSION=$(jq -r '.dependencies."@vscode/ripgrep"' package.json)
82112 mv package.json package.json.orig
83113 jq 'del(.dependencies."@vscode/ripgrep")' package.json.orig > package.json
84- yarn install
85- yarn add --ignore-scripts "@vscode/ripgrep@${VSCODE_RIPGREP_VERSION}"
114+
115+ # Re-run install to remove ripgrep
116+ npm install
117+
118+ # Add ripgrep back using npm
119+ npm install --ignore-scripts "@vscode/ripgrep@${VSCODE_RIPGREP_VERSION}"
120+
86121 ARCH_ALIAS=linux-x64
87- yarn gulp vscode-reh-web-${ARCH_ALIAS}-min
88- # Step 8: Find the exact path of the build output directory.
122+ # Run the gulp build task using npx
123+ npx gulp vscode-reh-web-${ARCH_ALIAS}-min
124+
125+ # Step 7: Find the exact path of the original build output directory.
89126 - name : Find build output
90127 id : find_output
91128 run : |
@@ -96,19 +133,43 @@ jobs:
96133 fi
97134 echo "Build output found at: $BUILD_PATH"
98135 echo "build_path=$BUILD_PATH" >> $GITHUB_OUTPUT
99- # Step 9: Create a compressed tarball of the build output.
136+
137+ # Step 8: Rename the build output directory to sagemaker-code-editor
138+ - name : Rename build output directory
139+ id : rename_output
140+ run : |
141+ ORIG_PATH="${{ steps.find_output.outputs.build_path }}"
142+ PARENT_DIR=$(dirname "$ORIG_PATH")
143+ mv "$ORIG_PATH" "$PARENT_DIR/sagemaker-code-editor"
144+ echo "Renamed build output directory to: $PARENT_DIR/sagemaker-code-editor"
145+ echo "build_path=$PARENT_DIR/sagemaker-code-editor" >> $GITHUB_OUTPUT
146+
147+ # Step 9: Create a compressed tarball of the renamed build output.
100148 - name : Create tarball archive
101149 run : |
102- TARBALL="vscode-reh-web-linux-x64 -${{ env.VERSION }}.tar.gz"
103- BUILD_DIR_PATH="${{ steps.find_output .outputs.build_path }}"
150+ TARBALL="sagemaker-code-editor -${{ env.VERSION }}.tar.gz"
151+ BUILD_DIR_PATH="${{ steps.rename_output .outputs.build_path }}"
104152 PARENT_DIR=$(dirname "$BUILD_DIR_PATH")
105153 BUILD_DIR_NAME=$(basename "$BUILD_DIR_PATH")
106154 echo "Creating '$TARBALL' from '$BUILD_DIR_NAME' in '$PARENT_DIR'"
107155 tar czf $TARBALL -C "$PARENT_DIR" "$BUILD_DIR_NAME"
156+
108157 # Step 10: Upload the tarball as a build artifact.
109- # This allows you to download the result from the workflow run summary page.
110158 - name : Upload build artifact
111159 uses : actions/upload-artifact@v4
112160 with :
113- name : vscode-reh-web-linux-x64-${{ env.VERSION }}
114- path : vscode-reh-web-linux-x64-${{ env.VERSION }}.tar.gz
161+ name : npm-package
162+ path : sagemaker-code-editor-${{ env.VERSION }}.tar.gz
163+ # Run end-to-end tests after the build is complete
164+ run-e2e-tests :
165+ name : Run e2e tests
166+ runs-on : ubuntu-latest
167+ needs : build # Ensure e2e tests run after build
168+ steps :
169+ # Checkout repository code
170+ - name : Checkout code
171+ uses : actions/checkout@v4
172+
173+ # Output placeholder message for e2e tests
174+ - name : Test of e2e test
175+ run : echo "Test of e2e test"
0 commit comments