Skip to content

Build

Build #150

Workflow file for this run

name: Build
on:
push:
branches: [ master ]
pull_request:
branches: '*'
release:
types: [published]
env:
PIP_DISABLE_PIP_VERSION_CHECK: 1
defaults:
run:
shell: bash -l {0}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup conda
uses: mamba-org/setup-micromamba@main
with:
environment-file: test-environment.yml
- name: Install bqplot
run: pip install --pre bqplot
- name: Install bqplot-gl
run: pip install . -vvv
- name: Test installation files
run: |
test -d $CONDA_PREFIX/share/jupyter/nbextensions/bqplot-gl
test -f $CONDA_PREFIX/share/jupyter/nbextensions/bqplot-gl/extension.js
test -f $CONDA_PREFIX/share/jupyter/nbextensions/bqplot-gl/index.js
test -d $CONDA_PREFIX/share/jupyter/labextensions/bqplot-gl
test -f $CONDA_PREFIX/share/jupyter/labextensions/bqplot-gl/package.json
test -d $CONDA_PREFIX/share/jupyter/labextensions/bqplot-gl/static
- name: Validate the labextension
run: jupyter labextension list 2>&1 | grep bqplot-gl
- name: Python PEP8 check
run: flake8 bqplot_gl --ignore=E501,W504,W503
- name: JavaScript prettyfier
run: jlpm run prettier:check
- name: Build Python package
run: python -m build
- name: Twine check
run: |
pip install --upgrade twine
twine check dist/*.whl dist/*.tar.gz
- name: Pack JavaScript package
run: |
jlpm pack -o bqplot-gl.tgz
mv bqplot-gl.tgz dist/
- name: Upload builds
uses: actions/upload-artifact@v5
with:
name: dist-${{ github.run_number }}
path: ./dist
visual-regression-tests:
runs-on: ubuntu-latest
needs: [build]
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup conda
uses: mamba-org/setup-micromamba@main
with:
environment-file: test-environment.yml
- uses: actions/download-artifact@v4
with:
name: dist-${{ github.run_number }}
path: ./dist
- name: Install the package
run: |
cd dist
pip install -vv bqplot*.whl
- name: Install dependencies
shell: bash -l {0}
working-directory: ui-tests
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: jlpm install
- name: Set up browser cache
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/pw-browsers
key: ${{ runner.os }}-${{ hashFiles('ui-tests/yarn.lock') }}
- name: Install browser
shell: bash -l {0}
run: npx playwright install chromium
working-directory: ui-tests
- name: Execute integration tests
shell: bash -l {0}
working-directory: ui-tests
run: npx playwright test
- name: Upload Playwright Test report
if: always()
uses: actions/upload-artifact@v5
with:
name: bqplot-playwright-tests
path: |
ui-tests/test-results
ui-tests/playwright-report
publish-pypi:
runs-on: ubuntu-latest
needs: [build, visual-regression-tests]
permissions:
id-token: write
environment:
name: ${{ github.event_name == 'release' && 'release-pypi' || '' }}
steps:
- uses: actions/download-artifact@v4
with:
name: dist-${{ github.run_number }}
path: ./dist
- name: Keep only PyPI artifacts
run: |
rm -f dist/*.tgz
ls -la dist/
- name: Verify tag matches wheel version
if: github.event_name == 'release'
run: |
TAG="${{ github.event.release.tag_name }}"
WHEEL_VERSION=$(ls dist/bqplot_gl-*.whl | sed -E 's|.*/bqplot_gl-([^-]+)-.*\.whl|\1|')
echo "Release tag: $TAG"
echo "Wheel version: $WHEEL_VERSION"
if [ "$TAG" != "$WHEEL_VERSION" ]; then
echo "::error::Release tag '$TAG' does not match wheel version '$WHEEL_VERSION'"
exit 1
fi
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Twine check
run: |
python -m pip install --upgrade pip twine
twine check dist/*.whl dist/*.tar.gz
- name: Publish to PyPI (Trusted Publisher)
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
publish-npm:
runs-on: ubuntu-latest
needs: [build, visual-regression-tests]
permissions:
id-token: write
contents: read
environment:
name: ${{ github.event_name == 'release' && 'release-npm' || '' }}
steps:
- uses: actions/download-artifact@v4
with:
name: dist-${{ github.run_number }}
path: ./dist
- uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Upgrade npm to a version that supports trusted publishing
run: npm install -g npm@latest
- name: Show npm package version
run: |
NPM_VERSION=$(tar -xOf dist/bqplot-gl.tgz package/package.json | node -p "JSON.parse(require('fs').readFileSync(0, 'utf8')).version")
echo "Will publish bqplot-gl@$NPM_VERSION"
echo "NPM_VERSION=$NPM_VERSION" >> "$GITHUB_ENV"
- name: Check npm version
id: npm_check
run: |
if npm view "bqplot-gl@$NPM_VERSION" version > /dev/null 2>&1; then
echo "already_published=true" >> "$GITHUB_OUTPUT"
echo "bqplot-gl@$NPM_VERSION is already on npm"
else
echo "already_published=false" >> "$GITHUB_OUTPUT"
echo "bqplot-gl@$NPM_VERSION not yet on npm"
fi
- name: Fail if releasing an already-published version
if: github.event_name == 'release' && steps.npm_check.outputs.already_published == 'true'
run: |
echo "::error::bqplot-gl@$NPM_VERSION is already on npm; bump package.json before releasing"
exit 1
- name: npm publish (dry-run)
if: github.event_name != 'release' && steps.npm_check.outputs.already_published == 'false'
run: npm publish ./dist/bqplot-gl.tgz --access public --dry-run
- name: Skip dry-run (version already published)
if: github.event_name != 'release' && steps.npm_check.outputs.already_published == 'true'
run: echo "::notice::bqplot-gl@$NPM_VERSION is already on npm; skipping dry-run. Bump package.json on a release-prep PR to exercise the full publish flow."
- name: npm publish (Trusted Publisher)
if: github.event_name == 'release'
run: npm publish ./dist/bqplot-gl.tgz --access public --provenance