Skip to content

Commit

Permalink
Verify vsix size before release (#2144)
Browse files Browse the repository at this point in the history
* Verify vsix size before release

* Remove istanbul from shipping payload
  • Loading branch information
Piotr Puszkiewicz authored Mar 29, 2018
1 parent a59273b commit 0514e83
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ script:
- npm run cov:instrument
- npm test --silent
- npm run cov:report
- npm run test:release

after_failure:
- ./.travis/printLogs.sh
Expand Down
2 changes: 0 additions & 2 deletions mocha.opts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
--ui tdd
--require source-map-support/register
--require ts-node/register

test/unitTests/**/*.test.@(ts|tsx)
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"vscode:prepublish": "tsc -p ./",
"compile": "tsc -p ./ && gulp tslint",
"watch": "tsc -watch -p ./",
"tdd": "npm run test:unit -- --watch --watch-extensions ts",
"tdd": "mocha --opts ./mocha.opts --watch --watch-extensions ts test/unitTests/**/*.test.ts*",
"test": "npm-run-all test:feature test:unit test:integration",
"test:unit": "nyc -r lcovonly --report-dir coverage/unit mocha --ui tdd -- test/unitTests/**/*.test.ts",
"test:feature": "cross-env OSVC_SUITE=featureTests CODE_EXTENSIONS_PATH=./ CODE_TESTS_PATH=./out/test/featureTests npm run test:runInVsCode",
Expand All @@ -38,6 +38,7 @@
"test:integration:slnWithCsproj": "cross-env OSVC_SUITE=slnWithCsproj npm run test:runSuiteInVsCode",
"test:runSuiteInVsCode": "cross-env CODE_EXTENSIONS_PATH=./ CODE_TESTS_PATH=./out/test/integrationTests CODE_TESTS_WORKSPACE=./test/integrationTests/testAssets/$OSVC_SUITE npm run test:runInVsCode",
"test:runInVsCode": "node ./test/runVsCodeTestsWithAbsolutePaths.js",
"test:release": "mocha --opts ./mocha.opts test/releaseTests/**/*.test.ts",
"postinstall": "node ./node_modules/vscode/bin/install",
"cov:instrument": "rimraf ./coverage && rimraf ./.nyc_output && rimraf ./out && npm run compile && cd out && nyc instrument --require source-map-support/register --cwd ../ . . && cd ..",
"cov:merge": "cd ./out && istanbul-combine -d ../coverage/integration -r lcovonly ../.nyc_output/integration/*.json && cd ..",
Expand Down Expand Up @@ -66,7 +67,6 @@
"fs-extra": "^5.0.0",
"http-proxy-agent": "^2.0.0",
"https-proxy-agent": "^2.1.1",
"istanbul": "^0.4.5",
"jsonc-parser": "^1.0.0",
"lodash.debounce": "^4.0.8",
"mkdirp": "^0.5.1",
Expand Down Expand Up @@ -102,9 +102,11 @@
"copyfiles": "^2.0.0",
"cross-env": "^5.1.4",
"del": "3.0.0",
"glob-promise": "^3.4.0",
"gulp": "3.9.1",
"gulp-mocha": "^5.0.0",
"gulp-tslint": "^8.1.3",
"istanbul": "^0.4.5",
"istanbul-combine": "^0.3.0",
"ltcdr": "^2.2.1",
"mocha": "^5.0.4",
Expand Down
38 changes: 38 additions & 0 deletions test/releaseTests/vsix.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as chai from 'chai';
import * as fs from 'async-file';
import * as glob from 'glob-promise';
import * as path from 'path';

let vsixFiles = glob.sync(path.join(process.cwd(), '**', '*.vsix'));

suite("Omnisharp-Vscode VSIX", async () => {
suiteSetup(async () => {
chai.should();

});

test("At least one vsix file should be produced", () => {
vsixFiles.length.should.be.greaterThan(0, "the build should produce at least one vsix file");
});

vsixFiles.forEach(element => {
const maximumVsixSizeInBytes = 5 * 1024 * 1024;

suite(`Given ${element}`, () => {
test(`Then its size is less than 1MB`, async () => {
const stats = await fs.stat(element);
stats.size.should.be.lessThan(maximumVsixSizeInBytes);
});

test(`Then it should not be empty`, async () => {
const stats = await fs.stat(element);
stats.size.should.be.greaterThan(0);
});
});
});
});

0 comments on commit 0514e83

Please sign in to comment.