webviz-core-components #2111
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: webviz-core-components | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
release: | |
types: | |
- published | |
schedule: | |
# Run CI daily and check that tests are working with latest dependencies | |
- cron: "0 0 * * *" | |
jobs: | |
webviz-core-components: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
steps: | |
- name: 📖 Checkout commit locally | |
uses: actions/checkout@v3 | |
- name: 🐍 Set up Python 3.8 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.8 # For compiling the JavaScript part we need dash<2.5, which is not supported on recent versions of Python | |
- name: ℹ️ Node and npm versions | |
run: | | |
node -v | |
npm -v | |
- name: 📦 Install build dependencies | |
run: | | |
npm ci --ignore-scripts --prefix ./react | |
npm run copy-package-json --prefix ./react | |
pip install "dash<2.5" # Build issue upstream in dash==2.5 | |
pip install .[dependencies] | |
pip install dash[dev] | |
- name: ℹ️ Installed npm packages (depth = 0) | |
run: npm list --depth=0 --prefix react/ | |
- name: 🏗️ Build JavaScript part | |
run: | | |
npm run build --prefix ./react | |
- name: 🐍 Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: 📦 Install webviz-core-components with dependencies | |
run: | | |
pip install --upgrade pip | |
pip install . | |
- name: 📦 Install test dependencies | |
run: | | |
pip install .[tests] | |
pip install dash[testing] | |
wget https://chromedriver.storage.googleapis.com/$(wget https://chromedriver.storage.googleapis.com/LATEST_RELEASE -q -O -)/chromedriver_linux64.zip | |
unzip chromedriver_linux64.zip | |
- name: 🧾 List all installed packages | |
run: pip freeze | |
- name: 🕵️ Check code style & linting | |
if: matrix.python-version == '3.8' | |
run: | | |
npm run validate --prefix ./react | |
black --check webviz_core_components tests setup.py usage.py | |
pylint webviz_core_components/ tests/*.py setup.py usage.py | |
bandit -r -c ./bandit.yml webviz_core_components tests setup.py usage.py | |
- name: 🤖 Run tests | |
run: | |
# npm run test --prefix ./react | |
pytest ./tests --headless | |
- name: ⏭️ Set next as npm publish tag if prerelease | |
if: github.event.release.prerelease | |
run: echo "NPM_PUBLISH_TAG=next" >> $GITHUB_ENV | |
- name: 🔼 Build and publish Node.js package | |
if: github.event_name == 'release' && matrix.python-version == '3.8' | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
working-directory: ./react | |
run: | | |
cp ../README.md . | |
npm version --no-git-tag-version ${GITHUB_REF//refs\/tags\//} | |
npm config set '//registry.npmjs.org/:_authToken' '${NPM_TOKEN}' | |
# Use 'latest' tag if $NPM_PUBLISH_TAG is not set: | |
npm publish --access public --tag ${NPM_PUBLISH_TAG:-latest} | |
- name: 🚢 Build and deploy Python package | |
if: github.event_name == 'release' && matrix.python-version == '3.8' | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.pypi_webviz_token }} | |
run: | | |
export SETUPTOOLS_SCM_PRETEND_VERSION=${GITHUB_REF//refs\/tags\//} | |
python -m pip install --upgrade setuptools wheel twine | |
python setup.py sdist bdist_wheel | |
twine upload dist/* |