Skip to content

Commit b33f028

Browse files
authored
Guarantee that master branch has "-dev" tag in version (microsoft#7477)
* Test this * Skip tests when running locally * Prep for microsoft#5908 (release* branches) * News file * Use require() * Forgot to update something lol * Add comment + undo microsoft#5908 change * Use application.ts * Review changes
1 parent 9f69bf7 commit b33f028

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

build/ci/templates/globals.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ variables:
66
MOCHA_REPORTER_JUNIT: true # Use the mocha-multi-reporters and send output to both console (spec) and JUnit (mocha-junit-reporter).
77
VSC_PYTHON_FORCE_LOGGING: true # Enable this to turn on console output for the logger
88
VSC_PYTHON_LOG_FILE: '$(Build.ArtifactStagingDirectory)/pvsc.log'
9+
CI_BRANCH_NAME: ${Build.SourceBranchName}

news/3 Code Health/7471.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add unit tests to guarantee that the extension version in the master branch has the '-dev' suffix.

src/test/extension.unit.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import { expect } from 'chai';
99
import { buildApi } from '../client/api';
10+
import { ApplicationEnvironment } from '../client/common/application/applicationEnvironment';
11+
import { IApplicationEnvironment } from '../client/common/application/types';
1012
import { EXTENSION_ROOT_DIR } from '../client/common/constants';
1113

1214
const expectedPath = `${EXTENSION_ROOT_DIR.fileToCommandArgument()}/pythonFiles/ptvsd_launcher.py`;
@@ -23,3 +25,40 @@ suite('Extension API Debugger', () => {
2325
expect(args).to.be.deep.equal(expectedArgs);
2426
});
2527
});
28+
29+
suite('Extension version tests', () => {
30+
let version: string;
31+
let applicationEnvironment: IApplicationEnvironment;
32+
const branchName = process.env.CI_BRANCH_NAME;
33+
34+
suiteSetup(async function() {
35+
// Skip the entire suite if running locally
36+
if (!branchName) {
37+
// tslint:disable-next-line: no-invalid-this
38+
return this.skip();
39+
}
40+
});
41+
42+
setup(() => {
43+
applicationEnvironment = new ApplicationEnvironment(undefined as any, undefined as any, undefined as any);
44+
version = applicationEnvironment.packageJson.version;
45+
});
46+
47+
test('If we are running a pipeline in the master branch, the extension version in `package.json` should have the "-dev" suffix', async function() {
48+
if (branchName !== 'master') {
49+
// tslint:disable-next-line: no-invalid-this
50+
return this.skip();
51+
}
52+
53+
return expect(version.endsWith('-dev'), 'When running a pipeline in the master branch, the extension version in package.json should have the -dev suffix').to.be.true;
54+
});
55+
56+
test('If we are running a pipeline in the release branch, the extension version in `package.json` should not have the "-dev" suffix', async function() {
57+
if (!branchName!.startsWith('release')) {
58+
// tslint:disable-next-line: no-invalid-this
59+
return this.skip();
60+
}
61+
62+
return expect(version.endsWith('-dev'), 'When running a pipeline in the release branch, the extension version in package.json should not have the -dev suffix').to.be.false;
63+
});
64+
});

0 commit comments

Comments
 (0)