diff --git a/.actrc b/.actrc new file mode 100644 index 000000000..3da902c8e --- /dev/null +++ b/.actrc @@ -0,0 +1,2 @@ +-P ubuntu-latest=node:22-bookworm +--container-options=--memory=32g --network=host \ No newline at end of file diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..82b5c4c93 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,17 @@ +# Exclude large directories that aren't needed for build +vscode/node_modules + +# Exclude build artifacts +*.tar.gz +*.log + +# Exclude development files +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# Exclude OS files +.DS_Store +Thumbs.db \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..8a68f4c2d --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +vscode-reh-web-linux-x64/node filter=lfs diff=lfs merge=lfs -text diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c7ecf8d2b..89c92bc5a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,6 +9,7 @@ concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: + # The main job for building the application build: name: Build sagemaker-code-editor runs-on: ubuntu-latest @@ -37,7 +38,13 @@ jobs: - name: Apply patches (if any) run: | if [ -d patches ] && [ "$(ls -A patches)" ]; then - quilt push -a || true + { + quilt push -a --leave-rejects --color=auto + } || { + printf "\nPatching error, review logs!\n" + find ./vscode -name "*.rej" + exit 1 + } fi - name: Set Development Version @@ -53,18 +60,17 @@ jobs: cd vscode export DISABLE_V8_COMPILE_CACHE=1 export UV_THREADPOOL_SIZE=4 + + npm install -g node-gyp + # Install dependencies using npm, skip optional and native modules npm install - VSCODE_RIPGREP_VERSION=$(jq -r '.dependencies."@vscode/ripgrep"' package.json) - mv package.json package.json.orig - jq 'del(.dependencies."@vscode/ripgrep")' package.json.orig > package.json - - npm install - npm install --ignore-scripts "@vscode/ripgrep@${VSCODE_RIPGREP_VERSION}" - + # Run the gulp build task with memory optimizations ARCH_ALIAS=linux-x64 - npx gulp vscode-reh-web-${ARCH_ALIAS}-min + node --max-old-space-size=32768 --optimize-for-size \ + ./node_modules/gulp/bin/gulp.js \ + "vscode-reh-web-${ARCH_ALIAS}-min" - name: Find build output id: find_output @@ -96,7 +102,8 @@ jobs: tar czf $TARBALL -C "$PARENT_DIR" "$BUILD_DIR_NAME" - name: Upload build artifact + if: env.ACT == '' uses: actions/upload-artifact@v4 with: name: npm-package - path: sagemaker-code-editor-${{ env.VERSION }}.tar.gz + path: sagemaker-code-editor-${{ env.VERSION }}.tar.gz \ No newline at end of file diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index f0eeb7124..f90e622fa 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -16,23 +16,20 @@ jobs: runs-on: ubuntu-latest if: github.event.workflow_run.conclusion == 'success' || github.event_name == 'pull_request' steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - name: Checkout repo with submodules + uses: actions/checkout@v4 with: - node-version: 20 - cache: npm - - run: npm ci - - name: Download build artifact - if: github.event_name != 'pull_request' - uses: actions/download-artifact@v4 + submodules: recursive + - name: Set up Node.js + uses: actions/setup-node@v4 with: - name: build-package - github-token: ${{ secrets.GITHUB_TOKEN }} - run-id: ${{ github.event.workflow_run.id }} + node-version: 20 + cache: 'npm' + cache-dependency-path: '**/package-lock.json' - name: Run E2E tests run: | # Add your actual E2E test commands here - echo "Running E2E tests..." + echo "[PLACEHOLDER] Running E2E tests..." # Example: npm run test:e2e - uses: actions/upload-artifact@v4 if: failure() diff --git a/.gitignore b/.gitignore index eab08afe3..b5e3fb045 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .DS_Store -.pc \ No newline at end of file +.pc +.artifacts +bin \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c4b6a1c50..6ee63d7e8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,11 +30,15 @@ Contributions via pull requests are much appreciated. Before sending us a pull r To send us a pull request, please: 1. Fork the repository. -2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. -3. Ensure local tests pass. -4. Commit to your fork using clear commit messages. -5. Send us a pull request, answering any default questions in the pull request interface. -6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. +2. Create a branch for your change. +3. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. +4. Ensure local tests pass. +5. Commit to your fork using clear commit messages. +6. Push that branch to the upstream `aws/sagemaker-code-editor` repository. +7. Send us a pull request (from your branch in `aws/sagemaker-code-editor`), answering any default questions in the pull request interface. + + > ***Important***: Our tests will **always fail** if the pull request does not come from a branch in the `aws/sagemaker-code-editor` repository. +8. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..1be0c16e0 --- /dev/null +++ b/Makefile @@ -0,0 +1,74 @@ +.PHONY: build-cache build install-act run-github run-local clean-vscode clean + +build-cache: + @echo "Building SageMaker Code Editor (multi-stage npm cache)..." + docker buildx build \ + --platform linux/amd64 \ + --progress=plain \ + --memory=32g \ + -t npm-cache:latest \ + -f scripts/Dockerfile.build.cache . + +build: + @echo "Building SageMaker Code Editor (original)..." + docker buildx build \ + --platform linux/amd64 \ + --progress=plain \ + --memory=32g \ + --output type=local,dest=./.artifacts \ + -t localbuild:latest \ + -f scripts/Dockerfile.build . + +install-act: + @echo "Installing act (GitHub Actions runner)..." + @if ! command -v act >/dev/null 2>&1 && [ ! -f ./bin/act ]; then \ + curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | bash; \ + echo "act installed successfully"; \ + else \ + echo "act is already available"; \ + fi + +run-github: install-act + @echo "Running complete GitHub Actions workflow locally..." + @echo "Available workflows:" + @ls -la .github/workflows/ + @echo "" + @echo "Running full build.yml workflow..." + @if command -v act >/dev/null 2>&1; then \ + act push -W .github/workflows/build.yml --platform ubuntu-22.04=catthehacker/ubuntu:act-22.04 --container-options "--memory=32g --memory-swap=32g"; \ + else \ + ./bin/act push -W .github/workflows/build.yml --platform ubuntu-22.04=catthehacker/ubuntu:act-22.04 --container-options "--memory=32g --memory-swap=32g"; \ + fi + +run-local: + @if [ -z "$(TARBALL)" ]; then \ + echo "Building and running SageMaker Code Editor locally on port 8888..."; \ + docker build -f scripts/Dockerfile.dev -t local-code-editor-dev . || exit 1; \ + echo "Stopping container..."; \ + docker stop local-code-editor-dev; \ + sleep 2; \ + echo "Starting container on http://localhost:8888"; \ + docker run --rm -d -p 8888:8000 -v .:/workspace --entrypoint /workspace/scripts/run-code-editor-dev.sh --name local-code-editor-dev local-code-editor-dev || exit 1; \ + docker logs -f local-code-editor-dev; \ + else \ + echo "Building and running SageMaker Code Editor locally on port 8888..."; \ + docker build -f scripts/Dockerfile.run --build-arg TARBALL=$(TARBALL) -t local-code-editor . || exit 1; \ + echo "Stopping container..."; \ + docker stop local-code-editor; \ + sleep 2; \ + echo "Starting container on http://localhost:8888"; \ + docker run --rm -d -p 8888:8000 --name local-code-editor local-code-editor || exit 1; \ + docker logs -f local-code-editor; \ + fi + +clean-vscode: + @echo "Cleaning VSCode node_modules..." + @find . -type d -name "node_modules" -exec rm -rf {} + 2>/dev/null || true + @rm -rf vscode/out/* 2>/dev/null || true + @echo "VSCode cleanup completed" + +clean: clean-vscode + @echo "Cleaning act temporary files and Docker images..." + @echo "Removing act cache..." + @rm -rf ~/.cache/act 2>/dev/null || true + @echo "Act cleanup completed" diff --git a/README.md b/README.md index cc5b8da21..edc7c53c2 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,26 @@ This script will: - Run `yarn watch` from within the `vscode` folder - Open a new terminal and run `./vscode/scripts/code-server.sh --launch` +## Make Commands + +Available make targets for building and testing: + +### 1. When making local changes to iterate faster where tarball generation is not required [each run takes 10-20 mins] +- `make run-local` - Build and run SageMaker Code Editor locally from source and does not require a TARBALL; this process runs a watcher so changes are automatically picked from local workspace +- `make clean-vscode` - Cleans node_modules and out files + +### 2. Once local changes are tested; follow this process to generate minified tarball [each run takes ~40 mins to build] +- `make build-cache` - Build SageMaker Code Editor with multi-stage npm cache; Run once and layer gets cached with node_modules +- `make build` - Build SageMaker Code Editor and output artifacts (tarball) to ./artifacts +- `make run-local TARBALL=` - Build and run SageMaker Code Editor locally on port 8888 using specified tarball from previos step. Example: `make run-local TARBALL=sagemaker-code-editor-1.101.2.tar.gz` + +### 3. This process is used to test and simulate github workflows locally [each run takes ~60 mins] +- `make run-github` - Run complete GitHub Actions workflow locally using act + +### 4. Cleanup +- `make clean` - Cleans node_modules, out files, and act temporary files + + ## Troubleshooting and Feedback For any issues that customers would like to report, please route to the `amazon-sagemaker-feedback` repository: https://github.com/aws/amazon-sagemaker-feedback @@ -38,4 +58,4 @@ See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more inform ## License -This library is licensed under the MIT License. See the LICENSE file. +This library is licensed under the MIT License. See the LICENSE file. \ No newline at end of file diff --git a/artifacts/sagemaker-code-editor-1.101.2.tar.gz b/artifacts/sagemaker-code-editor-1.101.2.tar.gz new file mode 100644 index 000000000..5db3b18a4 Binary files /dev/null and b/artifacts/sagemaker-code-editor-1.101.2.tar.gz differ diff --git a/patched-vscode/src/vs/server/node/remoteLanguagePacks.ts b/patched-vscode/src/vs/server/node/remoteLanguagePacks.ts index ba6b17125..9e14384bb 100644 --- a/patched-vscode/src/vs/server/node/remoteLanguagePacks.ts +++ b/patched-vscode/src/vs/server/node/remoteLanguagePacks.ts @@ -17,7 +17,11 @@ export function getNLSConfiguration(language: string, userDataPath: string): Pro let result = _cache.get(key); if (!result) { // The OS Locale on the remote side really doesn't matter, so we pass in the same language +<<<<<<< HEAD result = lp.getNLSConfiguration("dummy_commit", userDataPath, metaData, language, language).then(value => { +======= + result = lp.getNLSConfiguration("dummy_commmit", userDataPath, metaData, language, language).then(value => { +>>>>>>> 34c670ba (Update patched-vscode) if (InternalNLSConfiguration.is(value)) { value._languagePackSupport = true; } @@ -79,4 +83,8 @@ const stripComments = (content: string): string => { return match; } }); -}; \ No newline at end of file +<<<<<<< HEAD +}; +======= +}; +>>>>>>> 34c670ba (Update patched-vscode) diff --git a/patched-vscode/src/vs/server/node/webClientServer.ts b/patched-vscode/src/vs/server/node/webClientServer.ts index abb3138f1..e582be8c7 100644 --- a/patched-vscode/src/vs/server/node/webClientServer.ts +++ b/patched-vscode/src/vs/server/node/webClientServer.ts @@ -563,4 +563,4 @@ export class WebClientServer { serveError(req, res, 500, error.message) } } -} +} \ No newline at end of file diff --git a/patched-vscode/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts b/patched-vscode/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts index 0c77eb25b..a427534e1 100644 --- a/patched-vscode/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts +++ b/patched-vscode/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts @@ -3210,4 +3210,4 @@ registerThemingParticipant((theme: IColorTheme, collector: ICssStyleCollector) = collector.addRule(`.extension-editor .body .subcontent .runtime-status ${ThemeIcon.asCSSSelector(infoIcon)} { color: ${infoColor}; }`); collector.addRule(`.monaco-hover.extension-hover .markdown-hover .hover-contents ${ThemeIcon.asCSSSelector(infoIcon)} { color: ${infoColor}; }`); } -}); +}); \ No newline at end of file diff --git a/patches/base-path.diff b/patches/base-path.diff deleted file mode 100644 index d4814a993..000000000 --- a/patches/base-path.diff +++ /dev/null @@ -1,275 +0,0 @@ -Index: sagemaker-code-editor/vscode/src/vs/base/common/network.ts -=================================================================== ---- sagemaker-code-editor.orig/vscode/src/vs/base/common/network.ts -+++ sagemaker-code-editor/vscode/src/vs/base/common/network.ts -@@ -212,7 +212,9 @@ class RemoteAuthoritiesImpl { - return URI.from({ - scheme: platform.isWeb ? this._preferredWebSchema : Schemas.vscodeRemoteResource, - authority: `${host}:${port}`, -- path: this._remoteResourcesPath, -+ path: platform.isWeb -+ ? (window.location.pathname + "/" + this._remoteResourcesPath).replace(/\/\/+/g, "/") -+ : this._remoteResourcesPath, - query - }); - } -Index: sagemaker-code-editor/vscode/src/vs/base/common/product.ts -=================================================================== ---- sagemaker-code-editor.orig/vscode/src/vs/base/common/product.ts -+++ sagemaker-code-editor/vscode/src/vs/base/common/product.ts -@@ -55,6 +55,7 @@ export type ExtensionVirtualWorkspaceSup - }; - - export interface IProductConfiguration { -+ readonly rootEndpoint?: string - readonly version: string; - readonly date?: string; - readonly quality?: string; -Index: sagemaker-code-editor/vscode/src/vs/code/browser/workbench/workbench-dev.html -=================================================================== ---- sagemaker-code-editor.orig/vscode/src/vs/code/browser/workbench/workbench-dev.html -+++ sagemaker-code-editor/vscode/src/vs/code/browser/workbench/workbench-dev.html -@@ -36,7 +36,7 @@ - - - - -