From accc3ed90520e620322268e9510a0063555cce7a Mon Sep 17 00:00:00 2001 From: Hudson Xing <77495133+harvenstar@users.noreply.github.com> Date: Fri, 25 Jul 2025 13:26:15 -0700 Subject: [PATCH 1/3] Create build.yml Signed-off-by: Hudson Xing <77495133+harvenstar@users.noreply.github.com> --- .github/workflows/build.yml | 116 ++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..e84f5dcb6 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,116 @@ +name: Build sagemaker-code-editor and Generate Artifact + +on: + workflow_dispatch: + inputs: + version: + description: 'Release version (include "v", e.g. "v1.2.3")' + required: true + type: string + +jobs: + build-release: + runs-on: ubuntu-latest + timeout-minutes: 180 + env: + DISABLE_V8_COMPILE_CACHE: 1 + + steps: + - name: Checkout repo with submodules + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install system dependencies + run: | + sudo apt-get update + 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 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Cache node modules + uses: actions/cache@v4 + with: + path: | + vscode/node_modules + key: ${{ runner.os }}-node20-${{ hashFiles('vscode/package.json', 'vscode/yarn.lock') }} + + - name: Apply patches (if any) + run: | + if [ -d patches ] && [ "$(ls -A patches)" ]; then + quilt push -a || true + fi + + - name: Get and set VERSION + id: version + run: | + VER="${{ github.event.inputs.version }}" + # Strip leading "v" if present, for use in file naming + SHORTVER="${VER#v}" + echo "VERSION=$VER" >> $GITHUB_ENV + echo "SHORTVER=$SHORTVER" >> $GITHUB_ENV + + - name: Build vscode + run: | + cd vscode + export DISABLE_V8_COMPILE_CACHE=1 + export UV_THREADPOOL_SIZE=4 + npm i -g node-gyp + yarn install --network-concurrency 1 + 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 + yarn install + yarn add --ignore-scripts "@vscode/ripgrep@${VSCODE_RIPGREP_VERSION}" + ARCH_ALIAS=linux-x64 + # This is the actual build command. If it fails, the workflow stops here. + yarn gulp vscode-reh-web-${ARCH_ALIAS}-min + + - name: Explore workspace to find build output + id: explore + run: | + echo "--- Exploring workspace after build ---" + # List the contents of the root directory to see if the build output is here. + ls -lA + + # Use the 'find' command to locate the build directory. + # The result is captured into a GitHub Actions output variable. + BUILD_PATH=$(find . -name "vscode-reh-web-linux-x64" -type d | head -n 1) + + if [ -z "$BUILD_PATH" ]; then + echo "::error::Build output directory 'vscode-reh-web-linux-x64' not found!" + exit 1 + fi + + echo "Build output found at: $BUILD_PATH" + echo "build_path=$BUILD_PATH" >> $GITHUB_OUTPUT + + - name: Create tarball archive + run: | + TARBALL="vscode-reh-web-linux-x64-${{ env.SHORTVER }}.tar.gz" + BUILD_DIR_PATH="${{ steps.explore.outputs.build_path }}" + + # We need to navigate to the parent directory of the build output to create the tarball correctly. + PARENT_DIR=$(dirname "$BUILD_DIR_PATH") + BUILD_DIR_NAME=$(basename "$BUILD_DIR_PATH") + + echo "Creating '$TARBALL' from '$BUILD_DIR_NAME' located in '$PARENT_DIR'" + tar czf $TARBALL -C "$PARENT_DIR" "$BUILD_DIR_NAME" + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: vscode-reh-web-linux-x64-${{ env.SHORTVER }} + path: vscode-reh-web-linux-x64-${{ env.SHORTVER }}.tar.gz + + - name: Create GitHub Release and upload tarball + uses: softprops/action-gh-release@v2 + with: + name: sagemaker-code-editor ${{ env.VERSION }} + tag_name: ${{ env.VERSION }} + files: vscode-reh-web-linux-x64-${{ env.SHORTVER }}.tar.gz + draft: true # Set to true to create a draft release + #test part From 3b89a2d937e6f638084f411b917badb03ef77054 Mon Sep 17 00:00:00 2001 From: Hudson Xing <77495133+harvenstar@users.noreply.github.com> Date: Fri, 25 Jul 2025 13:32:52 -0700 Subject: [PATCH 2/3] Update build.yml Signed-off-by: Hudson Xing <77495133+harvenstar@users.noreply.github.com> --- .github/workflows/build.yml | 92 ++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 47 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e84f5dcb6..7fa6d46cd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,36 +1,53 @@ +# Workflow name name: Build sagemaker-code-editor and Generate Artifact + + +# This workflow is triggered on pushes and pull requests to the main branch. on: - workflow_dispatch: - inputs: - version: - description: 'Release version (include "v", e.g. "v1.2.3")' - required: true - type: string + push: + branches: + - '**' + pull_request: + branches: + - '**' + +# Concurrency settings to cancel in-progress runs for the same PR or branch +# This prevents wasting resources on outdated commits. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: - build-release: + # The main job for building the application + build: + name: Build sagemaker-code-editor runs-on: ubuntu-latest timeout-minutes: 180 env: + # Environment variable to optimize the build process DISABLE_V8_COMPILE_CACHE: 1 steps: + # Step 1: Check out the repository code, including its submodules. - name: Checkout repo with submodules uses: actions/checkout@v4 with: submodules: recursive + # Step 2: Install system-level dependencies required for the build. - name: Install system dependencies run: | sudo apt-get update 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 - + # Step 3: Set up the Node.js environment. Version 20 is specified. - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: 20 + # Step 4: Cache Node.js modules to speed up subsequent builds. + # The cache is invalidated if the lock file changes. - name: Cache node modules uses: actions/cache@v4 with: @@ -38,21 +55,22 @@ jobs: vscode/node_modules key: ${{ runner.os }}-node20-${{ hashFiles('vscode/package.json', 'vscode/yarn.lock') }} + # Step 5: Apply patches from the 'patches' directory if it exists. - name: Apply patches (if any) run: | if [ -d patches ] && [ "$(ls -A patches)" ]; then quilt push -a || true fi - - - name: Get and set VERSION + # Step 6: Generate a version string for this specific build. + # It's based on the commit SHA to create a unique identifier. + - name: Set Development Version id: version run: | - VER="${{ github.event.inputs.version }}" - # Strip leading "v" if present, for use in file naming - SHORTVER="${VER#v}" - echo "VERSION=$VER" >> $GITHUB_ENV - echo "SHORTVER=$SHORTVER" >> $GITHUB_ENV - + SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) + VERSION="0.0.0-dev-${SHORT_SHA}" + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "Generated version for this build: $VERSION" + # Step 7: The main build process for vscode. - name: Build vscode run: | cd vscode @@ -66,51 +84,31 @@ jobs: yarn install yarn add --ignore-scripts "@vscode/ripgrep@${VSCODE_RIPGREP_VERSION}" ARCH_ALIAS=linux-x64 - # This is the actual build command. If it fails, the workflow stops here. yarn gulp vscode-reh-web-${ARCH_ALIAS}-min - - - name: Explore workspace to find build output - id: explore + # Step 8: Find the exact path of the build output directory. + - name: Find build output + id: find_output run: | - echo "--- Exploring workspace after build ---" - # List the contents of the root directory to see if the build output is here. - ls -lA - - # Use the 'find' command to locate the build directory. - # The result is captured into a GitHub Actions output variable. BUILD_PATH=$(find . -name "vscode-reh-web-linux-x64" -type d | head -n 1) - if [ -z "$BUILD_PATH" ]; then echo "::error::Build output directory 'vscode-reh-web-linux-x64' not found!" exit 1 fi - echo "Build output found at: $BUILD_PATH" echo "build_path=$BUILD_PATH" >> $GITHUB_OUTPUT - + # Step 9: Create a compressed tarball of the build output. - name: Create tarball archive run: | - TARBALL="vscode-reh-web-linux-x64-${{ env.SHORTVER }}.tar.gz" - BUILD_DIR_PATH="${{ steps.explore.outputs.build_path }}" - - # We need to navigate to the parent directory of the build output to create the tarball correctly. + TARBALL="vscode-reh-web-linux-x64-${{ env.VERSION }}.tar.gz" + BUILD_DIR_PATH="${{ steps.find_output.outputs.build_path }}" PARENT_DIR=$(dirname "$BUILD_DIR_PATH") BUILD_DIR_NAME=$(basename "$BUILD_DIR_PATH") - - echo "Creating '$TARBALL' from '$BUILD_DIR_NAME' located in '$PARENT_DIR'" + echo "Creating '$TARBALL' from '$BUILD_DIR_NAME' in '$PARENT_DIR'" tar czf $TARBALL -C "$PARENT_DIR" "$BUILD_DIR_NAME" - + # Step 10: Upload the tarball as a build artifact. + # This allows you to download the result from the workflow run summary page. - name: Upload build artifact uses: actions/upload-artifact@v4 with: - name: vscode-reh-web-linux-x64-${{ env.SHORTVER }} - path: vscode-reh-web-linux-x64-${{ env.SHORTVER }}.tar.gz - - - name: Create GitHub Release and upload tarball - uses: softprops/action-gh-release@v2 - with: - name: sagemaker-code-editor ${{ env.VERSION }} - tag_name: ${{ env.VERSION }} - files: vscode-reh-web-linux-x64-${{ env.SHORTVER }}.tar.gz - draft: true # Set to true to create a draft release - #test part + name: vscode-reh-web-linux-x64-${{ env.VERSION }} + path: vscode-reh-web-linux-x64-${{ env.VERSION }}.tar.gz From c44560657a986d3ed8862b1e5836db523907c1b9 Mon Sep 17 00:00:00 2001 From: Hudson Xing <77495133+harvenstar@users.noreply.github.com> Date: Fri, 25 Jul 2025 13:35:19 -0700 Subject: [PATCH 3/3] Update build.yml Signed-off-by: Hudson Xing <77495133+harvenstar@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7fa6d46cd..41801a416 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: Build sagemaker-code-editor and Generate Artifact -# This workflow is triggered on pushes and pull requests to the main branch. +# This workflow is triggered on pushes and pull requests. on: push: branches: