enhance ci

This commit is contained in:
Pig Fang 2019-02-18 11:53:27 +08:00
parent 0a21090dca
commit 083a0a2895
3 changed files with 26 additions and 15 deletions

View File

@ -4,6 +4,7 @@ jobs:
pool:
vmImage: 'Ubuntu-16.04'
strategy:
parallel: 3
matrix:
'7.1':
phpVersion: 7.1
@ -25,13 +26,6 @@ jobs:
php -version
displayName: 'Use PHP version $(phpVersion)'
- task: DownloadPipelineArtifact@0
continueOnError: true
inputs:
artifactName: php-vendor-$(phpVersion)
targetPath: vendor
pipelineId: $($(Build.BuildId) - 1)
- script: composer install --no-interaction --prefer-dist
displayName: 'composer install'
@ -40,9 +34,10 @@ jobs:
php artisan key:random
php artisan salt:random
mysql -uroot -proot -e 'CREATE DATABASE IF NOT EXISTS test;'
mkdir junitReports
displayName: 'Prepare testing environment'
- script: ./vendor/bin/phpunit --log-junit junit.xml
- script: node scripts/distribute-test.js
displayName: Test
- task: PublishTestResults@2
@ -51,12 +46,6 @@ jobs:
testRunner: JUnit
testResultsFiles: './junit.xml'
- task: PublishPipelineArtifact@0
continueOnError: true
inputs:
artifactName: php-vendor-$(phpVersion)
targetPath: vendor
- job: javascript
displayName: JavaScript
pool:
@ -88,7 +77,7 @@ jobs:
- script: yarn
displayName: Install dependencies
- script: mkdir dist
- script: yarn release dist/blessing-skin-server.zip
- script: yarn release dist/blessing-skin-server.zip --ci
displayName: Generate package
- task: PublishPipelineArtifact@0
inputs:

View File

@ -0,0 +1,21 @@
const execa = require('execa');
const TOTAL_AGENTS = +process.env.SYSTEM_TOTALJOBSINPHASE || 1;
const AGENT_NUMBER = +process.env.SYSTEM_JOBPOSITIONINPHASE || 1;
const tests = execa
.sync('./vendor/bin/phpunit', ['--list-tests'])
.stdout
.split(/\r?\n/)
.filter(line => line.startsWith(' - Tests'))
.map(line => line.replace(' - Tests\\', ''));
const toBeRun = [];
for (let i = AGENT_NUMBER, length = tests.length; i <= length; i = i + TOTAL_AGENTS) {
toBeRun.push(test[i - 1]);
}
execa('./vendor/bin/phpunit', [
`--filter='(${toBeRun.join('|')})'`,
`--log-junit=./junitReports/junit_${AGENT_NUMBER}.xml`
]).stdout.pipe(process.stdout);

View File

@ -47,6 +47,7 @@ const tasks = new Listr([
},
{
title: 'Install PHP dependencies for development',
enabled: () => !process.argv.includes('--ci'),
task: () => execa('composer', ['install'])
},
]);