Skip to content

Commit

Permalink
Merge pull request #299
Browse files Browse the repository at this point in the history
ci: improve ci
  • Loading branch information
mariobuikhuizen authored Feb 28, 2024
2 parents 778deaa + 6850dc3 commit 8a6a636
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 31 deletions.
56 changes: 49 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: Build

on:
- push
- pull_request
- workflow_dispatch
push:
branches:
- master
pull_request:
workflow_dispatch:

jobs:
lint:
Expand All @@ -26,15 +28,13 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 16.x

- name: install build
run: python -m pip install build

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install "reacton[generate]" ipyvue
- name: build wheel
run: python -m build

Expand All @@ -44,6 +44,8 @@ jobs:
python -m ipyvuetify.components
diff ipyvuetify/components.py ipyvuetify/components-previous.py
- name: Package js
run: (cd js && npm pack)
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -103,9 +105,48 @@ jobs:
name: ipyvuetify-test-results
path: test-results

release-dry-run:
needs: [test, ui-test]
runs-on: ubuntu-20.04
steps:
- uses: actions/download-artifact@v3
with:
name: ipyvuetify-dist-${{ github.run_number }}

- name: Install node
uses: actions/setup-node@v1
with:
node-version: "14.x"
registry-url: "https://registry.npmjs.org"

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install twine
- name: Publish the Python package
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: twine upload --skip-existing --repository testpypi dist/*

- name: Publish the NPM package
run: |
cd js
echo $PRE_RELEASE
if [[ $PRE_RELEASE == "true" ]]; then export TAG="next"; else export TAG="latest"; fi
npm publish --dry-run --tag ${TAG} --access public *.tgz
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
PRE_RELEASE: ${{ github.event.release.prerelease }}

release:
if: startsWith(github.event.ref, 'refs/tags/v')
needs: [test]
needs: [release-dry-run]
runs-on: ubuntu-20.04
steps:
- uses: actions/download-artifact@v3
Expand All @@ -126,7 +167,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install twine wheel jupyter-packaging jupyterlab
pip install twine
- name: Publish the Python package
env:
Expand All @@ -136,6 +177,7 @@ jobs:

- name: Publish the NPM package
run: |
cd js
echo $PRE_RELEASE
if [[ $PRE_RELEASE == "true" ]]; then export TAG="next"; else export TAG="latest"; fi
npm publish --tag ${TAG} --access public *.tgz
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ ipyvuetify/generated
js/src/generated

# Compiled javascript
ipyvuetify/labextension/
ipyvuetify/nbextension/
prefix/share
js/lib

# Unit test / coverage reports
Expand Down
7 changes: 2 additions & 5 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
include LICENSE
recursive-include ipyvuetify/nbextension *.*
recursive-include ipyvuetify/labextension *.*
include jupyter-vuetify.json
recursive-include prefix *.*
recursive-include ipyvuetify/extra *.vue
recursive-include generate_source/ *.*
recursive-include js/ *.*
recursive-include ipyvuetify/generated *.*
2 changes: 1 addition & 1 deletion generate_source/generate_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def generate():

generate_schema(vuetify_api, base_schema, widget_gen_schema)

NPMPackage(here / "package.json").install()
NPMPackage(here / "package.json")._run_npm("ci")

reset_dir(destination_js)

Expand Down
16 changes: 14 additions & 2 deletions ipyvuetify/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,22 @@
from .VuetifyTemplate import VuetifyTemplate


def _prefix():
import sys
from pathlib import Path

prefix = sys.prefix
here = Path(__file__).parent
# for when in dev mode
if (here.parent / "prefix").exists():
prefix = str(here.parent)
return prefix


def _jupyter_labextension_paths():
return [
{
"src": "labextension",
"src": f"{_prefix()}/prefix/share/jupyter/labextensions/jupyter-vuetify/",
"dest": "jupyter-vuetify",
}
]
Expand All @@ -18,7 +30,7 @@ def _jupyter_nbextension_paths():
return [
{
"section": "notebook",
"src": "nbextension",
"src": f"{_prefix()}/prefix/share/jupyter/nbextensions/jupyter-vuetify/",
"dest": "jupyter-vuetify",
"require": "jupyter-vuetify/extension",
}
Expand Down
4 changes: 2 additions & 2 deletions js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"watch:webpack": "webpack --mode development --watch",
"watch": "run-p watch:*",
"clean": "rimraf lib/ dist/",
"prepare": "run-s build:*",
"build": "run-s build:*",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
Expand Down Expand Up @@ -66,7 +66,7 @@
},
"jupyterlab": {
"extension": "lib/labplugin",
"outputDir": "../ipyvuetify/labextension",
"outputDir": "../prefix/share/jupyter/labextensions/jupyter-vuetify",
"webpackConfig": "webpack.config.lab3.js",
"sharedPackages": {
"@jupyter-widgets/base": {
Expand Down
30 changes: 27 additions & 3 deletions js/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ module.exports = [
entry: "./lib/extension.js",
output: {
filename: "extension.js",
path: path.resolve(__dirname, "..", "ipyvuetify", "nbextension"),
path: path.resolve(
__dirname,
"..",
"prefix",
"share",
"jupyter",
"nbextensions",
"jupyter-vuetify"
),
libraryTarget: "amd",
},
mode: "production",
Expand All @@ -39,7 +47,15 @@ module.exports = [
entry: "./lib/notebook.js",
output: {
filename: "index.js",
path: path.resolve(__dirname, "..", "ipyvuetify", "nbextension"),
path: path.resolve(
__dirname,
"..",
"prefix",
"share",
"jupyter",
"nbextensions",
"jupyter-vuetify"
),
libraryTarget: "amd",
},
devtool: "source-map",
Expand All @@ -62,7 +78,15 @@ module.exports = [
entry: "./lib/nodeps.js",
output: {
filename: "nodeps.js",
path: path.resolve(__dirname, "..", "ipyvuetify", "nbextension"),
path: path.resolve(
__dirname,
"..",
"prefix",
"share",
"jupyter",
"nbextensions",
"jupyter-vuetify"
),
libraryTarget: "amd",
},
devtool: "source-map",
Expand Down
File renamed without changes.
25 changes: 16 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
ROOT = Path(__file__).parent
sys.path.append(str(ROOT))

from generate_source import generate_source # noqa


def update_package_data(distribution) -> None:
"""Update package_data to catch changes during setup"""
Expand All @@ -31,8 +29,14 @@ class DecoratedCommand(command):

def run(self):
"""Run the command"""
NPMPackage(ROOT / "js" / "package.json").install()
generate_source.generate()
if sys.argv[1] == "sdist" or sys.argv[1] == "dist_info":
from generate_source import generate_source

npm = NPMPackage(ROOT / "js" / "package.json")
npm._run_npm("ci")
generate_source.generate()
npm.run_script("build")

self.distribution.data_files = get_data_files()
command.run(self)

Expand All @@ -41,11 +45,14 @@ def run(self):

def get_data_files():
"""files that need to be installed in specific locations upon installation."""

nbext = [rel(f) for f in ROOT.glob("ipyvuetify/nbextension/*")]
package = [rel(f) for f in ROOT.glob("ipyvuetify/labextension/package.json")]
labext = [rel(f) for f in ROOT.glob("ipyvuetify/labextension/static/*")]
nbconfig = [rel(f) for f in ROOT.glob("jupyter-vuetify.json")]
nbext = [rel(f) for f in ROOT.glob("prefix/share/jupyter/nbextensions/jupyter-vuetify/*")]
package = [
rel(f) for f in ROOT.glob("prefix/share/jupyter/labextensions/jupyter-vuetify/package.json")
]
labext = [
rel(f) for f in ROOT.glob("prefix/share/jupyter/labextensions/jupyter-vuetify/static/*")
]
nbconfig = [rel(f) for f in ROOT.glob("prefix/etc/nbconfig/notebook.d/jupyter-vuetify.json")]

return [
("share/jupyter/nbextensions/jupyter-vuetify", nbext),
Expand Down

0 comments on commit 8a6a636

Please sign in to comment.