mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-09-11 20:27:17 +03:00
Add: 'gulp test' which will run UTs inside a container. Clean up gulpfile
This commit is contained in:
parent
c4f75ad16a
commit
1ed4647798
12
build/Dockerfile
Normal file
12
build/Dockerfile
Normal file
@ -0,0 +1,12 @@
|
||||
FROM node:8.9
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y xorg xvfb libxss-dev libgtk2.0-0 gconf2 libnss3 libasound2
|
||||
|
||||
ENV CXX="g++-4.9"
|
||||
ENV CC="gcc-4.9"
|
||||
ENV DISPLAY=:99.0
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENTRYPOINT ["sh", "-c", "(Xvfb $DISPLAY -screen 0 1024x768x16 &) && npm run test"]
|
120
gulpfile.js
120
gulpfile.js
@ -1,63 +1,32 @@
|
||||
var gulp = require('gulp'),
|
||||
bump = require('gulp-bump'),
|
||||
git = require('gulp-git'),
|
||||
inject = require('gulp-inject-string'),
|
||||
merge = require('merge-stream'),
|
||||
tag_version = require('gulp-tag-version'),
|
||||
ts = require('gulp-typescript'),
|
||||
tslint = require('gulp-tslint'),
|
||||
filter = require('gulp-filter'),
|
||||
shell = require('gulp-shell'),
|
||||
exec = require('child_process').exec;
|
||||
|
||||
var paths = {
|
||||
src_ts: 'src/**/*.ts',
|
||||
tests_ts: 'test/**/*.ts',
|
||||
};
|
||||
|
||||
function versionBump(semver) {
|
||||
return gulp
|
||||
.src(['./package.json', './package-lock.json'])
|
||||
.pipe(bump({ type: semver }))
|
||||
.pipe(gulp.dest('./'))
|
||||
.pipe(git.commit('bump version'))
|
||||
.pipe(filter('package.json'))
|
||||
.pipe(tag_version());
|
||||
}
|
||||
git = require('gulp-git'),
|
||||
tag_version = require('gulp-tag-version'),
|
||||
tslint = require('gulp-tslint'),
|
||||
ts = require('gulp-typescript');
|
||||
|
||||
// compile
|
||||
gulp.task('compile', function(){
|
||||
var tsProject = ts.createProject('./tsconfig.json');
|
||||
return tsProject.src().pipe(tsProject()).js.pipe(gulp.dest('out'));
|
||||
});
|
||||
|
||||
// tslint
|
||||
gulp.task('tslint', function() {
|
||||
var tslintOptions = {
|
||||
summarizeFailureOutput: true,
|
||||
};
|
||||
|
||||
var srcs = gulp
|
||||
.src(paths.src_ts)
|
||||
return gulp
|
||||
.src([
|
||||
'**/*.ts',
|
||||
'!node_modules/**',
|
||||
'!typings/**',
|
||||
])
|
||||
.pipe(tslint({ formatter: 'verbose' }))
|
||||
.pipe(tslint.report(tslintOptions));
|
||||
var tests = gulp
|
||||
.src(paths.tests_ts)
|
||||
.pipe(tslint({ formatter: 'verbose' }))
|
||||
.pipe(tslint.report(tslintOptions));
|
||||
return merge(srcs, tests);
|
||||
});
|
||||
|
||||
gulp.task('prettier', function() {
|
||||
runPrettier('git diff --name-only HEAD');
|
||||
});
|
||||
|
||||
gulp.task('forceprettier', function() {
|
||||
// files managed by git
|
||||
runPrettier('git ls-files');
|
||||
// untracked files
|
||||
runPrettier('git ls-files --others --exclude-standard');
|
||||
.pipe(tslint.report({ summarizeFailureOutput: true }));
|
||||
});
|
||||
|
||||
// prettier
|
||||
function runPrettier(command) {
|
||||
let exec = require('child_process').exec;
|
||||
exec(command, function(err, stdout, stderr) {
|
||||
const files = stdout.split('\n');
|
||||
for (const file of files) {
|
||||
@ -70,14 +39,71 @@ function runPrettier(command) {
|
||||
});
|
||||
}
|
||||
|
||||
gulp.task('default', ['prettier', 'tslint', 'compile']);
|
||||
gulp.task('prettier', function() {
|
||||
runPrettier('git diff --name-only HEAD');
|
||||
});
|
||||
|
||||
gulp.task('forceprettier', function() {
|
||||
// files managed by git
|
||||
runPrettier('git ls-files');
|
||||
// untracked files
|
||||
runPrettier('git ls-files --others --exclude-standard');
|
||||
});
|
||||
|
||||
|
||||
// test
|
||||
gulp.task('test', function(cb) {
|
||||
let spawn = require('child_process').spawn;
|
||||
|
||||
const dockerTag = 'vscodevim'
|
||||
|
||||
console.log("Building container...")
|
||||
let dockerBuildCmd = spawn('docker', ['build', '-f', './build/Dockerfile', '.', '-t', dockerTag], {
|
||||
cwd : process.cwd(),
|
||||
stdio: 'inherit',
|
||||
});
|
||||
|
||||
dockerBuildCmd.on('exit', function (code) {
|
||||
if (code !== 0) {
|
||||
cb(code);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Running tests inside container...")
|
||||
let dockerRunCmd = spawn('docker', ['run', '-v', '$PWD:/app', dockerTag], {
|
||||
cwd : process.cwd(),
|
||||
stdio: 'inherit',
|
||||
env: process.env,
|
||||
shell: true,
|
||||
});
|
||||
|
||||
dockerRunCmd.on('exit', function (code) {
|
||||
cb(code);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// version bump
|
||||
function versionBump(semver) {
|
||||
return gulp
|
||||
.src(['./package.json', './package-lock.json'])
|
||||
.pipe(bump({ type: semver }))
|
||||
.pipe(gulp.dest('./'))
|
||||
.pipe(git.commit('bump version'))
|
||||
.pipe(filter('package.json'))
|
||||
.pipe(tag_version());
|
||||
}
|
||||
|
||||
gulp.task('patch', ['default'], function() {
|
||||
return versionBump('patch');
|
||||
});
|
||||
|
||||
gulp.task('minor', ['default'], function() {
|
||||
return versionBump('minor');
|
||||
});
|
||||
|
||||
gulp.task('major', ['default'], function() {
|
||||
return versionBump('major');
|
||||
});
|
||||
|
||||
gulp.task('default', ['prettier', 'tslint', 'compile']);
|
401
package-lock.json
generated
401
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -582,7 +582,6 @@
|
||||
"dependencies": {
|
||||
"clipboardy": "^1.2.2",
|
||||
"diff-match-patch": "^1.0.0",
|
||||
"gulp-typescript": "^3.2.4",
|
||||
"lodash": "^4.17.4",
|
||||
"neovim-client": "^2.1.0",
|
||||
"promised-neovim-client": "^2.0.2",
|
||||
@ -597,11 +596,11 @@
|
||||
"@types/node": "^9.4.0",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-bump": "^3.0.0",
|
||||
"gulp-filter": "^5.1.0",
|
||||
"gulp-git": "^2.5.1",
|
||||
"gulp-inject-string": "^1.1.1",
|
||||
"gulp-shell": "^0.6.5",
|
||||
"gulp-tag-version": "^1.3.1",
|
||||
"gulp-tslint": "^8.1.2",
|
||||
"gulp-typescript": "^3.2.4",
|
||||
"merge-stream": "^1.0.1",
|
||||
"mocha": "^5.0.0",
|
||||
"prettier": "^1.10.2",
|
||||
|
Loading…
Reference in New Issue
Block a user