diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..972b58a8d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,92 @@ +name: CI + +on: [push] + +jobs: + js: + name: Lint and test JavaScript + runs-on: 'ubuntu-latest' + steps: + - uses: actions/checkout@v1 + - name: Use Node.js 12 + uses: actions/setup-node@v1 + with: + node-version: 12.x + - name: Install dependencies + run: npm ci + - name: Lint source + run: npm run lint + - uses: actions/checkout@v1 + - name: Use Node.js 12 + uses: actions/setup-node@v1 + with: + node-version: 12.x + - name: Install dependencies + run: npm ci + - name: Run tests + run: npm run test + - name: Run demo test + run: npm run test:demo + build: + name: Build package + runs-on: 'ubuntu-latest' + steps: + - uses: actions/checkout@v1 + - name: Use Node.js 12 + uses: actions/setup-node@v1 + with: + node-version: 12.x + - name: Install dependencies + run: npm ci + - name: Set up Python 3.8 + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - name: Install Dash + run: pip install dash[dev] + - name: Build dash-bootstrap-components + run: npm run build + - name: Upload generated files + uses: actions/upload-artifact@v2 + with: + name: dash-bootstrap-components + path: dash_bootstrap_components/_components + python: + name: Lint and test Python package + needs: build + runs-on: 'ubuntu-latest' + strategy: + max-parallel: 4 + matrix: + python-version: [2.7, 3.5, 3.6, 3.7, 3.8] + services: + hub: + image: selenium/hub:3.141.59-gold + firefox: + image: selenium/node-chrome:3.141.59-gold + env: + HUB_HOST: hub + HUB_PORT: 4444 + + steps: + - uses: actions/checkout@v1 + - name: Set up Python 3.8 + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - name: Set up Python ${{ matrix.python-version }} + if: matrix.python-version != '3.8' + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install nox + run: python3.8 -m pip install -U nox + - name: Lint Python source + if: matrix.python-version == 3.8 + run: nox -s lint + - uses: actions/download-artifact@v2 + with: + name: dash-bootstrap-components + path: dash_bootstrap_components/_components + - name: Test Python module + run: nox -s test-${{ matrix.python-version }} diff --git a/.gitignore b/.gitignore index 14dbb5442..3621e9bb5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,9 @@ node_modules lib -# sass -.sass-cache +# testing +.nox +.pytest_cache # dash-bootstrap-components artifacts dash_bootstrap_components/bundle.js diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5d26b824e..000000000 --- a/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ -language: python -cache: - directories: - - "node_modules" -install: - - "if [[ \"$GROUP\" == js ]] ; then pip install dash[dev] ; fi" - - "if [[ \"$GROUP\" == js ]] ; then npm -v ; fi" - - "if [[ \"$GROUP\" == js ]] ; then npm install ; fi" - - "if [[ \"$GROUP\" == python-linting ]] ; then pip install black flake8 isort>=4.3.5 ; fi" -script: - - "if [[ \"$GROUP\" == js ]] ; then npm run lint ; fi" - - "if [[ \"$GROUP\" == js ]] ; then npm run test ; fi" - - "if [[ \"$GROUP\" == js ]] ; then npm run test:demo ; fi" - - "if [[ \"$GROUP\" == js ]] ; then pip install .; fi" - - "if [[ \"$GROUP\" == python-linting ]] ; then black . --check ; fi" - - "if [[ \"$GROUP\" == python-linting ]] ; then flake8 ; fi" - - "if [[ \"$GROUP\" == python-linting ]] ; then isort -rc -c ; fi" - - "if [[ \"$GROUP\" == python-test ]] ; then python -m compileall dash_bootstrap_components ; fi" -matrix: - include: - - python: 3.6 - env: GROUP=python-linting - - python: 2.7 - env: GROUP=js - - python: 3.6 - env: GROUP=js - - python: 2.7 - env: GROUP=python-test - - python: 3.5 - env: GROUP=python-test - - python: 3.6 - env: GROUP=python-test diff --git a/noxfile.py b/noxfile.py new file mode 100644 index 000000000..8749d95dc --- /dev/null +++ b/noxfile.py @@ -0,0 +1,26 @@ +import nox + +SOURCES = [ + "dash_bootstrap_components", + "docs", + "examples", + "noxfile.py", + "setup.py", + "tasks.py", +] + + +@nox.session() +def lint(session): + session.install("black", "flake8", "isort") + session.run("black", "--check", *SOURCES) + session.run("flake8", *SOURCES) + session.run("isort", "--check", *SOURCES) + + +@nox.session(python=["2.7", "3.5", "3.6", "3.7", "3.8"]) +def test(session): + session.install("pytest") + session.install("dash[testing]") + session.install(".") + session.run("pytest", "--headless") diff --git a/setup.cfg b/setup.cfg index 9929ae211..4407c9378 100644 --- a/setup.cfg +++ b/setup.cfg @@ -42,6 +42,7 @@ ignore = E203, W503 [isort] multi_line_output = 3 include_trailing_comma = true +known_first_party = components_page, examples, markdown_to_html, server known_third_party = dash, dash_bootstrap_components, diff --git a/tasks.py b/tasks.py index b78566657..9b3f4dc65 100644 --- a/tasks.py +++ b/tasks.py @@ -12,6 +12,13 @@ VERSION_TEMPLATE = """__version__ = "{version_string}" """ +TEST_VERSION_TEMPLATE = """from dash_bootstrap_components import __version__ + + +def test_version(): + assert __version__ == "{version_string}" +""" + RELEASE_NOTES_TEMPLATE = """# Write the release notes here # Delete the version title to cancel Version {version_string} @@ -180,6 +187,10 @@ def set_pyversion(version): with version_path.open("w") as f: f.write(VERSION_TEMPLATE.format(version_string=version)) + test_version_path = HERE / "tests" / "test_version.py" + with test_version_path.open("w") as f: + f.write(TEST_VERSION_TEMPLATE.format(version_string=version)) + def set_jsversion(version): version = normalize_version(version) diff --git a/tests/test_alert.py b/tests/test_alert.py new file mode 100644 index 000000000..4ab370387 --- /dev/null +++ b/tests/test_alert.py @@ -0,0 +1,13 @@ +from dash import Dash +from dash_bootstrap_components import Alert +from dash_html_components import Div + + +def test_gene001_simple_callback(dash_duo): + app = Dash() + + app.layout = Div([Alert("Test content", id="alert")]) + + dash_duo.start_server(app) + + assert dash_duo.wait_for_element("#alert").text == "Test content" diff --git a/tests/test_version.py b/tests/test_version.py new file mode 100644 index 000000000..99d16b6b1 --- /dev/null +++ b/tests/test_version.py @@ -0,0 +1,5 @@ +from dash_bootstrap_components import __version__ + + +def test_version(): + assert __version__ == "0.10.4-dev"