2024-06-13 21:02:38 +00:00
|
|
|
name: Pipeline Segment - Electron Build
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
inputs:
|
2024-06-14 16:14:38 +00:00
|
|
|
environment:
|
|
|
|
description: using the production or testing environment
|
|
|
|
required: false
|
|
|
|
type: string
|
2024-06-13 21:02:38 +00:00
|
|
|
target-platform:
|
|
|
|
type: string
|
|
|
|
description: 'Platform to run on, can be macos or linux'
|
|
|
|
required: true
|
|
|
|
target-arch:
|
|
|
|
type: string
|
|
|
|
description: 'Arch to build for, can be x64, arm64 or arm'
|
|
|
|
required: true
|
|
|
|
build-runs-on:
|
|
|
|
type: string
|
|
|
|
description: 'What host to run the build'
|
|
|
|
required: true
|
|
|
|
build-container:
|
|
|
|
type: string
|
|
|
|
description: 'JSON container information for aks runs-on'
|
|
|
|
required: false
|
|
|
|
default: '{"image":null}'
|
|
|
|
is-release:
|
|
|
|
description: 'Whether this build job is a release job'
|
|
|
|
required: true
|
|
|
|
type: boolean
|
|
|
|
default: false
|
|
|
|
gn-build-type:
|
|
|
|
description: 'The gn build type - testing or release'
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
default: testing
|
|
|
|
generate-symbols:
|
|
|
|
description: 'Whether or not to generate symbols'
|
|
|
|
required: true
|
|
|
|
type: boolean
|
|
|
|
default: false
|
|
|
|
upload-to-storage:
|
|
|
|
description: 'Whether or not to upload build artifacts to external storage'
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
default: '0'
|
|
|
|
|
2024-06-13 22:49:38 +00:00
|
|
|
|
2024-06-13 21:02:38 +00:00
|
|
|
concurrency:
|
|
|
|
group: electron-build-${{ inputs.target-platform }}-${{ inputs.target-arch }}-${{ github.ref }}
|
2024-06-14 16:08:21 +00:00
|
|
|
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && !endsWith(github.ref, '-x-y') }}
|
2024-06-13 21:02:38 +00:00
|
|
|
|
|
|
|
env:
|
|
|
|
AZURE_AKS_CACHE_STORAGE_ACCOUNT: ${{ secrets.AZURE_AKS_CACHE_STORAGE_ACCOUNT }}
|
|
|
|
AZURE_AKS_CACHE_SHARE_NAME: ${{ secrets.AZURE_AKS_CACHE_SHARE_NAME }}
|
|
|
|
ELECTRON_ARTIFACTS_BLOB_STORAGE: ${{ secrets.ELECTRON_ARTIFACTS_BLOB_STORAGE }}
|
|
|
|
ELECTRON_RBE_JWT: ${{ secrets.ELECTRON_RBE_JWT }}
|
|
|
|
ELECTRON_GITHUB_TOKEN: ${{ secrets.ELECTRON_GITHUB_TOKEN }}
|
|
|
|
# Disable pre-compiled headers to reduce out size - only useful for rebuilds
|
|
|
|
GN_BUILDFLAG_ARGS: 'enable_precompiled_headers=false'
|
|
|
|
GCLIENT_EXTRA_ARGS: ${{ inputs.target-platform == 'macos' && '--custom-var=checkout_mac=True --custom-var=host_os=mac' || '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True' }}
|
|
|
|
# Only disable this in the Asan build
|
|
|
|
CHECK_DIST_MANIFEST: true
|
|
|
|
IS_GHA_RELEASE: true
|
|
|
|
ELECTRON_OUT_DIR: Default
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ${{ inputs.build-runs-on }}
|
|
|
|
container: ${{ fromJSON(inputs.build-container) }}
|
2024-06-14 16:14:38 +00:00
|
|
|
environment: ${{ inputs.environment }}
|
2024-06-13 21:02:38 +00:00
|
|
|
env:
|
|
|
|
TARGET_ARCH: ${{ inputs.target-arch }}
|
|
|
|
steps:
|
2024-06-13 22:49:38 +00:00
|
|
|
- name: Create src dir
|
|
|
|
run: mkdir src
|
2024-06-13 21:02:38 +00:00
|
|
|
- name: Checkout Electron
|
|
|
|
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
|
|
|
|
with:
|
|
|
|
path: src/electron
|
|
|
|
fetch-depth: 0
|
|
|
|
- name: Setup Node.js/npm
|
|
|
|
if: ${{ inputs.target-platform == 'macos' }}
|
|
|
|
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
|
|
|
|
with:
|
|
|
|
node-version: 20.11.x
|
|
|
|
cache: yarn
|
|
|
|
cache-dependency-path: src/electron/yarn.lock
|
|
|
|
- name: Install Dependencies
|
|
|
|
run: |
|
|
|
|
cd src/electron
|
|
|
|
node script/yarn install
|
|
|
|
- name: Install AZCopy
|
|
|
|
if: ${{ inputs.target-platform == 'macos' }}
|
|
|
|
run: brew install azcopy
|
|
|
|
- name: Set GN_EXTRA_ARGS for Linux
|
|
|
|
if: ${{ inputs.target-platform == 'linux' }}
|
|
|
|
run: |
|
|
|
|
if [ "${{ inputs.target-arch }}" = "arm" ]; then
|
2024-06-14 16:14:38 +00:00
|
|
|
GN_EXTRA_ARGS='target_cpu="arm" build_tflite_with_xnnpack=false'
|
2024-06-13 21:02:38 +00:00
|
|
|
elif [ "${{ inputs.target-arch }}" = "arm64" ]; then
|
2024-06-14 16:14:38 +00:00
|
|
|
GN_EXTRA_ARGS='target_cpu="arm64" fatal_linker_warnings=false enable_linux_installer=false'
|
2024-06-13 21:02:38 +00:00
|
|
|
fi
|
|
|
|
echo "GN_EXTRA_ARGS=$GN_EXTRA_ARGS" >> $GITHUB_ENV
|
|
|
|
- name: Get Depot Tools
|
|
|
|
timeout-minutes: 5
|
|
|
|
run: |
|
|
|
|
git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
|
|
|
|
|
|
|
SEDOPTION="-i"
|
|
|
|
if [ "`uname`" = "Darwin" ]; then
|
|
|
|
SEDOPTION="-i ''"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# remove ninjalog_uploader_wrapper.py from autoninja since we don't use it and it causes problems
|
|
|
|
sed $SEDOPTION '/ninjalog_uploader_wrapper.py/d' ./depot_tools/autoninja
|
|
|
|
|
|
|
|
# Ensure depot_tools does not update.
|
|
|
|
test -d depot_tools && cd depot_tools
|
2024-06-14 14:11:30 +00:00
|
|
|
if [ "`uname`" = "Linux" ]; then
|
|
|
|
git apply --3way ../src/electron/.github/workflows/config/gclient.diff
|
|
|
|
fi
|
2024-06-13 21:02:38 +00:00
|
|
|
touch .disable_auto_update
|
|
|
|
- name: Add Depot Tools to PATH
|
|
|
|
run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
|
|
|
|
- name: Generate DEPS Hash
|
|
|
|
run: |
|
|
|
|
node src/electron/script/generate-deps-hash.js && cat src/electron/.depshash-target
|
|
|
|
DEPSHASH=v1-src-cache-$(shasum src/electron/.depshash | cut -f1 -d' ')
|
|
|
|
echo "DEPSHASH=$DEPSHASH" >> $GITHUB_ENV
|
|
|
|
echo "CACHE_PATH=$DEPSHASH.tar" >> $GITHUB_ENV
|
|
|
|
- name: Restore src cache via AZCopy
|
|
|
|
if: ${{ inputs.target-platform == 'macos' }}
|
|
|
|
uses: ./src/electron/.github/actions/restore-cache-azcopy
|
|
|
|
- name: Restore src cache via AKS
|
|
|
|
if: ${{ inputs.target-platform == 'linux' }}
|
|
|
|
uses: ./src/electron/.github/actions/restore-cache-aks
|
|
|
|
- name: Checkout Electron
|
|
|
|
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
|
|
|
|
with:
|
|
|
|
path: src/electron
|
|
|
|
fetch-depth: 0
|
2024-06-13 22:49:38 +00:00
|
|
|
- name: Load Build Tools
|
|
|
|
run: |
|
2024-06-14 20:29:11 +00:00
|
|
|
export BUILD_TOOLS_SHA=ff3e40a9a2ebb735c18b6450ecd5ddaa8bb364a9
|
2024-06-13 22:49:38 +00:00
|
|
|
npm i -g @electron/build-tools
|
|
|
|
e auto-update disable
|
|
|
|
e init -f --root=$(pwd) --out=Default ${{ inputs.gn-build-type }} --import ${{ inputs.gn-build-type }} --target-cpu ${{ inputs.target-arch }} --only-sdk
|
2024-06-13 21:02:38 +00:00
|
|
|
- name: Run Electron Only Hooks
|
|
|
|
run: |
|
|
|
|
gclient runhooks --spec="solutions=[{'name':'src/electron','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':False},'managed':False}]"
|
|
|
|
- name: Regenerate DEPS Hash
|
|
|
|
run: |
|
|
|
|
(cd src/electron && git checkout .) && node src/electron/script/generate-deps-hash.js && cat src/electron/.depshash-target
|
|
|
|
echo "DEPSHASH=$(shasum src/electron/.depshash | cut -f1 -d' ')" >> $GITHUB_ENV
|
|
|
|
- name: Add CHROMIUM_BUILDTOOLS_PATH to env
|
|
|
|
run: echo "CHROMIUM_BUILDTOOLS_PATH=$(pwd)/src/buildtools" >> $GITHUB_ENV
|
|
|
|
- name: Fix Sync (macOS)
|
|
|
|
if: ${{ inputs.target-platform == 'macos' }}
|
|
|
|
uses: ./src/electron/.github/actions/fix-sync-macos
|
|
|
|
- name: Install build-tools & Setup RBE
|
|
|
|
run: |
|
|
|
|
echo "NUMBER_OF_NINJA_PROCESSES=${{ inputs.target-platform == 'linux' && '300' || '200' }}" >> $GITHUB_ENV
|
|
|
|
cd ~/.electron_build_tools
|
|
|
|
npx yarn --ignore-engines
|
|
|
|
# Pull down credential helper and print status
|
|
|
|
node -e "require('./src/utils/reclient.js').downloadAndPrepare({})"
|
|
|
|
HELPER=$(node -p "require('./src/utils/reclient.js').helperPath({})")
|
|
|
|
$HELPER login
|
|
|
|
echo 'RBE_service='`node -e "console.log(require('./src/utils/reclient.js').serviceAddress)"` >> $GITHUB_ENV
|
|
|
|
echo 'RBE_experimental_credentials_helper='`node -e "console.log(require('./src/utils/reclient.js').helperPath({}))"` >> $GITHUB_ENV
|
|
|
|
echo 'RBE_experimental_credentials_helper_args=print' >> $GITHUB_ENV
|
|
|
|
- name: Free up space (macOS)
|
|
|
|
if: ${{ inputs.target-platform == 'macos' }}
|
|
|
|
uses: ./src/electron/.github/actions/free-space-macos
|
|
|
|
- name: Build Electron
|
|
|
|
uses: ./src/electron/.github/actions/build-electron
|
|
|
|
with:
|
|
|
|
target-arch: ${{ inputs.target-arch }}
|
|
|
|
target-platform: ${{ inputs.target-platform }}
|
|
|
|
artifact-platform: ${{ inputs.target-platform == 'linux' && 'linux' || 'darwin' }}
|
|
|
|
is-release: '${{ inputs.is-release }}'
|
|
|
|
generate-symbols: '${{ inputs.generate-symbols }}'
|
|
|
|
upload-to-storage: '${{ inputs.upload-to-storage }}'
|
|
|
|
- name: Set GN_EXTRA_ARGS for MAS Build
|
|
|
|
if: ${{ inputs.target-platform == 'macos' }}
|
|
|
|
run: |
|
|
|
|
echo "MAS_BUILD=true" >> $GITHUB_ENV
|
|
|
|
GN_EXTRA_ARGS='is_mas_build=true'
|
|
|
|
echo "GN_EXTRA_ARGS=$GN_EXTRA_ARGS" >> $GITHUB_ENV
|
|
|
|
- name: Build Electron (MAS)
|
|
|
|
if: ${{ inputs.target-platform == 'macos' }}
|
|
|
|
uses: ./src/electron/.github/actions/build-electron
|
|
|
|
with:
|
|
|
|
target-arch: ${{ inputs.target-arch }}
|
|
|
|
target-platform: ${{ inputs.target-platform }}
|
|
|
|
artifact-platform: 'mas'
|
|
|
|
is-release: '${{ inputs.is-release }}'
|
|
|
|
generate-symbols: '${{ inputs.generate-symbols }}'
|
|
|
|
upload-to-storage: '${{ inputs.upload-to-storage }}'
|
|
|
|
step-suffix: '(mas)'
|