Add push trigger for testing on current branch #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Code OSS Fast Build | |
| # This workflow builds Code OSS for win32-x64, darwin-arm64, and linux-x64 as quickly as possible. | |
| # It is manually triggered and leverages caching for node_modules and built-in extensions. | |
| # The workflow runs in three stages: | |
| # 1. Compile: Compiles the source code and creates a compilation artifact | |
| # 2. Platform builds: Builds for each platform in parallel using the compilation artifact | |
| # 3. Upload: Uploads the build artifacts for each platform | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - copilot/add-github-actions-workflow | |
| permissions: {} | |
| env: | |
| VSCODE_QUALITY: 'oss' | |
| jobs: | |
| compile: | |
| name: Compile | |
| runs-on: [ self-hosted, 1ES.Pool=1es-vscode-oss-ubuntu-22.04-x64 ] | |
| outputs: | |
| node_modules_cache_key: ${{ steps.cache-key.outputs.key }} | |
| builtin_extensions_cache_key: ${{ steps.builtin-cache-key.outputs.key }} | |
| steps: | |
| - name: Checkout microsoft/vscode | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version-file: .nvmrc | |
| - name: Prepare node_modules cache key | |
| id: cache-key | |
| run: | | |
| mkdir -p .build | |
| node build/azure-pipelines/common/computeNodeModulesCacheKey.ts compile $(node -p process.arch) > .build/packagelockhash | |
| echo "key=node_modules-compile-$(cat .build/packagelockhash | sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT | |
| - name: Restore node_modules cache | |
| id: cache-node-modules | |
| uses: actions/cache@v5 | |
| with: | |
| path: .build/node_modules_cache | |
| key: ${{ steps.cache-key.outputs.key }} | |
| - name: Extract node_modules cache | |
| if: steps.cache-node-modules.outputs.cache-hit == 'true' | |
| run: tar -xzf .build/node_modules_cache/cache.tgz | |
| - name: Install build tools | |
| if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
| run: sudo apt update -y && sudo apt install -y build-essential pkg-config libx11-dev libx11-xcb-dev libxkbfile-dev libnotify-bin libkrb5-dev | |
| - name: Install dependencies | |
| if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
| run: | | |
| set -e | |
| for i in {1..5}; do # try 5 times | |
| npm ci && break | |
| if [ $i -eq 5 ]; then | |
| echo "Npm install failed too many times" >&2 | |
| exit 1 | |
| fi | |
| echo "Npm install failed $i, trying again..." | |
| done | |
| env: | |
| ELECTRON_SKIP_BINARY_DOWNLOAD: 1 | |
| PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create node_modules archive | |
| if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
| run: | | |
| set -e | |
| node build/azure-pipelines/common/listNodeModules.ts .build/node_modules_list.txt | |
| mkdir -p .build/node_modules_cache | |
| tar -czf .build/node_modules_cache/cache.tgz --files-from .build/node_modules_list.txt | |
| - name: Prepare built-in extensions cache key | |
| id: builtin-cache-key | |
| run: | | |
| set -e | |
| mkdir -p .build | |
| node build/azure-pipelines/common/computeBuiltInDepsCacheKey.ts > .build/builtindepshash | |
| echo "key=builtin-extensions-$(cat .build/builtindepshash | sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT | |
| - name: Restore built-in extensions cache | |
| id: cache-builtin-extensions | |
| uses: actions/cache@v5 | |
| with: | |
| enableCrossOsArchive: true | |
| path: .build/builtInExtensions | |
| key: ${{ steps.builtin-cache-key.outputs.key }} | |
| - name: Download built-in extensions | |
| if: steps.cache-builtin-extensions.outputs.cache-hit != 'true' | |
| run: node build/lib/builtInExtensions.ts | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Compile & Hygiene | |
| run: npm exec -- npm-run-all2 -lp core-ci extensions-ci | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create compilation artifact | |
| run: | | |
| set -e | |
| tar -czf compilation.tar.gz .build out-* | |
| - name: Upload compilation artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: compilation | |
| path: compilation.tar.gz | |
| retention-days: 1 | |
| linux-x64: | |
| name: Linux x64 | |
| needs: compile | |
| runs-on: [ self-hosted, 1ES.Pool=1es-vscode-oss-ubuntu-22.04-x64 ] | |
| env: | |
| NPM_ARCH: x64 | |
| VSCODE_ARCH: x64 | |
| steps: | |
| - name: Checkout microsoft/vscode | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version-file: .nvmrc | |
| - name: Download compilation artifact | |
| uses: actions/download-artifact@v4.1.3 | |
| with: | |
| name: compilation | |
| - name: Extract compilation artifact | |
| run: tar -xzf compilation.tar.gz | |
| - name: Setup system services | |
| run: | | |
| set -e | |
| sudo apt update -y | |
| sudo apt install -y pkg-config libx11-dev libx11-xcb-dev libxkbfile-dev libsecret-1-dev libkrb5-dev rpm | |
| - name: Prepare node_modules cache key | |
| run: mkdir -p .build && node build/azure-pipelines/common/computeNodeModulesCacheKey.ts linux $VSCODE_ARCH $(node -p process.arch) > .build/packagelockhash | |
| - name: Restore node_modules cache | |
| id: cache-node-modules | |
| uses: actions/cache/restore@v5 | |
| with: | |
| path: .build/node_modules_cache | |
| key: "node_modules-linux-${{ hashFiles('.build/packagelockhash') }}" | |
| - name: Extract node_modules cache | |
| if: steps.cache-node-modules.outputs.cache-hit == 'true' | |
| run: tar -xzf .build/node_modules_cache/cache.tgz | |
| - name: Install build dependencies | |
| if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
| working-directory: build | |
| run: | | |
| set -e | |
| for i in {1..5}; do # try 5 times | |
| npm ci && break | |
| if [ $i -eq 5 ]; then | |
| echo "Npm install failed too many times" >&2 | |
| exit 1 | |
| fi | |
| echo "Npm install failed $i, trying again..." | |
| done | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install dependencies | |
| if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
| run: | | |
| set -e | |
| source ./build/azure-pipelines/linux/setup-env.sh | |
| for i in {1..5}; do # try 5 times | |
| npm ci && break | |
| if [ $i -eq 5 ]; then | |
| echo "Npm install failed too many times" >&2 | |
| exit 1 | |
| fi | |
| echo "Npm install failed $i, trying again..." | |
| done | |
| env: | |
| npm_config_arch: ${{ env.NPM_ARCH }} | |
| VSCODE_ARCH: ${{ env.VSCODE_ARCH }} | |
| ELECTRON_SKIP_BINARY_DOWNLOAD: 1 | |
| PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build package | |
| run: npm run gulp vscode-linux-$VSCODE_ARCH-min-ci | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create archive | |
| run: | | |
| set -e | |
| mkdir -p .build/linux/client | |
| ARCHIVE_PATH=".build/linux/client/code-oss-x64.tar.gz" | |
| tar -czf $ARCHIVE_PATH -C .. VSCode-linux-x64 | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: vscode-linux-x64 | |
| path: .build/linux/client/*.tar.gz | |
| retention-days: 7 | |
| darwin-arm64: | |
| name: macOS arm64 | |
| needs: compile | |
| runs-on: macos-14-xlarge | |
| env: | |
| NPM_ARCH: arm64 | |
| VSCODE_ARCH: arm64 | |
| steps: | |
| - name: Checkout microsoft/vscode | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version-file: .nvmrc | |
| - name: Download compilation artifact | |
| uses: actions/download-artifact@v4.1.3 | |
| with: | |
| name: compilation | |
| - name: Extract compilation artifact | |
| run: tar -xzf compilation.tar.gz | |
| - name: Prepare node_modules cache key | |
| run: mkdir -p .build && node build/azure-pipelines/common/computeNodeModulesCacheKey.ts darwin $VSCODE_ARCH $(node -p process.arch) > .build/packagelockhash | |
| - name: Restore node_modules cache | |
| id: cache-node-modules | |
| uses: actions/cache/restore@v5 | |
| with: | |
| path: .build/node_modules_cache | |
| key: "node_modules-macos-${{ hashFiles('.build/packagelockhash') }}" | |
| - name: Extract node_modules cache | |
| if: steps.cache-node-modules.outputs.cache-hit == 'true' | |
| run: tar -xzf .build/node_modules_cache/cache.tgz | |
| - name: Install dependencies | |
| if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
| run: | | |
| set -e | |
| c++ --version | |
| xcode-select -print-path | |
| python3 -m pip install --break-system-packages setuptools | |
| for i in {1..5}; do # try 5 times | |
| npm ci && break | |
| if [ $i -eq 5 ]; then | |
| echo "Npm install failed too many times" >&2 | |
| exit 1 | |
| fi | |
| echo "Npm install failed $i, trying again..." | |
| done | |
| env: | |
| npm_config_arch: ${{ env.NPM_ARCH }} | |
| VSCODE_ARCH: ${{ env.VSCODE_ARCH }} | |
| ELECTRON_SKIP_BINARY_DOWNLOAD: 1 | |
| PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GYP_DEFINES: "kerberos_use_rtld=false" | |
| - name: Build package | |
| run: npm run gulp vscode-darwin-$VSCODE_ARCH-min-ci | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create archive | |
| run: | | |
| set -e | |
| mkdir -p .build/darwin/client | |
| ARCHIVE_PATH="$(pwd)/.build/darwin/client/VSCode-darwin-arm64.zip" | |
| (cd ../VSCode-darwin-arm64 && zip -Xry $ARCHIVE_PATH *) | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: vscode-darwin-arm64 | |
| path: .build/darwin/client/*.zip | |
| retention-days: 7 | |
| win32-x64: | |
| name: Windows x64 | |
| needs: compile | |
| runs-on: [ self-hosted, 1ES.Pool=1es-vscode-oss-windows-2022-x64 ] | |
| env: | |
| NPM_ARCH: x64 | |
| VSCODE_ARCH: x64 | |
| steps: | |
| - name: Checkout microsoft/vscode | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version-file: .nvmrc | |
| - name: Download compilation artifact | |
| uses: actions/download-artifact@v4.1.3 | |
| with: | |
| name: compilation | |
| - name: Extract compilation artifact | |
| shell: pwsh | |
| run: tar -xzf compilation.tar.gz | |
| - name: Prepare node_modules cache key | |
| shell: pwsh | |
| run: | | |
| mkdir .build -ea 0 | |
| node build/azure-pipelines/common/computeNodeModulesCacheKey.ts win32 ${{ env.VSCODE_ARCH }} $(node -p process.arch) > .build/packagelockhash | |
| - name: Restore node_modules cache | |
| uses: actions/cache/restore@v5 | |
| id: node-modules-cache | |
| with: | |
| path: .build/node_modules_cache | |
| key: "node_modules-windows-${{ hashFiles('.build/packagelockhash') }}" | |
| - name: Extract node_modules cache | |
| if: steps.node-modules-cache.outputs.cache-hit == 'true' | |
| shell: pwsh | |
| run: 7z.exe x .build/node_modules_cache/cache.7z -aoa | |
| - name: Install dependencies | |
| if: steps.node-modules-cache.outputs.cache-hit != 'true' | |
| shell: pwsh | |
| run: | | |
| . build/azure-pipelines/win32/exec.ps1 | |
| $ErrorActionPreference = "Stop" | |
| for ($i = 1; $i -le 5; $i++) { | |
| try { | |
| exec { npm ci } | |
| break | |
| } | |
| catch { | |
| if ($i -eq 5) { | |
| Write-Error "npm ci failed after 5 attempts" | |
| throw | |
| } | |
| Write-Host "npm ci failed attempt $i, retrying..." | |
| Start-Sleep -Seconds 2 | |
| } | |
| } | |
| env: | |
| npm_config_arch: ${{ env.NPM_ARCH }} | |
| npm_config_foreground_scripts: "true" | |
| VSCODE_ARCH: ${{ env.VSCODE_ARCH }} | |
| ELECTRON_SKIP_BINARY_DOWNLOAD: 1 | |
| PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build package | |
| shell: pwsh | |
| run: npm run gulp vscode-win32-$env:VSCODE_ARCH-min-ci | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create archive directory | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force -Path .build/win32-x64/archive | |
| - name: Move archive | |
| shell: pwsh | |
| run: | | |
| Move-Item -Path .build/win32-x64/VSCode-win32-x64.zip -Destination .build/win32-x64/archive/VSCode-win32-x64.zip | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: vscode-win32-x64 | |
| path: .build/win32-x64/archive/*.zip | |
| retention-days: 7 |