ci: Move Mac builds to Azure Devops (VSTS) (#14588)

* Add support for multiple mocha reporters

Allows us to output to junit file and to console at the same time

* Cleanup VSTS file

Don't install depot_tools everytime as it is already installed.

Only run tests if "RUN_TESTS" environment variable is set
Only notify slack if "NOTIFY_SLACK" environment variable is set

Don't use sccache for release builds

Move CircleCI mac builds to VSTS

* Only build mac PRS from forks

Don't install depot_tools everytime as it is already installed.

Only run tests if "RUN_TESTS" environment variable is set
Only notify slack if "NOTIFY_SLACK" environment variable is set

Don't use sccache for release builds

Move CircleCI mac builds to VSTS

Use sccache helper script

* rename vsts-gn.yml to vsts.yml
Make sure Electron isn't running before starting tests
This commit is contained in:
John Kleinschmidt 2018-09-14 14:56:16 -04:00 коммит произвёл Jeremy Apthorp
Родитель 451b1782ac
Коммит 838b26ee26
4 изменённых файлов: 80 добавлений и 94 удалений

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

@ -112,8 +112,9 @@ build-steps: &build-steps
- run: - run:
name: Test name: Test
environment: environment:
MOCHA_REPORTER: mocha-junit-reporter MOCHA_REPORTER: mocha-multi-reporters
MOCHA_FILE: junit/test-results.xml MOCHA_FILE: junit/test-results.xml
MOCHA_MULTI_REPORTERS: mocha-junit-reporter, tap
ELECTRON_DISABLE_SECURITY_WARNINGS: 1 ELECTRON_DISABLE_SECURITY_WARNINGS: 1
command: | command: |
if [ "$RUN_TESTS" != "false" ]; then if [ "$RUN_TESTS" != "false" ]; then
@ -189,8 +190,9 @@ mac-build-steps: &mac-build-steps
- run: - run:
name: Test name: Test
environment: environment:
MOCHA_REPORTER: mocha-junit-reporter MOCHA_REPORTER: mocha-multi-reporters
MOCHA_FILE: junit/test-results.xml MOCHA_FILE: junit/test-results.xml
MOCHA_MULTI_REPORTERS: mocha-junit-reporter, tap
ELECTRON_DISABLE_SECURITY_WARNINGS: 1 ELECTRON_DISABLE_SECURITY_WARNINGS: 1
command: | command: |
if [ "$RUN_TESTS" != "false" ]; then if [ "$RUN_TESTS" != "false" ]; then
@ -338,49 +340,15 @@ jobs:
<<: *linux-build-machine <<: *linux-build-machine
<<: *build-steps <<: *build-steps
electron-osx-release:
environment:
GN_CONFIG: //electron/build/args/release.gn
RUN_TESTS: true
NIGHTLY_BUILD: true
<<: *mac-build-machine
<<: *mac-build-steps
electron-osx-testing: electron-osx-testing:
environment: environment:
GN_CONFIG: //electron/build/args/testing.gn GN_CONFIG: //electron/build/args/testing.gn
RUN_TESTS: true
<<: *mac-build-machine
<<: *mac-build-steps
electron-osx-debug:
environment:
GN_CONFIG: //electron/build/args/debug.gn
RUN_TESTS: false
<<: *mac-build-machine
<<: *mac-build-steps
electron-mas-release:
environment:
GN_CONFIG: //electron/build/args/release.gn
RUN_TESTS: true
GN_EXTRA_ARGS: 'is_mas_build = true'
NIGHTLY_BUILD: true
<<: *mac-build-machine <<: *mac-build-machine
<<: *mac-build-steps <<: *mac-build-steps
electron-mas-testing: electron-mas-testing:
environment: environment:
GN_CONFIG: //electron/build/args/testing.gn GN_CONFIG: //electron/build/args/testing.gn
RUN_TESTS: true
GN_EXTRA_ARGS: 'is_mas_build = true'
<<: *mac-build-machine
<<: *mac-build-steps
electron-mas-debug:
environment:
GN_CONFIG: //electron/build/args/debug.gn
RUN_TESTS: false
GN_EXTRA_ARGS: 'is_mas_build = true' GN_EXTRA_ARGS: 'is_mas_build = true'
<<: *mac-build-machine <<: *mac-build-machine
<<: *mac-build-steps <<: *mac-build-steps
@ -397,12 +365,19 @@ workflows:
- electron-linux-arm-testing - electron-linux-arm-testing
- electron-linux-arm64-debug - electron-linux-arm64-debug
- electron-linux-arm64-testing - electron-linux-arm64-testing
build-mac:
build-mac-fork-prs:
jobs: jobs:
- electron-mas-debug - electron-mas-testing:
- electron-mas-testing filters:
- electron-osx-debug branches:
- electron-osx-testing # only from forks
only: /^pull\/.*$/
- electron-osx-testing:
filters:
branches:
# only from forks
only: /^pull\/.*$/
nightly-release-test: nightly-release-test:
triggers: triggers:
@ -417,5 +392,3 @@ workflows:
- electron-linux-ia32-release - electron-linux-ia32-release
- electron-linux-arm-release - electron-linux-arm-release
- electron-linux-arm64-release - electron-linux-arm64-release
- electron-mas-release
- electron-osx-release

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

@ -15,6 +15,7 @@
"mkdirp": "^0.5.1", "mkdirp": "^0.5.1",
"mocha": "^5.2.0", "mocha": "^5.2.0",
"mocha-junit-reporter": "^1.17.0", "mocha-junit-reporter": "^1.17.0",
"mocha-multi-reporters": "^1.1.7",
"multiparty": "^4.1.4", "multiparty": "^4.1.4",
"q": "^1.5.1", "q": "^1.5.1",
"send": "^0.16.2", "send": "^0.16.2",

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

@ -43,10 +43,16 @@
const { Coverage } = require('electabul') const { Coverage } = require('electabul')
const Mocha = require('mocha') const Mocha = require('mocha')
const mochaOptions = {}
const mocha = new Mocha(process.env.MOCHA_REPORTER if (process.env.MOCHA_REPORTER) {
? { reporter: process.env.MOCHA_REPORTER } mochaOptions.reporter = process.env.MOCHA_REPORTER
: undefined) }
if (process.env.MOCHA_MULTI_REPORTERS) {
mochaOptions.reporterOptions = {
reporterEnabled: process.env.MOCHA_MULTI_REPORTERS
}
}
const mocha = new Mocha(mochaOptions)
if (!process.env.MOCHA_REPORTER) { if (!process.env.MOCHA_REPORTER) {
mocha.ui('bdd').reporter(isCi ? 'tap' : 'html') mocha.ui('bdd').reporter(isCi ? 'tap' : 'html')

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

@ -1,16 +1,10 @@
resources: jobs:
- repo: self - job: Build_Electron_via_GN
phases: timeoutInMinutes: 180
- phase: Build_Electron_via_GN
queue:
timeoutInMinutes: 180
steps: steps:
- bash: | - bash: |
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git "${AGENT_BUILDDIRECTORY}/depot_tools" export PATH="$PATH:/Users/electron/depot_tools"
echo "##vso[task.setvariable variable=PATH]$PATH:${AGENT_BUILDDIRECTORY}/depot_tools" echo "##vso[task.setvariable variable=PATH]$PATH"
name: Setup_depot_tools
- bash: |
export GIT_CACHE_PATH="/Users/electron/libcc_cache" export GIT_CACHE_PATH="/Users/electron/libcc_cache"
set -ex set -ex
gclient config \ gclient config \
@ -26,71 +20,83 @@ phases:
# better solution for checking out the commit to be built. # better solution for checking out the commit to be built.
(cd src/electron; git fetch origin +"${BUILD_SOURCEBRANCH}"; git checkout "${BUILD_SOURCEVERSION}") (cd src/electron; git fetch origin +"${BUILD_SOURCEBRANCH}"; git checkout "${BUILD_SOURCEVERSION}")
gclient sync --with_branch_heads --with_tags gclient sync --with_branch_heads --with_tags
name: gclient_sync
- bash: |
cd src cd src
export CHROMIUM_BUILDTOOLS_PATH=`pwd`/buildtools export CHROMIUM_BUILDTOOLS_PATH=`pwd`/buildtools
echo "##vso[task.setvariable variable=CHROMIUM_BUILDTOOLS_PATH]`pwd`/buildtools"
displayName: gclient sync
- bash: |
cd src
export SCCACHE_BINARY="`pwd`/electron/external_binaries/sccache" export SCCACHE_BINARY="`pwd`/electron/external_binaries/sccache"
# SCCACHE_AZURE_BLOB_CONTAINER and SCCACHE_AZURE_CONNECTION_STRING are expected to be set.
"$SCCACHE_BINARY" --start-server "$SCCACHE_BINARY" --start-server
echo "##vso[task.setvariable variable=SCCACHE_BINARY]$SCCACHE_BINARY" echo "##vso[task.setvariable variable=SCCACHE_BINARY]$SCCACHE_BINARY"
echo "##vso[task.setvariable variable=CHROMIUM_BUILDTOOLS_PATH]$CHROMIUM_BUILDTOOLS_PATH"
echo "GN gen for: $GN_CONFIG"
gn gen out/Default --args='import("'$GN_CONFIG'") cc_wrapper="'"$SCCACHE_BINARY"'"'
name: GN_gen
- bash: |
cd src
ninja -C out/Default electron:electron_app
name: Ninja_build
- bash: |
"$SCCACHE_BINARY" -s "$SCCACHE_BINARY" -s
"$SCCACHE_BINARY" --stop-server echo "GN gen for: $GN_CONFIG"
name: Check_sccache_stats gn gen out/Default --args='import("'$GN_CONFIG'") cc_wrapper="'"$SCCACHE_BINARY"'"'" $GN_EXTRA_ARGS"
env:
- bash: | AWS_ACCESS_KEY_ID: $(SCCACHE_AWS_ACCESS_KEY)
set +e AWS_SECRET_ACCESS_KEY: $(SCCACHE_AWS_SECRET)
cd src displayName: GN gen with sccache
ninja -C out/Default third_party/electron_node:headers
export npm_config_nodedir="$PWD/out/Default/gen/node_headers"
(cd electron/spec && npm install)
./out/Default/Electron.app/Contents/MacOS/Electron electron/spec --ci --enable-logging
name: Test
condition: and(succeeded(), ne(variables['ELECTRON_RELEASE'], '1')) condition: and(succeeded(), ne(variables['ELECTRON_RELEASE'], '1'))
- bash: | - bash: |
cd src cd src
ninja -C out/Default electron:electron_dist_zip echo "GN gen for: $GN_CONFIG"
name: Build_dist_zip gn gen out/Default --args='import("'$GN_CONFIG'")'" $GN_EXTRA_ARGS"
displayName: GN gen without sccache
condition: and(succeeded(), eq(variables['ELECTRON_RELEASE'], '1')) condition: and(succeeded(), eq(variables['ELECTRON_RELEASE'], '1'))
- bash: |
cd src
ninja -C out/Default electron:electron_app
displayName: Ninja build app
- bash: |
"$SCCACHE_BINARY" --stop-server
displayName: Check sccache stats after build
condition: and(succeeded(), ne(variables['ELECTRON_RELEASE'], '1'))
- bash: |
set +e
cd src
# Make sure there aren't any Electron processes left running from previous tests
killall Electron
ninja -C out/Default third_party/electron_node:headers
export ELECTRON_OUT_DIR=Default
(cd electron && npm run test -- --ci --enable-logging)
displayName: Test
condition: and(succeeded(), eq(variables['RUN_TESTS'], '1'))
- bash: |
cd src
ninja -C out/Default electron:electron_dist_zip
displayName: Build dist zip
- task: PublishTestResults@2 - task: PublishTestResults@2
displayName: Publish Test Results displayName: Publish Test Results
inputs: inputs:
testResultsFiles: '**/test-*.xml' testResultsFiles: '*.xml'
condition: and(always(), eq(variables['MOCHA_FILE'], 'junit/test-results.xml'), ne(variables['ELECTRON_RELEASE'], '1')) searchFolder: '$(System.DefaultWorkingDirectory)/src/junit/'
condition: and(always(), eq(variables['MOCHA_FILE'], 'junit/test-results.xml'), eq(variables['RUN_TESTS'], '1'))
- task: PublishBuildArtifacts@1 - task: PublishBuildArtifacts@1
displayName: Publish Build Artifacts displayName: Publish Build Artifacts
inputs: inputs:
PathtoPublish: '$(Build.SourcesDirectory)/out/Default/dist.zip' PathtoPublish: '$(System.DefaultWorkingDirectory)/src/out/Default/dist.zip'
ArtifactName: dist.zip ArtifactName: dist.zip
condition: and(succeeded(), eq(variables['ELECTRON_RELEASE'], '1'))
- bash: | - bash: |
export BUILD_URL="${SYSTEM_TEAMFOUNDATIONCOLLECTIONURI}${SYSTEM_TEAMPROJECT}/_build/results?buildId=${BUILD_BUILDID}" export BUILD_URL="${SYSTEM_TEAMFOUNDATIONCOLLECTIONURI}${SYSTEM_TEAMPROJECT}/_build/results?buildId=${BUILD_BUILDID}"
export MESSAGE="Build failed for *<$BUILD_URL|$BUILD_DEFINITIONNAME>* nightly build." export MESSAGE="Build failed for *<$BUILD_URL|$BUILD_DEFINITIONNAME>* nightly build."
curl -g -H "Content-Type: application/json" -X POST \ curl -g -H "Content-Type: application/json" -X POST \
-d "{\"text\": \"$MESSAGE\", \"attachments\": [{\"color\": \"#FC5C3C\",\"title\": \"$BUILD_DEFINITIONNAME nightly build results\",\"title_link\": \"$BUILD_URL\"}]}" $(slack_webhook) -d "{\"text\": \"$MESSAGE\", \"attachments\": [{\"color\": \"#FC5C3C\",\"title\": \"$BUILD_DEFINITIONNAME nightly build results\",\"title_link\": \"$BUILD_URL\"}]}" $(slack_webhook)
name: Post_Slack_Notification_on_Failure displayName: 'Post Slack Notification on Failure'
condition: failed() condition: and(failed(), eq(variables['NOTIFY_SLACK'], '1'))
- bash: | - bash: |
export BUILD_URL="${SYSTEM_TEAMFOUNDATIONCOLLECTIONURI}${SYSTEM_TEAMPROJECT}/_build/results?buildId=${BUILD_BUILDID}" export BUILD_URL="${SYSTEM_TEAMFOUNDATIONCOLLECTIONURI}${SYSTEM_TEAMPROJECT}/_build/results?buildId=${BUILD_BUILDID}"
export MESSAGE="Build succeeded for *<$BUILD_URL|$BUILD_DEFINITIONNAME>* nightly build." export MESSAGE="Build succeeded for *<$BUILD_URL|$BUILD_DEFINITIONNAME>* nightly build."
curl -g -H "Content-Type: application/json" -X POST \ curl -g -H "Content-Type: application/json" -X POST \
-d "{\"text\": \"$MESSAGE\", \"attachments\": [{\"color\": \"good\",\"title\": \"$BUILD_DEFINITIONNAME nightly build results\",\"title_link\": \"$BUILD_URL\"}]}" $(slack_webhook) -d "{\"text\": \"$MESSAGE\", \"attachments\": [{\"color\": \"good\",\"title\": \"$BUILD_DEFINITIONNAME nightly build results\",\"title_link\": \"$BUILD_URL\"}]}" $(slack_webhook)
name: Post_Slack_Notification_on_Success displayName: 'Post Slack Notification on Success'
condition: succeeded() condition: and(succeeded(), eq(variables['NOTIFY_SLACK'], '1'))