Skip to content

Commit

Permalink
Update workflow improvements (#7552)
Browse files Browse the repository at this point in the history
* Improve update workflow

* dedupe in ui-tests

* read name from package.json
  • Loading branch information
jtpio authored Dec 21, 2024
1 parent 0d49b45 commit edfa5e2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
28 changes: 23 additions & 5 deletions .github/workflows/upgrade-jupyterlab-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ on:
default: main
required: false
type: string
target_repo:
description: 'Target repository'
required: false
default: jupyter/notebook
type: string

env:
version_tag: 'latest'
Expand Down Expand Up @@ -68,13 +73,17 @@ jobs:
echo "latest=${LATEST}" >> $GITHUB_ENV
jlpm upgrade:lab:dependencies --set-version ${LATEST}
if [[ ! -z "$(git status --porcelain package.json)" ]]; then
jlpm install
jlpm
jlpm deduplicate
cd ui-tests
jlpm
jlpm deduplicate
fi
- name: Create a PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
run: |
set -eux
Expand All @@ -95,9 +104,18 @@ jobs:
git commit . -m "Update to JupyterLab v${LATEST}"
git push --set-upstream origin "${BRANCH_NAME}"
gh pr create \
--base ${{ inputs.branch || 'main' }} \
--title "Update to JupyterLab v${LATEST}" \
PR_ARGS=(
--base "${{ inputs.branch || 'main' }}"
--title "Update to JupyterLab v${LATEST}"
--body "New JupyterLab release [v${LATEST}](https://github.com/jupyterlab/jupyterlab/releases/tag/v${LATEST}) is available. Please review the lock file carefully."
)
# Add --repo flag only if target_repo is specified
if [[ -n "${{ inputs.target_repo }}" ]]; then
PR_ARGS+=(--repo "${{ inputs.target_repo }}")
fi
gh pr create "${PR_ARGS[@]}"
fi
fi
11 changes: 11 additions & 0 deletions buildutils/src/upgrade-lab-dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const PACKAGE_JSON_PATHS: string[] = [
'packages/tree-extension/package.json',
'packages/tree/package.json',
'packages/ui-components/package.json',
'ui-tests/package.json',
];

const DEPENDENCY_GROUP = '@jupyterlab';
Expand Down Expand Up @@ -78,7 +79,16 @@ async function updatePackageJson(newVersion: string): Promise<void> {
throw new Error(errorMessage);
}

// fetch the new galata version
const galataUrl = `https://raw.githubusercontent.com/jupyterlab/jupyterlab/v${newVersion}/galata/package.json`;
const galataResponse = await fetch(galataUrl);
if (!galataResponse.ok) {
const errorMessage = `Failed to fetch galata/package.json from ${galataUrl}. HTTP status code: ${galataResponse.status}`;
throw new Error(errorMessage);
}

const newPackageJson = await response.json();
const galataPackageJson = await galataResponse.json();

for (const packageJsonPath of PACKAGE_JSON_PATHS) {
const filePath: string = path.resolve(packageJsonPath);
Expand All @@ -87,6 +97,7 @@ async function updatePackageJson(newVersion: string): Promise<void> {
const newDependencies = {
...newPackageJson.devDependencies,
...newPackageJson.resolutions,
[galataPackageJson.name]: galataPackageJson.version,
};

updateDependencyVersion(existingPackageJson, newDependencies);
Expand Down
2 changes: 1 addition & 1 deletion ui-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"license": "BSD-3-Clause",
"description": "Jupyter Notebook UI Tests",
"scripts": {
"deduplicate": "jlpm dlx yarn-berry-deduplicate -s fewerHighest && jlpm install",
"rimraf": "rimraf",
"start": "jupyter notebook --config test/jupyter_server_config.py",
"start:detached": "yarn run start&",
"test": "playwright test",
"test:debug": "PWDEBUG=1 playwright test",
"test:report": "http-server ./playwright-report -a localhost -o",
Expand Down

0 comments on commit edfa5e2

Please sign in to comment.