forked from equinor/webviz-subsurface-components
-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (86 loc) · 3.62 KB
/
python.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: webviz-subsurface-components
defaults:
run:
working-directory: ./python
on:
push:
pull_request:
branches:
- master
release:
types:
- published
schedule:
# Run CI daily and check that tests are working with latest dependencies
- cron: "0 0 * * *"
jobs:
python:
# Run on all events defined above, except pushes which are not to master
if: github.event_name != 'push' || github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- name: 📖 Checkout commit locally
uses: actions/checkout@v4
- name: 🐍 Set up Python 3.8
uses: actions/setup-python@v5
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: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: 🐍 Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: 📦 Install build dependencies
# The deckgl types package runs a postscript to setup, but since we ignore scripts, we need to set it up manually.
run: |
# In https://github.com/equinor/webviz-subsurface-components/pull/1010 we
# loosened up npm constraint to include npm version using lockfileVersion: 1
# for downstream users. However in the development of this repository we
# want to limit ourselves to lockfileVersion: 3.
# While waiting for dropping node 14 and npm 6 support, we include this manual
# check:
grep -q '"lockfileVersion": 3,' ./package-lock.json
npm ci
pip install .[dependencies]
pip install dash[dev]
- name: 🏗️ Generate Dash components
run: |
npm run build
- name: 📦 Install webviz-subsurface-components with dependencies
run: |
pip install --upgrade pip
pip install "tables<3.9.0"
pip install .[tests]
- name: 🧾 List all installed packages
run: pip freeze
- name: 🕵️ Check code style, linting and typechecking
if: matrix.python-version == '3.8'
run: |
npm run validate
black --check webviz_subsurface_components/__init__.py webviz_subsurface_components/py_expression_eval.py webviz_subsurface_components/VectorCalculatorWrapper.py webviz_subsurface_components/VectorDefinitions.py setup.py
pylint webviz_subsurface_components/ setup.py
bandit -r -c ./bandit.yml webviz_subsurface_components/ setup.py
- 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: |
# Parse mono-repo tag (git tag format: "package@version")
echo ${{ github.ref_name }}
PACKAGE=`python -c "tag='${{ github.ref_name }}'; print(tag.split('@')[0])"`
VERSION=`python -c "tag='${{ github.ref_name }}'; print(tag.split('@')[1])"`
if [[ $PACKAGE != "dash-components" ]]; then
echo "Skipping deployment of $PACKAGE"
exit 0
fi
sed -i 's/# version = this is set automatically by CI/version="'"$VERSION"'",/' setup.py
python -m pip install --upgrade setuptools wheel twine
python setup.py sdist bdist_wheel
twine upload dist/*