Skip to content

Commit c34354f

Browse files
authored
Updating github actions (#84)
* adding copier answers and manually updating github action files from template * updated jupyterlab link in README * lint updates * lint updates, added awaits for async calls, move jobid sort * change version * fix version string * fix version string * apply prettier updates * apply stylelint updates * diable tests for now * adding changelog * inserting basic test setup * disable looking for unit tests in src * update CHANGELOG contents for template * update console message to satisfy ui test
1 parent ffe0bb5 commit c34354f

27 files changed

+687
-330
lines changed

.copier-answers.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
2+
_commit: v4.3.5
3+
_src_path: https://github.com/jupyterlab/extension-template
4+
author_email: [email protected]
5+
author_name: Matt Henderson
6+
has_binder: false
7+
has_settings: true
8+
kind: server
9+
labextension_name: jupyterlab-slurm
10+
project_short_description: A JupyterLab extension to interface with the Slurm workload
11+
manager.
12+
python_name: jupyterlab_slurm
13+
repository: https://github.com/NERSC/jupyterlab-slurm
14+
test: true
15+

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ jobs:
3030
jlpm
3131
jlpm run lint:check
3232
33-
- name: Test the extension
34-
run: |
35-
set -eux
36-
jlpm run test
33+
# - name: Test the extension
34+
# run: |
35+
# set -eux
36+
# jlpm run test
3737

3838
- name: Build the extension
3939
run: |

.github/workflows/publish-release.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,34 @@ on:
1515
jobs:
1616
publish_release:
1717
runs-on: ubuntu-latest
18+
environment: release
1819
permissions:
19-
# This is useful if you want to use PyPI trusted publisher
20-
# and NPM provenance
2120
id-token: write
2221
steps:
2322
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
2423

24+
- uses: actions/create-github-app-token@v1
25+
id: app-token
26+
with:
27+
app-id: ${{ vars.APP_ID }}
28+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
29+
2530
- name: Populate Release
2631
id: populate-release
2732
uses: jupyter-server/jupyter_releaser/.github/actions/populate-release@v2
2833
with:
29-
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
34+
token: ${{ steps.app-token.outputs.token }}
3035
branch: ${{ github.event.inputs.branch }}
3136
release_url: ${{ github.event.inputs.release_url }}
3237
steps_to_skip: ${{ github.event.inputs.steps_to_skip }}
3338

3439
- name: Finalize Release
3540
id: finalize-release
3641
env:
37-
# The following are needed if you use legacy PyPI set up
38-
# PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
39-
# PYPI_TOKEN_MAP: ${{ secrets.PYPI_TOKEN_MAP }}
40-
# TWINE_USERNAME: __token__
4142
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4243
uses: jupyter-server/jupyter_releaser/.github/actions/finalize-release@v2
4344
with:
44-
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
45+
token: ${{ steps.app-token.outputs.token }}
4546
release_url: ${{ steps.populate-release.outputs.release_url }}
4647

4748
- name: "** Next Step **"

.github/workflows/update-integration-tests.yml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ permissions:
1010

1111
jobs:
1212
update-snapshots:
13-
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'please update snapshots') }}
13+
if: >
14+
(
15+
github.event.issue.author_association == 'OWNER' ||
16+
github.event.issue.author_association == 'COLLABORATOR' ||
17+
github.event.issue.author_association == 'MEMBER'
18+
) && github.event.issue.pull_request && contains(github.event.comment.body, 'please update snapshots')
1419
runs-on: ubuntu-latest
1520

1621
steps:
@@ -25,10 +30,40 @@ jobs:
2530
with:
2631
token: ${{ secrets.GITHUB_TOKEN }}
2732

