|
| 1 | +# Workflow name |
| 2 | +name: Build sagemaker-code-editor and Generate Artifact |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | +# This workflow is triggered on pushes and pull requests. |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - '**' |
| 11 | + pull_request: |
| 12 | + branches: |
| 13 | + - '**' |
| 14 | + |
| 15 | +# Concurrency settings to cancel in-progress runs for the same PR or branch |
| 16 | +# This prevents wasting resources on outdated commits. |
| 17 | +concurrency: |
| 18 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 19 | + cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 20 | + |
| 21 | +jobs: |
| 22 | + # The main job for building the application |
| 23 | + build: |
| 24 | + name: Build sagemaker-code-editor |
| 25 | + runs-on: ubuntu-latest |
| 26 | + timeout-minutes: 180 |
| 27 | + env: |
| 28 | + # Environment variable to optimize the build process |
| 29 | + DISABLE_V8_COMPILE_CACHE: 1 |
| 30 | + |
| 31 | + steps: |
| 32 | + # Step 1: Check out the repository code, including its submodules. |
| 33 | + - name: Checkout repo with submodules |
| 34 | + uses: actions/checkout@v4 |
| 35 | + with: |
| 36 | + submodules: recursive |
| 37 | + |
| 38 | + # Step 2: Install system-level dependencies required for the build. |
| 39 | + - name: Install system dependencies |
| 40 | + run: | |
| 41 | + sudo apt-get update |
| 42 | + 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 |
| 43 | + # Step 3: Set up the Node.js environment. Version 20 is specified. |
| 44 | + - name: Set up Node.js |
| 45 | + uses: actions/setup-node@v4 |
| 46 | + with: |
| 47 | + node-version: 20 |
| 48 | + |
| 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. |
| 59 | + - name: Apply patches (if any) |
| 60 | + run: | |
| 61 | + if [ -d patches ] && [ "$(ls -A patches)" ]; then |
| 62 | + quilt push -a || true |
| 63 | + fi |
| 64 | + # Step 6: Generate a version string for this specific build. |
| 65 | + # It's based on the commit SHA to create a unique identifier. |
| 66 | + - name: Set Development Version |
| 67 | + id: version |
| 68 | + run: | |
| 69 | + SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) |
| 70 | + VERSION="0.0.0-dev-${SHORT_SHA}" |
| 71 | + echo "VERSION=$VERSION" >> $GITHUB_ENV |
| 72 | + echo "Generated version for this build: $VERSION" |
| 73 | + # Step 7: The main build process for vscode. |
| 74 | + - name: Build vscode |
| 75 | + run: | |
| 76 | + cd vscode |
| 77 | + export DISABLE_V8_COMPILE_CACHE=1 |
| 78 | + export UV_THREADPOOL_SIZE=4 |
| 79 | + npm i -g node-gyp |
| 80 | + yarn install --network-concurrency 1 |
| 81 | + VSCODE_RIPGREP_VERSION=$(jq -r '.dependencies."@vscode/ripgrep"' package.json) |
| 82 | + mv package.json package.json.orig |
| 83 | + jq 'del(.dependencies."@vscode/ripgrep")' package.json.orig > package.json |
| 84 | + yarn install |
| 85 | + yarn add --ignore-scripts "@vscode/ripgrep@${VSCODE_RIPGREP_VERSION}" |
| 86 | + 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. |
| 89 | + - name: Find build output |
| 90 | + id: find_output |
| 91 | + run: | |
| 92 | + BUILD_PATH=$(find . -name "vscode-reh-web-linux-x64" -type d | head -n 1) |
| 93 | + if [ -z "$BUILD_PATH" ]; then |
| 94 | + echo "::error::Build output directory 'vscode-reh-web-linux-x64' not found!" |
| 95 | + exit 1 |
| 96 | + fi |
| 97 | + echo "Build output found at: $BUILD_PATH" |
| 98 | + echo "build_path=$BUILD_PATH" >> $GITHUB_OUTPUT |
| 99 | + # Step 9: Create a compressed tarball of the build output. |
| 100 | + - name: Create tarball archive |
| 101 | + run: | |
| 102 | + TARBALL="vscode-reh-web-linux-x64-${{ env.VERSION }}.tar.gz" |
| 103 | + BUILD_DIR_PATH="${{ steps.find_output.outputs.build_path }}" |
| 104 | + PARENT_DIR=$(dirname "$BUILD_DIR_PATH") |
| 105 | + BUILD_DIR_NAME=$(basename "$BUILD_DIR_PATH") |
| 106 | + echo "Creating '$TARBALL' from '$BUILD_DIR_NAME' in '$PARENT_DIR'" |
| 107 | + 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. |
| 110 | + - name: Upload build artifact |
| 111 | + uses: actions/upload-artifact@v4 |
| 112 | + with: |
| 113 | + name: vscode-reh-web-linux-x64-${{ env.VERSION }} |
| 114 | + path: vscode-reh-web-linux-x64-${{ env.VERSION }}.tar.gz |
0 commit comments