Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove need for brave-browser repo #13006

Merged
merged 1 commit into from
Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 1 addition & 31 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]
mihaiplesa marked this conversation as resolved.
Show resolved Hide resolved
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') {
Expand Down Expand Up @@ -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)
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions build/commands/lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand All @@ -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}`)
}
}

Expand Down
18 changes: 4 additions & 14 deletions build/commands/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
mihaiplesa marked this conversation as resolved.
Show resolved Hide resolved
let packages = { config: {} }
const configAbsolutePath = path.join(sourceDir, 'package.json')
if (fs.existsSync(configAbsolutePath)) {
Expand All @@ -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 })
Expand All @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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]
Expand Down
15 changes: 5 additions & 10 deletions script/download_rust_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,20 @@
"""Script to download rust_deps."""

import argparse
import deps
import os
import subprocess
import sys

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)


Expand Down Expand Up @@ -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')
Expand Down
31 changes: 1 addition & 30 deletions script/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions script/uplift.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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 = []

Expand Down