Skip to content

Commit

Permalink
Add branch integrity handling (jupyterlab#10708)
Browse files Browse the repository at this point in the history
* Add branch integrity handling

* Follow on integrity updates
  • Loading branch information
afshin committed Jul 28, 2021
1 parent 686cf17 commit 7aeaee7
Show file tree
Hide file tree
Showing 17 changed files with 183 additions and 25 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Check Release

on: [push, pull_request]
on:
push:
branches: [master]
pull_request:
branches: [master]
release:
types: [published]

jobs:

Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/linuxjs-flaky-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Linux JS Flaky Tests

on: [push, pull_request]
on:
push:
branches: [master]
pull_request:
branches: [master]
release:
types: [published]

jobs:
linuxjs:
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/linuxjs-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Linux JS Tests

on: [push, pull_request]
on:
push:
branches: [master]
pull_request:
branches: [master]
release:
types: [published]

jobs:
linuxjs:
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/linuxtests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Linux Tests

on: [push, pull_request]
on:
push:
branches: [master]
pull_request:
branches: [master]
release:
types: [published]

jobs:
linuxtests:
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/macostests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: macOS Tests

on: [push, pull_request]
on:
push:
branches: [master]
pull_request:
branches: [master]
release:
types: [published]

jobs:
macostests:
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/ui-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: UI Tests

on: [push, pull_request]
on:
push:
branches: [master]
pull_request:
branches: [master]
release:
types: [published]

jobs:
ui-tests:
Expand Down Expand Up @@ -32,7 +38,7 @@ jobs:
# Print jupyterlab logs before removing the containers using the container name set in docker-compose file
docker logs jupyterlab
docker-compose -f "./ui-tests/docker/docker-compose.yml" down
- name: Run UI Tests
if: ${{ failure() }}
run: |
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/windowstests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Windows Tests

on: [push, pull_request]
on:
push:
branches: [master]
pull_request:
branches: [master]
release:
types: [published]

jobs:
windowstests:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM mambaorg/micromamba:0.14.0 as build

# Install basic tools
RUN micromamba install -qy -c conda-forge python nodejs yarn=1.21 build \
RUN micromamba install -qy -c conda-forge python nodejs yarn \
&& useradd --shell /bin/bash jovyan \
&& chown jovyan $HOME

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ via [PyPI](https://pypi.org/search/?q=jupyterlab&o=-created&c=Framework+%3A%3A+J
conda, and other package managers. The _source_ extensions can be installed
directly from npm (search for [jupyterlab-extension](https://www.npmjs.com/search?q=keywords:jupyterlab-extension)) but require additional build step.
You can also find JupyterLab extensions exploring GitHub topic [jupyterlab-extension](https://github.com/topics/jupyterlab-extension).
To learn more about extensions, see the [user documentation](https://jupyterlab.readthedocs.io/en/stable/user/extensions.html).
To learn more about extensions, see the [user documentation](https://jupyterlab.readthedocs.io/en/latest/user/extensions.html).

The current JupyterLab releases are suitable for general
usage, and the extension APIs will continue to
Expand All @@ -50,7 +50,7 @@ Read the current JupyterLab documentation on [ReadTheDocs](http://jupyterlab.rea

### Installation

JupyterLab can be installed using [conda](https://docs.conda.io/en/latest/), [mamba](https://mamba.readthedocs.io/en/latest/) or [pip](https://docs.python.org/3.6/installing/index.html). For more detailed instructions, consult the [installation guide](http://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html).
JupyterLab can be installed using [conda](https://docs.conda.io/en/latest/), [mamba](https://mamba.readthedocs.io/en/latest/) or [pip](https://docs.python.org/3.6/installing/index.html). For more detailed instructions, consult the [installation guide](http://jupyterlab.readthedocs.io/en/latest/getting_started/installation.html).

Project installation instructions from the git sources are available in the [contributor documentation](CONTRIBUTING.md).

Expand Down Expand Up @@ -95,7 +95,7 @@ Start up JupyterLab using:
jupyter lab
```

JupyterLab will open automatically in the browser. See the [documentation](http://jupyterlab.readthedocs.io/en/stable/getting_started/starting.html) for additional details.
JupyterLab will open automatically in the browser. See the [documentation](http://jupyterlab.readthedocs.io/en/latest/getting_started/starting.html) for additional details.

If you encounter an error like "Command 'jupyter' not found", please make sure `PATH` environment variable is set correctly. Alternatively, you can start up JupyterLab using `~/.local/bin/jupyter lab` without changing the `PATH` environment variable.

Expand All @@ -107,7 +107,7 @@ The latest versions of the following browsers are currently _known to work_:
- Chrome
- Safari

See our [documentation](http://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html) for additional details.
See our [documentation](http://jupyterlab.readthedocs.io/en/latest/getting_started/installation.html) for additional details.

---

Expand All @@ -117,7 +117,7 @@ We encourage you to ask questions on the [Discourse forum](https://discourse.jup

### Bug report

To report a bug please read the [guidelines](https://jupyterlab.readthedocs.io/en/stable/getting_started/issue.html) and then open a [Github issue](https://github.com/jupyterlab/jupyterlab/issues/new?template=bug_report.md). To keep resolved issues self-contained, the [lock bot](https://github.com/apps/lock) will lock closed issues as resolved after a period of inactivity. If related discussion is still needed after an issue is locked, please open a new issue and reference the old issue.
To report a bug please read the [guidelines](https://jupyterlab.readthedocs.io/en/latest/getting_started/issue.html) and then open a [Github issue](https://github.com/jupyterlab/jupyterlab/issues/new?template=bug_report.md). To keep resolved issues self-contained, the [lock bot](https://github.com/apps/lock) will lock closed issues as resolved after a period of inactivity. If related discussion is still needed after an issue is locked, please open a new issue and reference the old issue.

### Feature request

Expand All @@ -129,7 +129,7 @@ We also welcome suggestions for new features as they help make the project more

### Extending JupyterLab

To start developing an extension for JupyterLab, see the [developer documentation](https://jupyterlab.readthedocs.io/en/stable/extension/extension_dev.html) and the [API docs](https://jupyterlab.readthedocs.io/en/stable/api/).
To start developing an extension for JupyterLab, see the [developer documentation](https://jupyterlab.readthedocs.io/en/latest/extension/extension_dev.html) and the [API docs](https://jupyterlab.readthedocs.io/en/latest/api/).

### Contributing

Expand Down
111 changes: 111 additions & 0 deletions buildutils/src/ensure-repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
* Ensure a consistent version of all packages.
* Manage the metapackage meta package.
*/
import { execSync } from 'child_process';
import * as glob from 'glob';
import * as path from 'path';
import * as fs from 'fs-extra';
import * as utils from './utils';
Expand All @@ -22,6 +24,21 @@ import {

type Dict<T> = { [key: string]: T };

// URL config for this branch
// Source and target branches
// Source and target RTD version names
// For master these will be the same, for other branches the source
// Branch is whichever branch it was created from
// The current release branch should target RTD stable
// Master should target latest
// All other release branches should target a specific named version
const URL_CONFIG = {
source: 'master',
target: 'master',
rtdSource: 'stable',
rtdTarget: 'latest'
};

// Data to ignore.
const MISSING: Dict<string[]> = {
'@jupyterlab/coreutils': ['path'],
Expand Down Expand Up @@ -234,6 +251,89 @@ const pkgNames: Dict<string> = {};
const depCache: Dict<string> = {};
const locals: Dict<string> = {};

/**
* Ensure branch integrity - GitHub and RTD urls, and workflow target branches
*
* @returns An array of messages for changes.
*/
function ensureBranch(): string[] {
const messages: string[] = [];

const { source, target, rtdSource, rtdTarget } = URL_CONFIG;

// Handle the github_version in conf.py
const confPath = 'docs/source/conf.py';
let confData = fs.readFileSync(confPath, 'utf-8');
const confTest = new RegExp('"github_version": "(.*)"');
if (source !== target) {
messages.push(`Overwriting ${confPath}`);
confData = confData.replace(confTest, `"github_version": "${target}"`);
fs.writeFileSync(confPath, confData, 'utf-8');
}

// Handle urls in files
// Get all files matching the desired file types
const fileTypes = ['.json', '.md', '.rst', '.yml', '.ts', '.tsx', '.py'];
let files = execSync('git ls-tree -r HEAD --name-only')
.toString()
.trim()
.split(/\r?\n/);
files = files.filter(filePath => {
return fileTypes.indexOf(path.extname(filePath)) !== -1;
});

// Set up string replacements
const base = '/jupyterlab/jupyterlab';
const rtdString = `jupyterlab.readthedocs.io/en/${rtdTarget}/`;
const urlMap = [
[`\/jupyterlab\/jupyterlab\/${source}\/`, `${base}/${target}/`],
[`\/jupyterlab\/jupyterlab\/blob\/${source}\/`, `${base}/blob/${target}/`],
[`\/jupyterlab\/jupyterlab\/tree\/${source}\/`, `${base}/tree/${target}/`],
[`jupyterlab.readthedocs.io\/en\/${rtdSource}\/`, rtdString]
];

// Make the string replacements
files.forEach(filePath => {
const oldData = fs.readFileSync(filePath, 'utf-8');
let newData = oldData;
urlMap.forEach(section => {
const test = new RegExp(section[0], 'g');
const replacer = section[1];
if (newData.match(test)) {
newData = newData.replace(test, replacer);
}
});

// Make sure the root RTD links point to stable
const badgeLink = '(http://jupyterlab.readthedocs.io/en/stable/)';
const toReplace = badgeLink.replace('stable', rtdTarget);
while (newData.indexOf(toReplace) !== -1) {
newData = newData.replace(toReplace, badgeLink);
}

if (newData !== oldData) {
messages.push(`Overwriting ${filePath}`);
fs.writeFileSync(filePath, newData, 'utf-8');
}
});

// Handle workflow file target branches
const workflows = glob.sync(path.join('.github', 'workflows', '*.yml'));
workflows.forEach(filePath => {
let workflowData = fs.readFileSync(filePath, 'utf-8');
const test = new RegExp(`\\[${source}\\]`, 'g');
if (workflowData.match(test)) {
if (workflowData.match(test)![1] !== `[${target}]`) {
messages.push(`Overwriting ${filePath}`);
workflowData = workflowData.replace(test, `[${target}]`);
fs.writeFileSync(filePath, workflowData, 'utf-8');
}
}
});

return messages;
}

/**
* Ensure the metapackage package.
*
Expand Down Expand Up @@ -451,6 +551,17 @@ function ensureBuildUtils() {
export async function ensureIntegrity(): Promise<boolean> {
const messages: Dict<string[]> = {};

if (process.env.SKIP_INTEGRITY_CHECK === 'true') {
console.log('Skipping integrity check');
return true;
}

// Handle branch integrity
const branchMessages = ensureBranch();
if (branchMessages.length > 0) {
messages['branch'] = branchMessages;
}

// Pick up all the package versions.
const paths = utils.getLernaPaths();

Expand Down
3 changes: 3 additions & 0 deletions docker/jupyter_server_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
},
"LabApp": {
"dev_mode": true
},
"Application": {
"log_level": "DEBUG"
}
}
2 changes: 1 addition & 1 deletion docs/source/user/rtc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ represent the document's content, what we call ``DocumentModel``. If you
modify a Notebook with both editors simultaneously, JupyterLab will prompt
a warning message indicating that the document's content changed. For more
information, you can read the section of
`Documents <https://jupyterlab.readthedocs.io/en/stable/extension/documents.html#documents>`_.
`Documents <https://jupyterlab.readthedocs.io/en/latest/extension/documents.html#documents>`_.

.. image:: images/sync_editors.png
:align: center
Expand Down
10 changes: 5 additions & 5 deletions packages/extensionmanager/src/widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ function ListEntry(props: ListEntry.IProperties): React.ReactElement<any> {
)}
onClick={() =>
window.open(
'https://jupyterlab.readthedocs.io/en/stable/user/extensions.html'
'https://jupyterlab.readthedocs.io/en/latest/user/extensions.html'
)
}
/>
Expand All @@ -266,7 +266,7 @@ function ListEntry(props: ListEntry.IProperties): React.ReactElement<any> {
)}
onClick={() =>
window.open(
'https://jupyterlab.readthedocs.io/en/stable/user/extensions.html'
'https://jupyterlab.readthedocs.io/en/latest/user/extensions.html'
)
}
/>
Expand Down Expand Up @@ -396,11 +396,11 @@ function getPrebuiltUninstallInstruction(
</p>
<p>
<a
href="https://jupyterlab.readthedocs.io/en/stable/user/extensions.html"
href="https://jupyterlab.readthedocs.io/en/latest/user/extensions.html"
target="_blank"
rel="noopener noreferrer"
>
https://jupyterlab.readthedocs.io/en/stable/user/extensions.html
https://jupyterlab.readthedocs.io/en/latest/user/extensions.html
</a>
</p>
</div>
Expand Down Expand Up @@ -725,7 +725,7 @@ administrator to verify the listings configuration.`)}
</div>
<div>
<a
href="https://jupyterlab.readthedocs.io/en/stable/user/extensions.html"
href="https://jupyterlab.readthedocs.io/en/latest/user/extensions.html"
target="_blank"
rel="noopener noreferrer"
>
Expand Down
4 changes: 2 additions & 2 deletions packages/help-extension/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,12 @@ const resources: JupyterFrontEndPlugin<void> = {
const resources = [
{
text: trans.__('JupyterLab Reference'),
url: 'https://jupyterlab.readthedocs.io/en/stable/'
url: 'https://jupyterlab.readthedocs.io/en/latest/'
},
{
text: trans.__('JupyterLab FAQ'),
url:
'https://jupyterlab.readthedocs.io/en/stable/getting_started/faq.html'
'https://jupyterlab.readthedocs.io/en/latest/getting_started/faq.html'
},
{
text: trans.__('Jupyter Reference'),
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-components/docs/source/intro.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The `@jupyterlab/ui-components <https://jupyterlab.readthedocs.io/en/stable/api/modules/ui_components.html>`__
The `@jupyterlab/ui-components <https://jupyterlab.readthedocs.io/en/latest/api/modules/ui_components.html>`__
package provides UI elements that are widely used in JupyterLab core,
and that can be reused in your own extensions.

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ install_requires =

[options.extras_require]
test = coverage; pytest>=6.0; pytest-cov; pytest-console-scripts; pytest-check-links>=0.5; jupyterlab_server[test]~=2.2; requests; requests_cache; virtualenv; check-manifest
ui-tests = ipykernel>=6.0
ui-tests = build

[options.entry_points]
console_scripts =
Expand Down
Loading

0 comments on commit 7aeaee7

Please sign in to comment.