Merge pull request #13241 from electron/test-releases

spec: run tests on release builds
This commit is contained in:
John Kleinschmidt 2018-06-14 15:14:02 -04:00 коммит произвёл GitHub
Родитель 91559191c9 832b5a36fa
Коммит fa79b40946
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 141 добавлений и 24 удалений

Просмотреть файл

@ -6,7 +6,7 @@ build-steps: &build-steps
command: | command: |
if [ -n "${RUN_RELEASE_BUILD}" ]; then if [ -n "${RUN_RELEASE_BUILD}" ]; then
echo 'release build triggered from api' echo 'release build triggered from api'
echo 'export ELECTRON_RELEASE=1 TRIGGERED_BY_API=1' >> $BASH_ENV echo 'export ELECTRON_RELEASE=1 UPLOAD_TO_S3=1' >> $BASH_ENV
fi fi
- run: - run:
name: Bootstrap name: Bootstrap
@ -43,10 +43,10 @@ build-steps: &build-steps
- run: - run:
name: Upload distribution name: Upload distribution
command: | command: |
if [ "$ELECTRON_RELEASE" == "1" ] && [ "$TRIGGERED_BY_API" != "1" ]; then if [ "$ELECTRON_RELEASE" == "1" ] && [ "$UPLOAD_TO_S3" != "1" ]; then
echo 'Uploading Electron release distribution to github releases' echo 'Uploading Electron release distribution to github releases'
script/upload.py script/upload.py
elif [ "$ELECTRON_RELEASE" == "1" ] && [ "$TRIGGERED_BY_API" == "1" ]; then elif [ "$ELECTRON_RELEASE" == "1" ] && [ "$UPLOAD_TO_S3" == "1" ]; then
echo 'Uploading Electron release distribution to s3' echo 'Uploading Electron release distribution to s3'
script/upload.py --upload_to_s3 script/upload.py --upload_to_s3
else else
@ -55,7 +55,7 @@ build-steps: &build-steps
- run: - run:
name: Setup for headless testing name: Setup for headless testing
command: | command: |
if [ "$ELECTRON_RELEASE" != "1" ] && [ "$RUN_HEADLESS_TESTS" == "true" ]; then if [ "$RUN_HEADLESS_TESTS" == "true" ]; then
echo 'Setup for headless testing' echo 'Setup for headless testing'
sh -e /etc/init.d/xvfb start sh -e /etc/init.d/xvfb start
else else
@ -67,30 +67,34 @@ build-steps: &build-steps
MOCHA_FILE: junit/test-results.xml MOCHA_FILE: junit/test-results.xml
MOCHA_REPORTER: mocha-junit-reporter MOCHA_REPORTER: mocha-junit-reporter
command: | command: |
if [ "$ELECTRON_RELEASE" != "1" ] && [ "$RUN_TESTS" == "true" ]; then if [ "$RUN_TESTS" == "true" ]; then
echo 'Testing Electron debug build' if [ "$ELECTRON_RELEASE" != "1" ]; then
mkdir junit echo 'Testing Electron debug build'
script/test.py --ci mkdir junit
else script/test.py --ci --rebuild_native_modules
if [ "$ELECTRON_RELEASE" == "1" ]; then
echo 'Skipping testing on release build'
else else
echo 'Skipping tests due to configuration' echo 'Testing Electron release build'
mkdir junit
script/test.py --ci --rebuild_native_modules -c R
fi fi
else
echo 'Skipping tests due to configuration'
fi fi
- run: - run:
name: Verify FFmpeg name: Verify FFmpeg
command: | command: |
if [ "$ELECTRON_RELEASE" != "1" ] && [ "$RUN_TESTS" == "true" ]; then if [ "$RUN_TESTS" == "true" ]; then
echo 'Verifying ffmpeg on debug build' if [ "$ELECTRON_RELEASE" != "1" ]; then
script/verify-ffmpeg.py echo 'Verifying ffmpeg on debug build'
else script/verify-ffmpeg.py
if [ "$ELECTRON_RELEASE" == "1" ]; then
echo 'Skipping verify ffmpeg on release build'
else else
echo 'Skipping tests due to configuration' echo 'Verifying ffmpeg on release build'
script/verify-ffmpeg.py -R
fi fi
else
echo 'Skipping tests due to configuration'
fi fi
- run: - run:
name: Generate Typescript Definitions name: Generate Typescript Definitions
command: | command: |
@ -311,3 +315,12 @@ workflows:
- electron-linux-arm64-release-nightly - electron-linux-arm64-release-nightly
- electron-linux-ia32-release-nightly - electron-linux-ia32-release-nightly
- electron-linux-x64-release-nightly - electron-linux-x64-release-nightly
experimental:
notify:
branches:
only:
- master
- 2-0-x
- 1-8-x
- 1-7-x