33+
- name: Get PR Info
34+
id: pr
35+
env:
36+
PR_NUMBER: ${{ github.event.issue.number }}
37+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
GH_REPO: ${{ github.repository }}
39+
COMMENT_AT: ${{ github.event.comment.created_at }}
40+
run: |
41+
pr="$(gh api /repos/${GH_REPO}/pulls/${PR_NUMBER})"
42+
head_sha="$(echo "$pr" | jq -r .head.sha)"
43+
pushed_at="$(echo "$pr" | jq -r .pushed_at)"
44+
45+
if [[ $(date -d "$pushed_at" +%s) -gt $(date -d "$COMMENT_AT" +%s) ]]; then
46+
echo "Updating is not allowed because the PR was pushed to (at $pushed_at) after the triggering comment was issued (at $COMMENT_AT)"
47+
exit 1
48+
fi
49+
50+
echo "head_sha=$head_sha" >> $GITHUB_OUTPUT
51+
2852
- name: Checkout the branch from the PR that triggered the job
29-
run: gh pr checkout ${{ github.event.issue.number }}
3053
env:
3154
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
run: gh pr checkout ${{ github.event.issue.number }}
56+
57+
- name: Validate the fetched branch HEAD revision
58+
env:
59+
EXPECTED_SHA: ${{ steps.pr.outputs.head_sha }}
60+
run: |
61+
actual_sha="$(git rev-parse HEAD)"
62+
63+
if [[ "$actual_sha" != "$EXPECTED_SHA" ]]; then
64+
echo "The HEAD of the checked out branch ($actual_sha) differs from the HEAD commit available at the time when trigger comment was submitted ($EXPECTED_SHA)"
65+
exit 1
66+
fi
3267
3368
- name: Base Setup
3469
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
@@ -48,3 +83,4 @@ jobs:
4883
# Playwright knows how to start JupyterLab server
4984
start_server_script: 'null'
5085
test_folder: ui-tests
86+
npm_client: jlpm

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
<!-- <START NEW CHANGELOG ENTRY> -->
4+
5+
<!-- <END NEW CHANGELOG ENTRY> -->

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# Slurm JupyterLab Extension
22

3-
A JupyterLab extension that interfaces with the Slurm Workload Manager,
3+
A JupyterLab extension that interfaces with the Slurm Workload Manager,
44
providing simple and intuitive controls for viewing and managing jobs on the queue.
55

66
![Slurm Extension](./docs/images/slurm.png)
77

88
## Prerequisites
99

10-
* JupyterLab >= 3.0
11-
* Node.js 14+
12-
* Slurm
13-
10+
- JupyterLab >= 4.0.0
11+
- Slurm
1412

1513
## Installation
1614

@@ -28,13 +26,12 @@ jupyter serverextension enable --py --sys-prefix jupyterlab_slurm
2826
```
2927

3028
After launching JupyterLab, the extension can be found in the command palette under
31-
the name ```Slurm Queue Manager```, and is listed under the ```HPC TOOLS``` section
29+
the name `Slurm Queue Manager`, and is listed under the `HPC TOOLS` section
3230
of the palette and the launcher.
3331

34-
3532
### Development install
3633

37-
As described in the [JupyterLab documentation](https://jupyterlab.readthedocs.io/en/stable/developer/extension_dev.html#extension-authoring) for a development install of the labextension you can run the following in this directory:
34+
As described in the [JupyterLab documentation](https://jupyterlab.readthedocs.io/en/stable/extension/extension_dev.html#extension-authoring) for a development install of the labextension you can run the following in this directory:
3835

3936
### Setup a local slurm cluster
4037

@@ -77,10 +74,11 @@ jlpm run build
7774
```
7875

7976
### Restart the jupyterlab docker container
77+
8078
```bash
8179
docker compose restart jupyterlab
8280

8381
# rerun munged on the jupyterlab instance
8482
docker compose exec jupyterlab bash
8583
runuser -u slurm -- munged
86-
```
84+
```

conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import pytest
2+
3+
pytest_plugins = ("pytest_jupyter.jupyter_server", )
4+
5+
6+
@pytest.fixture
7+
def jp_server_config(jp_server_config):
8+
return {"ServerApp": {"jpserver_extensions": {"jupyterlab_slurm": True}}}

jupyter-config/jupyter_notebook_config.d/jupyterlab_slurm.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
"jupyterlab_slurm": true
55
}
66
}
7-
}
7+
}

jupyterlab_slurm/tests/__init__.py

Whitespace-only changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import json
2+
3+
4+
async def test_get_example(jp_fetch):
5+
response = await jp_fetch("jupyterlab_slurm", "get_example")
6+
7+
assert response.code == 200
8+
payload = json.loads(response.body)
9+
expected_payload = {
10+
"data": "This is the /jupyterlab_slurm/get_example endpoint!"
11+
}
12+
assert payload == expected_payload

0 commit comments

Comments
 (0)