ci: on azure pipelines split coveralls and ci:full invocation scripts, run each script conditionally

This commit is contained in:
Michael Bradley, Jr 2019-05-01 09:54:42 -05:00 committed by Michael Bradley
parent fbfe376101
commit 4c4c8ed1d6
2 changed files with 39 additions and 14 deletions

View File

@ -31,11 +31,13 @@ pool:
steps: steps:
- task: NodeTool@0 - task: NodeTool@0
condition: succeeded()
displayName: 'Install Node.js' displayName: 'Install Node.js'
inputs: inputs:
versionSpec: $(nodeVersion) versionSpec: $(nodeVersion)
- task: UsepythonVersion@0 - task: UsepythonVersion@0
condition: succeeded()
displayName: 'Install Python' displayName: 'Install Python'
inputs: inputs:
architecture: x64 architecture: x64
@ -62,12 +64,14 @@ steps:
else else
tar xzvf go-ipfs.tar.gz tar xzvf go-ipfs.tar.gz
fi fi
condition: succeeded()
displayName: 'Install IPFS' displayName: 'Install IPFS'
- bash: | - bash: |
export PATH="$(cd ../Downloads && pwd)/go-ipfs:${PATH}" export PATH="$(cd ../Downloads && pwd)/go-ipfs:${PATH}"
ipfs version ipfs version
ipfs init ipfs init
condition: succeeded()
displayName: 'Initialize IPFS' displayName: 'Initialize IPFS'
- bash: | - bash: |
@ -75,6 +79,7 @@ steps:
export PATH="${HOME}/.yarn/bin:${HOME}/.config/yarn/global/node_modules/.bin:${PATH}" export PATH="${HOME}/.yarn/bin:${HOME}/.config/yarn/global/node_modules/.bin:${PATH}"
yarn --version yarn --version
mkdir -p ../Downloads/Yarn mkdir -p ../Downloads/Yarn
condition: succeeded()
displayName: 'Install Yarn' displayName: 'Install Yarn'
- bash: | - bash: |
@ -85,16 +90,7 @@ steps:
yarn config set cache-folder "${PWD}/Yarn" &>/dev/null yarn config set cache-folder "${PWD}/Yarn" &>/dev/null
popd &>/dev/null popd &>/dev/null
npm run ci:full npm run ci:full
if [[ "$AGENT_OS" = "Linux" ]]; then condition: and( succeeded(), ne( variables['Agent.OS'], 'Windows_NT' ) )
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)' displayName: 'Test (*nix)'
- powershell: | - powershell: |
@ -105,8 +101,25 @@ steps:
yarn config set cache-folder "$($PWD.Path)\Yarn" | out-null yarn config set cache-folder "$($PWD.Path)\Yarn" | out-null
popd popd
npm run ci:full npm run ci:full
$env:COVERALLS_GIT_BRANCH=node scripts/coveralls-branch-name condition: and( succeeded(), eq( variables['Agent.OS'], 'Windows_NT' ) )
$env:COVERALLS_SERVICE_NAME="Azure Pipelines (Windows)"
npm run coveralls
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: 'Test (Windows)' displayName: 'Test (Windows)'
- bash: |
if [[ "$AGENT_OS" = "Linux" ]]; then
OS="Linux"
fi
if [[ "$AGENT_OS" = "Darwin" ]]; then
OS="macOS"
fi
if [[ "$AGENT_OS" = "Windows_NT" ]]; then
OS="Windows"
fi
export CI_PULL_REQUEST=$(node scripts/coveralls-pr-id)
if [[ -z "$CI_PULL_REQUEST" ]]; then
unset CI_PULL_REQUEST
fi
export COVERALLS_GIT_BRANCH=$(node scripts/coveralls-branch-name)
export COVERALLS_SERVICE_NAME="Azure Pipelines (${OS})"
npm run coveralls
condition: succeeded()
displayName: 'Coveralls'

View File

@ -0,0 +1,12 @@
/* global process require */
const {execSync} = require('child_process');
let branchName = execSync('git name-rev --name-only HEAD').toString().trim();
let prId = '';
if (branchName.startsWith('remotes/pull')) {
prId = branchName.split('/')[2];
}
process.stdout.write(prId);