Skip to content

Commit

Permalink
Reduce logging & faster CI (#14944)
Browse files Browse the repository at this point in the history
* Reduce logging on CI

* Faster

* Faster

* oops

* Skip on windows

* Misc

* hello

* oops

* No need to upgrade pip

* No need to list packages
  • Loading branch information
DonJayamanne authored Dec 21, 2023
1 parent 0ee7acf commit e419372
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 60 deletions.
42 changes: 4 additions & 38 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ jobs:
# Upload unit test coverage reports for later use in the "reports" job.
- name: Upload unit test coverage reports
uses: actions/upload-artifact@v3
if: "(success() || failure()) && !contains(github.ref, 'refs/heads/release')"
if: "(success() || failure()) && !contains(github.ref, 'refs/heads/release') && github.event_name != 'pull_request'"
with:
name: ${{env.COVERAGE_REPORTS}}-${{runner.os}}
path: .nyc_output
Expand Down Expand Up @@ -401,10 +401,6 @@ jobs:
with:
PYTHON_VERSION: ${{matrix.pythonVersion}}

- name: Upgrade pip
run: python -m pip install -U pip
if: matrix.python != 'conda' && matrix.python != 'noPython'

- name: Use Node ${{env.NODE_VERSION}}
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -560,13 +556,6 @@ jobs:
python -m jupyter nbextension uninstall --sys-prefix --py ipympl
sudo $PYTHON_EXECUTABLE -m jupyter nbextension install --system --py ipympl
- name: Pip List
if: matrix.python != 'noPython'
run: |
python --version
python -c "import sys;print(sys.executable)"
python -m pip list
# This step is slow.

# Run npm install (we need chrome to get downloaded)
Expand Down Expand Up @@ -722,7 +711,7 @@ jobs:
# Upload unit test coverage reports for later use in the "reports" job.
- name: Upload unit test coverage reports
uses: actions/upload-artifact@v3
if: "(success() || failure()) && !contains(github.ref, 'refs/heads/release')"
if: "(success() || failure()) && !contains(github.ref, 'refs/heads/release') && github.event_name != 'pull_request'"
with:
name: ${{env.COVERAGE_REPORTS}}-${{runner.os}}
path: .nyc_output
Expand Down Expand Up @@ -780,9 +769,6 @@ jobs:
with:
PYTHON_VERSION: ${{matrix.python}}

- name: Upgrade pip
run: python -m pip install -U pip

- name: Use Node ${{env.NODE_VERSION}}
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -826,31 +812,11 @@ jobs:
with:
run: npm run testSmokeLogged

- name: Upload test result, screenshots files
uses: actions/upload-artifact@v3
if: always()
with:
name: TestLogs-Smoke-${{matrix.python}}-${{matrix.os}}
path: './logs/*'
retention-days: 60

- name: Create coverage folder (if not created)
run: npm run createNycFolder

# Upload unit test coverage reports for later use in the "reports" job.
- name: Upload unit test coverage reports
uses: actions/upload-artifact@v3
if: always()
with:
name: ${{env.COVERAGE_REPORTS}}-${{runner.os}}
path: .nyc_output
retention-days: 1

coverage:
name: Coverage reports upload
runs-on: ubuntu-latest
if: (success() || failure()) && !contains(github.ref, 'refs/heads/release') && github.event_name != 'pull_request'
needs: [ts_tests, vscodeTests, smoke-tests]
if: "(success() || failure()) && !contains(github.ref, 'refs/heads/release') && github.event_name != 'pull_request'"
needs: [ts_tests, vscodeTests]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
4 changes: 3 additions & 1 deletion src/extension.node.proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export async function activate(context: IExtensionContext): Promise<IExtensionAp
realEntryPoint = eval('require')(entryPoint); // CodeQL [SM04509] Usage of eval in this context is safe (we do not want bundlers to import code when it sees `require`).
return realEntryPoint.activate(context);
} catch (ex) {
console.error('Failed to activate extension, falling back to `./extension.node`', ex);
if (!ex.toString().includes(`Cannot find module '../out/extension.node'`)) {
console.error('Failed to activate extension, falling back to `./extension.node`', ex);
}
// In smoke tests, we do not want to load the out/extension.node.
realEntryPoint = eval('require')('./extension.node'); // CodeQL [SM04509] Usage of eval in this context is safe (we do not want bundlers to import code when it sees `require`)
return realEntryPoint.activate(context);
Expand Down
5 changes: 3 additions & 2 deletions src/kernels/jupyter/connection/serverUriStorage.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ suite('Server Uri Storage', async () => {
const itemsInNewStorage = generateDummyData(2).slice();
const all = serverUriStorage.all;
assert.strictEqual(all.length, 2, 'Should have 2 items');
// Strip the last few chars from time, to account for the fact that we store time in ms and it can be off a little.
assert.deepEqual(
all
.map((a) => {
return {
time: a.time,
time: a.time.toString().substring(0, -4),
displayName: a.displayName,
uri: generateIdFromRemoteProvider(a.provider)
};
Expand All @@ -82,7 +83,7 @@ suite('Server Uri Storage', async () => {
itemsInNewStorage
.map((a) => {
return {
time: a.time,
time: a.time.toString().substring(0, -4),
displayName: a.displayName,
uri: generateIdFromRemoteProvider(a.serverHandle)
};
Expand Down
3 changes: 0 additions & 3 deletions src/test/common.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ async function setPythonPathInWorkspace(
const prop: 'workspaceFolderValue' | 'workspaceValue' =
config === vscode.ConfigurationTarget.Workspace ? 'workspaceValue' : 'workspaceFolderValue';
if (!value || value[prop] !== pythonPath) {
console.log(`Updating Interpreter path to ${pythonPath} in workspace`);
await settings.update('pythonPath', pythonPath, config).then(noop, noop);
await settings.update('defaultInterpreterPath', pythonPath, config).then(noop, noop);
if (config === vscode.ConfigurationTarget.Global) {
Expand Down Expand Up @@ -190,7 +189,6 @@ export async function captureScreenShot(contextOrFileName: string | Mocha.Contex
try {
const screenshot = require('screenshot-desktop');
await screenshot({ filename });
console.info(`Screenshot captured into ${filename}`);
} catch (ex) {
console.error(`Failed to capture screenshot into ${filename}`, ex);
}
Expand Down Expand Up @@ -247,7 +245,6 @@ export function initializeCommonNodeApi() {
await commands.executeCommand('jupyter.selectjupyteruri', Uri.parse(url));
return { url, dispose: noop };
} else {
console.info(`Jupyter not started and set to local`); // This is the default
return { url: '', dispose: noop };
}
},
Expand Down
6 changes: 6 additions & 0 deletions src/test/datascience/notebook/executionService.vscode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import { createKernelController, TestNotebookDocument } from './executionHelper'
import { noop } from '../../core';
import { getOSType, OSType } from '../../../platform/common/utils/platform';
import { splitLines } from '../../../platform/common/helpers';
import { isCI } from '../../../platform/vscode-path/platform';
use(chaiAsPromised);

// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
Expand All @@ -82,6 +83,11 @@ suite('Kernel Execution @kernelCore', function () {
let kernel: IKernel;
let kernelExecution: INotebookKernelExecution;
suiteSetup(async function () {
// No need to run this test on windows on CI.
// Running these is very slow on windows & we have other tests that run on windows (interrupts and restarts).
if (getOSType() === OSType.Windows && isCI) {
return this.skip();
}
traceInfo('Suite Setup VS Code Notebook - Execution');
this.timeout(120_000);
try {
Expand Down
3 changes: 0 additions & 3 deletions src/test/index.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,11 @@ export async function run(): Promise<void> {

// Setup test files that need to be run.
testFiles.forEach((file) => mocha.addFile(path.join(testsRoot, file)));
console.log(`Running tests with options ${JSON.stringify(options, undefined, 4)}`);
console.log(`Tests included ${testFiles.join(',')}`);

// for performance tests, extension activation is part of the test run
if (!IS_PERF_TEST()) {
/* eslint-disable no-console */
console.time('Time taken to activate the extension');
console.log('Starting & waiting for Jupyter Extension to activate');
await activateExtensionScript();
console.timeEnd('Time taken to activate the extension');
}
Expand Down
2 changes: 0 additions & 2 deletions src/test/smokeTest.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { EXTENSION_ROOT_DIR_FOR_TESTS, SMOKE_TEST_EXTENSIONS_DIR } from './const

class TestRunner {
public async start() {
console.log('Start Test Runner');
await this.extractLatestExtension(SMOKE_TEST_EXTENSIONS_DIR);
await this.launchSmokeTests();
}
Expand All @@ -28,7 +27,6 @@ class TestRunner {
await this.launchTest(env);
}
private async launchTest(customEnvVars: Record<string, {}>) {
console.log('Launch tests in test runner');
await new Promise<void>((resolve, reject) => {
const env: Record<string, string> = {
TEST_FILES_SUFFIX: 'smoke.test*',
Expand Down
2 changes: 0 additions & 2 deletions src/test/standardTest.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ async function getExtensionsDir(): Promise<string> {
}

async function start() {
console.log('*'.repeat(100));
console.log('Start Standard tests');
const platform = computePlatform();
const vscodeExecutablePath = await downloadAndUnzipVSCode(channel, platform);
const baseLaunchArgs = requiresPythonExtensionToBeInstalled() ? [] : ['--disable-extensions'];
Expand Down
10 changes: 1 addition & 9 deletions src/test/testBootstrap.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,13 @@ async function deletePortFile() {
}
}
async function end(exitCode: number) {
if (exitCode === 0) {
console.log('Exiting without errors');
} else {
if (exitCode !== 0) {
console.error('Exiting with test failures');
}
if (proc) {
try {
const procToKill = proc;
proc = undefined;
console.log('Killing VSC');
await deletePortFile();
// Wait for the std buffers to get flushed before killing.
await sleep(5_000);
Expand All @@ -76,7 +73,6 @@ async function end(exitCode: number) {

async function startSocketServer() {
return new Promise<void>((resolve) => {
console.log(`Creating test server`);
server = createServer((socket) => {
socket.on('data', (buffer) => {
const data = buffer.toString('utf8');
Expand All @@ -93,10 +89,8 @@ async function startSocketServer() {
// Just log it, no need to do anything else.
console.error(ex);
});
console.log(`Listening to test server`);
server.listen({ host: '127.0.0.1', port: 0 }, async () => {
const port = (server!.address() as AddressInfo).port;
console.log(`Test server listening on port ${port}`);
await deletePortFile();
await fs.writeFile(portFile, port.toString());
resolve();
Expand All @@ -106,10 +100,8 @@ async function startSocketServer() {
}

async function start() {
console.log('Starting socket server for tests.');
await startSocketServer();
const options: SpawnOptions = { cwd: process.cwd(), env: process.env, detached: false, stdio: 'inherit' };
console.log(`Spawning ${process.execPath} : ${testFile}`);
proc = spawn(process.execPath, [testFile], options);
proc.once('close', end);
}
Expand Down

0 comments on commit e419372

Please sign in to comment.