diff --git a/Jenkinsfile b/Jenkinsfile index caeaa6177f93..43b1545858ca 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,6 @@ pipeline { parameters { choice(name: 'CHANNEL', choices: ['nightly', 'dev', 'beta', 'release', 'development']) choice(name: 'BUILD_TYPE', choices: ["Static", "Release", "Component", "Debug"]) - choice(name: 'BUILD_STATUS', choices: ['', 'SUCCESS', 'FAILURE', 'UNSTABLE', 'ABORTED']) booleanParam(name: 'TERMINATE_NODE', defaultValue: false) booleanParam(name: 'WIPE_WORKSPACE', defaultValue: false) booleanParam(name: 'SKIP_INIT', defaultValue: false) @@ -23,45 +22,19 @@ pipeline { agent { label 'master' } steps { script { - REPO = JOB_NAME.substring(0, JOB_NAME.indexOf('-build-pr')) - OTHER_REPO = REPO.equals('brave-browser') ? 'brave-core' : 'brave-browser' PLATFORM = JOB_NAME.substring(JOB_NAME.indexOf('-build-pr') + 10, JOB_NAME.indexOf('/PR-')) PIPELINE_NAME = 'pr-brave-browser-' + CHANGE_BRANCH.replace('/', '-') + '-' + PLATFORM - if (params.BUILD_STATUS) { - if (Jenkins.instance.getItemByFullName(JOB_NAME).getLastBuild().getCause(hudson.model.Cause$UpstreamCause) == null) { - echo 'Aborting build as it has been started manually with BUILD_STATUS set' - currentBuild.result = 'ABORTED' - return - } - else { - echo "Setting other PR build status to ${params.BUILD_STATUS}" - currentBuild.result = params.BUILD_STATUS - return - } - } - withCredentials([usernamePassword(credentialsId: 'brave-builds-github-token-for-pr-builder', usernameVariable: 'PR_BUILDER_USER', passwordVariable: 'PR_BUILDER_TOKEN')]) { GITHUB_API = 'https://api.github.com/repos/brave' GITHUB_AUTH_HEADERS = [[name: 'Authorization', value: 'token ' + PR_BUILDER_TOKEN]] CHANGE_BRANCH_ENCODED = java.net.URLEncoder.encode(CHANGE_BRANCH, 'UTF-8') - def prDetails = readJSON(text: httpRequest(url: GITHUB_API + '/' + REPO + '/pulls?head=brave:' + CHANGE_BRANCH_ENCODED, customHeaders: GITHUB_AUTH_HEADERS, quiet: true).content)[0] + def prDetails = readJSON(text: httpRequest(url: GITHUB_API + '/brave-core/pulls?head=brave:' + CHANGE_BRANCH_ENCODED, customHeaders: GITHUB_AUTH_HEADERS, quiet: true).content)[0] SKIP = (prDetails.draft.equals(true) && prDetails.labels.count { label -> label.name.equalsIgnoreCase('CI/run-draft') }.equals(0)) || prDetails.labels.count { label -> label.name.equalsIgnoreCase('CI/skip') }.equals(1) || prDetails.labels.count { label -> label.name.equalsIgnoreCase("CI/skip-${PLATFORM}") }.equals(1) RUN_NETWORK_AUDIT = prDetails.labels.count { label -> label.name.equalsIgnoreCase('CI/run-network-audit') }.equals(1) RUN_AUDIT_DEPS = prDetails.labels.count { label -> label.name.equalsIgnoreCase('CI/run-audit-deps') }.equals(1) RUN_UPSTREAM_TESTS = prDetails.labels.count { label -> label.name.equalsIgnoreCase('CI/run-upstream-tests') }.equals(1) STORYBOOK = prDetails.labels.count { label -> label.name.equalsIgnoreCase('CI/storybook-url') }.equals(1) - def branchExistsInOtherRepo = httpRequest(url: GITHUB_API + '/' + OTHER_REPO + '/branches/' + CHANGE_BRANCH_ENCODED, validResponseCodes: '100:499', customHeaders: GITHUB_AUTH_HEADERS, quiet: true).status.equals(200) - if (branchExistsInOtherRepo) { - def otherPrDetails = readJSON(text: httpRequest(url: GITHUB_API + '/' + OTHER_REPO + '/pulls?head=brave:' + CHANGE_BRANCH_ENCODED, customHeaders: GITHUB_AUTH_HEADERS, quiet: true).content)[0] - if (otherPrDetails) { - env.OTHER_PR_NUMBER = otherPrDetails.number - SKIP = SKIP || otherPrDetails.draft.equals(true) || otherPrDetails.labels.count { label -> label.name.equalsIgnoreCase('CI/skip') }.equals(1) || otherPrDetails.labels.count { label -> label.name.equalsIgnoreCase("CI/skip-${PLATFORM}") }.equals(1) - RUN_NETWORK_AUDIT = RUN_NETWORK_AUDIT || otherPrDetails.labels.count { label -> label.name.equalsIgnoreCase('CI/run-network-audit') }.equals(1) - RUN_AUDIT_DEPS = RUN_AUDIT_DEPS || otherPrDetails.labels.count { label -> label.name.equalsIgnoreCase('CI/run-audit-deps') }.equals(1) - RUN_UPSTREAM_TESTS = RUN_UPSTREAM_TESTS || otherPrDetails.labels.count { label -> label.name.equalsIgnoreCase('CI/run-upstream-tests') }.equals(1) - } - } } if (SKIP && PLATFORM != 'noplatform') { @@ -133,9 +106,6 @@ pipeline { ] currentBuild.result = build(job: PIPELINE_NAME, parameters: params, propagate: false).result - if (env.OTHER_PR_NUMBER) { - build(job: OTHER_REPO + '-build-pr-' + PLATFORM + '/PR-' + env.OTHER_PR_NUMBER, parameters: [string(name: 'BUILD_STATUS', value: currentBuild.result)], propagate: false) - } } } } diff --git a/build/commands/lib/build.js b/build/commands/lib/build.js index 38e2043e7235..222042e5b167 100644 --- a/build/commands/lib/build.js +++ b/build/commands/lib/build.js @@ -106,7 +106,7 @@ const touchOverriddenVectorIconFiles = () => { } /** - * Checks to make sure the src/chrome/VERSION matches brave-browser's package.json version + * Checks to make sure the src/chrome/VERSION matches brave-core's package.json version */ const checkVersionsMatch = () => { const srcChromeVersionDir = path.resolve(path.join(config.srcDir, 'chrome', 'VERSION')) @@ -116,7 +116,7 @@ const checkVersionsMatch = () => { const braveVersionFromChromeFile = `${found[2]}.${found[3]}.${found[4]}` if (braveVersionFromChromeFile !== config.braveVersion) { // Only a warning. The CI environment will choose to proceed or not within its own script. - console.warn(`Version files do not match!\nsrc/chrome/VERSION: ${braveVersionFromChromeFile}\nbrave-browser package.json version: ${config.braveVersion}`) + console.warn(`Version files do not match!\nsrc/chrome/VERSION: ${braveVersionFromChromeFile}\nbrave-core package.json version: ${config.braveVersion}`) } } diff --git a/build/commands/lib/config.js b/build/commands/lib/config.js index ae3fb414ed2b..be4f3b5a8fbc 100755 --- a/build/commands/lib/config.js +++ b/build/commands/lib/config.js @@ -18,6 +18,7 @@ if (process.platform === 'win32') { dirName = fs.realpathSync.native(dirName) } const rootDir = path.resolve(dirName, '..', '..', '..', '..', '..') +const braveCoreDir = path.join(rootDir, 'src', 'brave') const run = (cmd, args = [], options) => { const prog = spawnSync(cmd, args, options) @@ -29,8 +30,7 @@ const run = (cmd, args = [], options) => { return prog } -// this is a huge hack because the npm config doesn't get passed through from brave-browser .npmrc/package.json -var packageConfig = function (key, sourceDir = rootDir) { +var packageConfig = function (key, sourceDir = braveCoreDir) { let packages = { config: {} } const configAbsolutePath = path.join(sourceDir, 'package.json') if (fs.existsSync(configAbsolutePath)) { @@ -48,10 +48,6 @@ var packageConfig = function (key, sourceDir = rootDir) { return obj } -var packageConfigBraveCore = function (key) { - return packageConfig(key, path.join(rootDir, 'src', 'brave')) -} - const getNPMConfig = (key, default_value = undefined) => { if (!NpmConfig) { const list = run(npmCommand, ['config', 'list', '--json'], { cwd: rootDir }) @@ -70,10 +66,6 @@ const getNPMConfig = (key, default_value = undefined) => { if (npmConfigDeprecatedValue !== undefined) return npmConfigDeprecatedValue - const packageConfigBraveCoreValue = packageConfigBraveCore(key) - if (packageConfigBraveCoreValue !== undefined) - return packageConfigBraveCoreValue - const packageConfigValue = packageConfig(key) if (packageConfigValue !== undefined) return packageConfigValue @@ -105,7 +97,7 @@ const Config = function () { this.srcDir = path.join(this.rootDir, 'src') this.chromeVersion = this.getProjectVersion('chrome') this.chromiumRepo = getNPMConfig(['projects', 'chrome', 'repository', 'url']) - this.braveCoreDir = path.join(this.srcDir, 'brave') + this.braveCoreDir = braveCoreDir this.buildToolsDir = path.join(this.srcDir, 'build') this.resourcesDir = path.join(this.rootDir, 'resources') this.depotToolsDir = path.join(this.braveCoreDir, 'vendor', 'depot_tools') @@ -155,9 +147,7 @@ const Config = function () { this.rewardsGrantProdEndpoint = getNPMConfig(['rewards_grant_prod_endpoint']) || '' // this.buildProjects() - // version should be taken from b-c package.json, not from brave-browser - // or npm config. - this.braveVersion = packageConfigBraveCore(['version']) || '0.0.0' + this.braveVersion = packageConfig(['version']) || '0.0.0' this.androidOverrideVersionName = this.braveVersion this.releaseTag = this.braveVersion.split('+')[0] diff --git a/script/download_rust_deps.py b/script/download_rust_deps.py index 5933a4e32d01..5daf43d55137 100755 --- a/script/download_rust_deps.py +++ b/script/download_rust_deps.py @@ -6,6 +6,7 @@ """Script to download rust_deps.""" import argparse +import deps import os import subprocess import sys @@ -13,18 +14,12 @@ try: from urllib2 import URLError except ImportError: # For Py3 compatibility - from urllib.error import URLError # pylint: disable=no-name-in-module,import-error + from urllib.error import URLError # pylint: disable=no-name-in-module,import-error -import deps from deps_config import DEPS_PACKAGES_URL, RUST_DEPS_PACKAGE_VERSION - -BRAVE_CORE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) - -BRAVE_BROWSER_ROOT = os.path.abspath( - os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) +from lib.config import BRAVE_CORE_ROOT RUSTUP_PATH = os.path.join(BRAVE_CORE_ROOT, 'build', 'rustup') - RUSTUP_HOME = os.path.join(RUSTUP_PATH, RUST_DEPS_PACKAGE_VERSION) @@ -89,8 +84,8 @@ def get_android_linker(target_arch): def make_standalone_toolchain_for_android(): - ANDROID_NDK_PATH = os.path.join( - BRAVE_BROWSER_ROOT, 'third_party', 'android_ndk') + ANDROID_NDK_PATH = os.path.join(os.path.dirname( + __file__), '..', '..', 'third_party', 'android_ndk') make_standalone_toolchain = os.path.join( ANDROID_NDK_PATH, 'build', 'tools', 'make_standalone_toolchain.py') diff --git a/script/lib/config.py b/script/lib/config.py index f2e380f1b6c6..416d15dd70d9 100644 --- a/script/lib/config.py +++ b/script/lib/config.py @@ -19,14 +19,7 @@ os.path.join(os.path.dirname(__file__), '..', '..', '..')) BRAVE_CORE_ROOT = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..')) -BRAVE_BROWSER_ROOT = os.path.abspath( - os.path.join(os.path.dirname(__file__), '..', '..', '..', '..')) -""" -SHALLOW_BRAVE_BROWSER_ROOT assumes the brave-browser directory is in the same -parent directory as brave-core -""" -SHALLOW_BRAVE_BROWSER_ROOT = os.path.abspath( - os.path.join(os.path.dirname(__file__), '..', '..', '..', 'brave-browser')) + verbose_mode = False @@ -46,28 +39,6 @@ def output_dir(target_os, target_arch): return os.path.join(CHROMIUM_ROOT, 'out', target_os_prefix + 'Release' + target_arch_suffix) -# Use brave-browser/package.json version for canonical version definition -def brave_browser_package(): - try: - pjson = os.path.join(BRAVE_BROWSER_ROOT, 'package.json') - with open(pjson) as f: - obj = json.load(f) - return obj - except IOError: - # When IOError exception is caught, try SHALLOW_BRAVE_BROWSER_ROOT next - try: - """ - SHALLOW_BRAVE_BROWSER_ROOT assumes the brave-browser directory is in the same - parent directory as brave-core - """ - pjson = os.path.join(SHALLOW_BRAVE_BROWSER_ROOT, 'package.json') - with open(pjson) as f: - obj = json.load(f) - return obj - except Exception as e: - exit("Error: cannot open file package.json: {}".format(e)) - - def brave_core_package(): pjson = os.path.join(BRAVE_CORE_ROOT, 'package.json') with open(pjson) as f: diff --git a/script/uplift.py b/script/uplift.py index a9d208596be2..d63c0bf9688d 100755 --- a/script/uplift.py +++ b/script/uplift.py @@ -169,7 +169,7 @@ def parse_args(): def get_remote_version(branch_to_compare): global config - decoded_file = get_file_contents(config.github_token, BRAVE_REPO, + decoded_file = get_file_contents(config.github_token, BRAVE_CORE_REPO, 'package.json', branch_to_compare) json_file = json.loads(decoded_file) return json_file['version'] @@ -205,8 +205,8 @@ def main(): return result # get all channel branches (starting at master) - brave_browser_version = get_remote_version('master') - remote_branches = get_remote_channel_branches(brave_browser_version) + brave_core_version = get_remote_version('master') + remote_branches = get_remote_channel_branches(brave_core_version) top_level_base = 'master' issues_fixed = []