Просмотреть файл

@ -1,6 +1,7 @@
const assert = require('assert') const assert = require('assert')
const request = require('request') const request = require('request')
const buildAppVeyorURL = 'https://windows-ci.electronjs.org/api/builds' const buildAppVeyorURL = 'https://windows-ci.electronjs.org/api/builds'
const vstsURL = 'https://github.visualstudio.com/electron/_apis/build'
const circleCIJobs = [ const circleCIJobs = [
'electron-linux-arm', 'electron-linux-arm',
@ -10,6 +11,11 @@ const circleCIJobs = [
'electron-linux-x64' 'electron-linux-x64'
] ]
const vstsJobs = [
'electron-release-mas-x64',
'electron-release-osx-x64'
]
async function makeRequest (requestOptions, parseResponse) { async function makeRequest (requestOptions, parseResponse) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
request(requestOptions, (err, res, body) => { request(requestOptions, (err, res, body) => {
@ -62,7 +68,7 @@ async function circleCIcall (buildUrl, targetBranch, job, options) {
}, true).catch(err => { }, true).catch(err => {
console.log('Error calling CircleCI:', err) console.log('Error calling CircleCI:', err)
}) })
console.log(`Check ${circleResponse.build_url} for status. (${job})`) console.log(`CircleCI release build request for ${job} successful. Check ${circleResponse.build_url} for status.`)
} }
async function buildAppVeyor (targetBranch, options) { async function buildAppVeyor (targetBranch, options) {
@ -113,6 +119,70 @@ function buildCircleCI (targetBranch, options) {
} }
} }
async function buildVSTS (targetBranch, options) {
if (options.job) {
assert(vstsJobs.includes(options.job), `Unknown CI job name: ${options.job}.`)
}
console.log(`Triggering VSTS to run build on branch: ${targetBranch} with release flag.`)
assert(process.env.VSTS_TOKEN, 'VSTS_TOKEN not found in environment')
let environmentVariables = {}
if (!options.ghRelease) {
environmentVariables.UPLOAD_TO_S3 = 1
}
if (options.automaticRelease) {
environmentVariables.AUTO_RELEASE = 'true'
}
let requestOpts = {
url: `${vstsURL}/definitions?api-version=4.1`,
auth: {
user: '',
password: process.env.VSTS_TOKEN
},
headers: {
'Content-Type': 'application/json'
}
}
let vstsResponse = await makeRequest(requestOpts, true).catch(err => {
console.log('Error calling VSTS to get build definitions:', err)
})
let buildsToRun = []
if (options.job) {
buildsToRun = vstsResponse.value.filter(build => build.name === options.job)
} else {
buildsToRun = vstsResponse.value.filter(build => vstsJobs.includes(build.name))
}
buildsToRun.forEach((build) => callVSTSBuild(build, targetBranch, environmentVariables))
}
async function callVSTSBuild (build, targetBranch, environmentVariables) {
let buildBody = {
definition: build,
sourceBranch: targetBranch
}
if (Object.keys(environmentVariables).length !== 0) {
buildBody.parameters = JSON.stringify(environmentVariables)
}
let requestOpts = {
url: `${vstsURL}/builds?api-version=4.1`,
auth: {
user: '',
password: process.env.VSTS_TOKEN
},
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(buildBody),
method: 'POST'
}
let vstsResponse = await makeRequest(requestOpts, true).catch(err => {
console.log(`Error calling VSTS for job ${build.name}`, err)
})
console.log(`VSTS release build request for ${build.name} successful. Check ${vstsResponse._links.web.href} for status.`)
}
function runRelease (targetBranch, options) { function runRelease (targetBranch, options) {
if (options.ci) { if (options.ci) {
switch (options.ci) { switch (options.ci) {
@ -124,10 +194,19 @@ function runRelease (targetBranch, options) {
buildAppVeyor(targetBranch, options) buildAppVeyor(targetBranch, options)
break break
} }
case 'VSTS': {
buildVSTS(targetBranch, options)
break
}
default: {
console.log(`Error! Unknown CI: ${options.ci}.`)
process.exit(1)
}
} }
} else { } else {
buildCircleCI(targetBranch, options) buildCircleCI(targetBranch, options)
buildAppVeyor(targetBranch, options) buildAppVeyor(targetBranch, options)
buildVSTS(targetBranch, options)
} }
} }
@ -140,7 +219,7 @@ if (require.main === module) {
const targetBranch = args._[0] const targetBranch = args._[0]
if (args._.length < 1) { if (args._.length < 1) {
console.log(`Trigger CI to build release builds of electron. console.log(`Trigger CI to build release builds of electron.
Usage: ci-release-build.js [--job=CI_JOB_NAME] [--ci=CircleCI|AppVeyor] [--ghRelease] [--automaticRelease] TARGET_BRANCH Usage: ci-release-build.js [--job=CI_JOB_NAME] [--ci=CircleCI|AppVeyor|VSTS] [--ghRelease] [--automaticRelease] TARGET_BRANCH
`) `)
process.exit(0) process.exit(0)
} }

Просмотреть файл

@ -212,6 +212,7 @@ def create_release_draft(github, tag):
def upload_electron(github, release, file_path, args): def upload_electron(github, release, file_path, args):
filename = os.path.basename(file_path)
# if upload_to_s3 is set, skip github upload. # if upload_to_s3 is set, skip github upload.
if args.upload_to_s3: if args.upload_to_s3:
@ -221,10 +222,11 @@ def upload_electron(github, release, file_path, args):
s3put(bucket, access_key, secret_key, os.path.dirname(file_path), s3put(bucket, access_key, secret_key, os.path.dirname(file_path),
key_prefix, [file_path]) key_prefix, [file_path])
upload_sha256_checksum(release['tag_name'], file_path, key_prefix) upload_sha256_checksum(release['tag_name'], file_path, key_prefix)
s3url = 'https://gh-contractor-zcbenz.s3.amazonaws.com'
print '{0} uploaded to {1}/{2}/{0}'.format(filename, s3url, key_prefix)
return return
# Delete the original file before uploading in CI. # Delete the original file before uploading in CI.
filename = os.path.basename(file_path)
if os.environ.has_key('CI'): if os.environ.has_key('CI'):
try: try:
for asset in release['assets']: for asset in release['assets']:

Просмотреть файл

@ -33,7 +33,7 @@ steps:
condition: and(succeeded(), eq(variables['ELECTRON_RELEASE'], '1')) condition: and(succeeded(), eq(variables['ELECTRON_RELEASE'], '1'))
- bash: | - bash: |
if [ "$TRIGGERED_BY_API" != "1" ]; then if [ "$UPLOAD_TO_S3" != "1" ]; then
echo 'Uploading Electron release distribution to github releases' 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 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 else
@ -48,16 +48,31 @@ steps:
mkdir junit mkdir junit
export MOCHA_FILE="junit/test-results.xml" export MOCHA_FILE="junit/test-results.xml"
export MOCHA_REPORTER="mocha-junit-reporter" export MOCHA_REPORTER="mocha-junit-reporter"
script/test.py --ci script/test.py --ci --rebuild_native_modules
name: Test name: Test
condition: and(succeeded(), ne(variables['ELECTRON_RELEASE'], '1')) condition: and(succeeded(), ne(variables['ELECTRON_RELEASE'], '1'))
- bash: |
echo 'Testing Electron release build'
mkdir junit
export MOCHA_FILE="junit/test-results.xml"
export MOCHA_REPORTER="mocha-junit-reporter"
script/test.py --ci --rebuild_native_modules -c R
name: Test
condition: and(succeeded(), eq(variables['ELECTRON_RELEASE'], '1'))
- bash: | - bash: |
echo 'Verifying ffmpeg on debug build' echo 'Verifying ffmpeg on debug build'
script/verify-ffmpeg.py script/verify-ffmpeg.py
name: Verify_FFmpeg name: Verify_FFmpeg
condition: and(succeeded(), ne(variables['ELECTRON_RELEASE'], '1')) condition: and(succeeded(), ne(variables['ELECTRON_RELEASE'], '1'))
- bash: |
echo 'Verifying ffmpeg on release build'
script/verify-ffmpeg.py -R
name: Verify_FFmpeg
condition: and(succeeded(), eq(variables['ELECTRON_RELEASE'], '1'))
- task: PublishTestResults@2 - task: PublishTestResults@2
displayName: Publish Test Results displayName: Publish Test Results
inputs: inputs:
@ -65,4 +80,12 @@ steps:
searchFolder: junit searchFolder: junit
condition: and(always(), ne(variables['ELECTRON_RELEASE'], '1')) condition: and(always(), ne(variables['ELECTRON_RELEASE'], '1'))
- task: kasunkodagoda.slack-notification.slack-notification-task.SlackNotification@3
displayName: Post Slack Notification
inputs:
SlackApiToken: '$(slack_token)'
Channel: '#bot-nightly-releases'
Message: '$(Build.DefinitionName)-$(Build.BuildNumber) finished with a $(Agent.JobStatus) status.'
condition: and(always(), eq(variables['Build.Reason'], 'Schedule'))
- task: mspremier.PostBuildCleanup.PostBuildCleanup-task.PostBuildCleanup@3 - task: mspremier.PostBuildCleanup.PostBuildCleanup-task.PostBuildCleanup@3