From 7866575385a1d0b8fcd7dfed7e6197b3c882e7fa Mon Sep 17 00:00:00 2001 From: Alexey Kuzmin Date: Mon, 8 Oct 2018 22:19:40 +0200 Subject: [PATCH] ci: fix the upload distribution step on VSTS (#15015) * ci: fix the upload distribution step on VSTS * ci: fix get_electron_exec() * ci: define "CI" env variable --- script/dump-symbols.py | 4 ++-- script/lib/util.py | 15 ++++++++++----- script/upload.py | 6 +++--- tools/win/generate_breakpad_symbols.py | 4 ++-- vsts.yml | 21 +++++++++++++++------ 5 files changed, 32 insertions(+), 18 deletions(-) diff --git a/script/dump-symbols.py b/script/dump-symbols.py index 0d96e44d8996..abb49c4e7cb7 100755 --- a/script/dump-symbols.py +++ b/script/dump-symbols.py @@ -6,7 +6,7 @@ import sys from lib.config import PLATFORM, enable_verbose_mode, is_verbose_mode from lib.util import get_electron_branding, execute, rm_rf, get_out_dir, \ - GN_SRC_DIR + SRC_DIR ELECTRON_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) SOURCE_ROOT = os.path.abspath(os.path.dirname(ELECTRON_ROOT)) @@ -51,7 +51,7 @@ def main(): args += ['-v'] #Make sure msdia140.dll is in the path (needed for dump_syms.exe) env = os.environ.copy() - msdia140_dll_path = os.path.join(GN_SRC_DIR, 'third_party', 'llvm-build', + msdia140_dll_path = os.path.join(SRC_DIR, 'third_party', 'llvm-build', 'Release+Asserts', 'bin') env['PATH'] = os.path.pathsep.join( [env.get('PATH', '')] + [msdia140_dll_path]) diff --git a/script/lib/util.py b/script/lib/util.py index 26593413976b..1c40efde9e19 100644 --- a/script/lib/util.py +++ b/script/lib/util.py @@ -21,7 +21,7 @@ import zipfile from lib.config import is_verbose_mode, PLATFORM from lib.env_util import get_vs_env -GN_SRC_DIR = os.path.abspath(os.path.join(__file__, '..', '..', '..', '..')) +SRC_DIR = os.path.abspath(os.path.join(__file__, '..', '..', '..', '..')) BOTO_DIR = os.path.abspath(os.path.join(__file__, '..', '..', '..', 'vendor', 'boto')) @@ -301,7 +301,7 @@ def get_out_dir(): override = os.environ.get('ELECTRON_OUT_DIR') if override is not None: out_dir = override - return os.path.join(GN_SRC_DIR, 'out', out_dir) + return os.path.join(SRC_DIR, 'out', out_dir) # NOTE: This path is not created by gn, it is used as a scratch zone by our # upload scripts @@ -309,9 +309,14 @@ def get_dist_dir(): return os.path.join(get_out_dir(), 'gen', 'electron_dist') def get_electron_exec(): + out_dir = get_out_dir() + if sys.platform == 'darwin': - return 'out/{0}/Electron.app/Contents/MacOS/Electron'.format(get_out_dir()) + return '{0}/Electron.app/Contents/MacOS/Electron'.format(out_dir) elif sys.platform == 'win32': - return 'out/{0}/electron.exe'.format(get_out_dir()) + return '{0}/electron.exe'.format(out_dir) elif sys.platform == 'linux': - return 'out/{0}/electron'.format(get_out_dir()) \ No newline at end of file + return '{0}/electron'.format(out_dir) + + raise Exception( + "get_electron_exec: unexpected platform '{0}'".format(sys.platform)) diff --git a/script/upload.py b/script/upload.py index d6925acc03de..7f5464206801 100755 --- a/script/upload.py +++ b/script/upload.py @@ -16,7 +16,7 @@ from lib.config import PLATFORM, get_target_arch, get_env_var, s3_config, \ get_zip_name from lib.util import get_electron_branding, execute, get_electron_version, \ parse_version, scoped_cwd, s3put, get_electron_exec, \ - get_out_dir, GN_SRC_DIR + get_out_dir, SRC_DIR ELECTRON_REPO = 'electron/electron' @@ -84,7 +84,7 @@ def main(): # Upload free version of ffmpeg. ffmpeg = get_zip_name('ffmpeg', ELECTRON_VERSION) ffmpeg_zip = os.path.join(OUT_DIR, ffmpeg) - ffmpeg_build_path = os.path.join(GN_SRC_DIR, 'out', 'ffmpeg', 'ffmpeg.zip') + ffmpeg_build_path = os.path.join(SRC_DIR, 'out', 'ffmpeg', 'ffmpeg.zip') shutil.copy2(ffmpeg_build_path, ffmpeg_zip) upload_electron(release, ffmpeg_zip, args) @@ -97,7 +97,7 @@ def main(): mksnapshot_zip = os.path.join(OUT_DIR, mksnapshot) if get_target_arch().startswith('arm'): # Upload the native mksnapshot as mksnapshot.zip - shutil.copy2(os.path.join(GN_SRC_DIR, 'out', 'native_mksnapshot', + shutil.copy2(os.path.join(SRC_DIR, 'out', 'native_mksnapshot', 'mksnapshot.zip'), mksnapshot_zip) upload_electron(release, mksnapshot_zip, args) # Upload the x64 binary for arm/arm64 mksnapshot diff --git a/tools/win/generate_breakpad_symbols.py b/tools/win/generate_breakpad_symbols.py index 9da56376964e..9ed970dbffe6 100755 --- a/tools/win/generate_breakpad_symbols.py +++ b/tools/win/generate_breakpad_symbols.py @@ -16,7 +16,7 @@ import subprocess import sys import threading -GN_SRC_DIR = os.path.abspath(os.path.join(__file__, '..', '..', '..', '..')) +SRC_DIR = os.path.abspath(os.path.join(__file__, '..', '..', '..', '..')) # Duplicated as this script lives in tools not script def get_out_dir(): @@ -24,7 +24,7 @@ def get_out_dir(): override = os.environ.get('ELECTRON_OUT_DIR') if override is not None: out_dir = override - return os.path.join(GN_SRC_DIR, 'out', out_dir) + return os.path.join(SRC_DIR, 'out', out_dir) CONCURRENT_TASKS=4 diff --git a/vsts.yml b/vsts.yml index c007fd6b3c1d..97c63af9755a 100644 --- a/vsts.yml +++ b/vsts.yml @@ -2,6 +2,8 @@ jobs: - job: Build_Electron_via_GN displayName: Build Electron via GN timeoutInMinutes: 120 + variables: + CI: true steps: - task: CopyFiles@2 @@ -133,14 +135,21 @@ jobs: - bash: | cd src/electron - if [ "$UPLOAD_TO_S3" != "1" ]; then - echo 'Uploading Electron release distribution to github releases' - ELECTRON_S3_BUCKET="$(s3_bucket)" ELECTRON_S3_ACCESS_KEY="$(s3_access_key)" ELECTRON_S3_SECRET_KEY="$(s3_secret_key)" ELECTRON_GITHUB_TOKEN="$(github_token)" script/upload.py - else + + export ELECTRON_OUT_DIR=Default + export ELECTRON_S3_BUCKET="$(s3_bucket)" + export ELECTRON_S3_ACCESS_KEY="$(s3_access_key)" + export ELECTRON_S3_SECRET_KEY="$(s3_secret_key)" + export ELECTRON_GITHUB_TOKEN="$(github_token)" + + if [ "$UPLOAD_TO_S3" == "1" ]; then echo 'Uploading Electron release distribution to s3' - ELECTRON_S3_BUCKET="$(s3_bucket)" ELECTRON_S3_ACCESS_KEY="$(s3_access_key)" ELECTRON_S3_SECRET_KEY="$(s3_secret_key)" ELECTRON_GITHUB_TOKEN="$(github_token)" script/upload.py --upload_to_s3 + script/upload.py --upload_to_s3 + else + echo 'Uploading Electron release distribution to Github releases' + script/upload.py fi - name: Upload_distribution + displayName: Upload distribution condition: and(succeeded(), eq(variables['ELECTRON_RELEASE'], '1')) - task: PublishTestResults@2