ci: revise azure pipelines config to report branch and service name to coveralls

This commit is contained in:
Michael Bradley, Jr 2019-04-30 16:47:56 -05:00 committed by Michael Bradley
parent e5fc9ffdf6
commit b5a9553599
2 changed files with 27 additions and 0 deletions

View File

@ -85,6 +85,14 @@ steps:
yarn config set cache-folder "${PWD}/Yarn" &>/dev/null
popd &>/dev/null
npm run ci:full
if [[ "$AGENT_OS" = "Linux" ]]; then
OS="Linux"
fi
if [[ "$AGENT_OS" = "Darwin" ]]; then
OS="macOS"
fi
export COVERALLS_GIT_BRANCH=$(node scripts/coveralls-branch-name)
export COVERALLS_SERVICE_NAME="Azure Pipelines (${OS})"
npm run coveralls
condition: ne( variables['Agent.OS'], 'Windows_NT' )
displayName: 'Test (*nix)'
@ -97,6 +105,8 @@ steps:
yarn config set cache-folder "$($PWD.Path)\Yarn" | out-null
popd
npm run ci:full
$env:COVERALLS_GIT_BRANCH=node scripts/coveralls-branch-name
$env:COVERALLS_SERVICE_NAME="Azure Pipelines (Windows)"
npm run coveralls
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: 'Test (Windows)'

View File

@ -0,0 +1,17 @@
/* global process require */
const {execSync} = require('child_process');
const nameRevCmd = 'git name-rev --name-only HEAD';
let branchName = execSync(nameRevCmd).toString().trim();
if (branchName.startsWith('remotes/pull')) {
execSync('git checkout "HEAD^2"', {stdio: 'ignore'});
const _branchName = branchName;
branchName = execSync(nameRevCmd).toString().trim().split('/').slice(2).join('/');
execSync(`git checkout ${_branchName}`, {stdio: 'ignore'});
} else if (branchName.startsWith('remotes/origin')) {
branchName = branchName.split('/').slice(2).join('/');
}
process.stdout.write(branchName);