Skip to content

Commit c5b4d5f

Browse files
author
Jesse Claven
authored
test: Detect generate failures (#1729)
Currently, since we don't exit on a command failure, it's been missed that generation is currently broken for the dataplane. You can see an example in these logs from a previous workflow (https://github.com/SeldonIO/MLServer/actions/runs/8880776962/job/24381621013). ``` Writing mypy to dataplane_pb2.pyi Traceback (most recent call last): File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/datamodel_code_generator/__main__.py", line 428, in main generate( File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/datamodel_code_generator/__init__.py", line 462, in generate results = parser.parse() File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/datamodel_code_generator/parser/base.py", line 1153, in parse self.parse_raw() File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/datamodel_code_generator/parser/openapi.py", line 571, in parse_raw specification: Dict[str, Any] = load_yaml(source.text) File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/datamodel_code_generator/__init__.py", line 51, in load_yaml return yaml.load(stream, Loader=SafeLoader) File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/yaml/__init__.py", line 81, in load return loader.get_single_data() File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/yaml/constructor.py", line 49, in get_single_data node = self.get_single_node() File "yaml/_yaml.pyx", line 673, in yaml._yaml.CParser.get_single_node File "yaml/_yaml.pyx", line 687, in yaml._yaml.CParser._compose_document File "yaml/_yaml.pyx", line 731, in yaml._yaml.CParser._compose_node File "yaml/_yaml.pyx", line 845, in yaml._yaml.CParser._compose_mapping_node File "yaml/_yaml.pyx", line 731, in yaml._yaml.CParser._compose_node File "yaml/_yaml.pyx", line 845, in yaml._yaml.CParser._compose_mapping_node File "yaml/_yaml.pyx", line 731, in yaml._yaml.CParser._compose_node File "yaml/_yaml.pyx", line 845, in yaml._yaml.CParser._compose_mapping_node File "yaml/_yaml.pyx", line 731, in yaml._yaml.CParser._compose_node File "yaml/_yaml.pyx", line 845, in yaml._yaml.CParser._compose_mapping_node File "yaml/_yaml.pyx", line 731, in yaml._yaml.CParser._compose_node File "yaml/_yaml.pyx", line 847, in yaml._yaml.CParser._compose_mapping_node File "yaml/_yaml.pyx", line 860, in yaml._yaml.CParser._parse_next_event yaml.scanner.ScannerError: mapping values are not allowed in this context in "<unicode string>", line 324, column 23 /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/grpc_tools/protoc.py:21: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html import pkg_resources Writing mypy to model_repository_pb2.pyi poetry run black . Skipping virtualenv creation, as specified in config file. Skipping .ipynb files as Jupyter dependencies are not installed. You can fix this by running ``pip install "black[jupyter]"`` reformatted /home/runner/work/MLServer/MLServer/mlserver/grpc/dataplane_pb2_grpc.py reformatted /home/runner/work/MLServer/MLServer/mlserver/grpc/model_repository_pb2.py reformatted /home/runner/work/MLServer/MLServer/mlserver/grpc/model_repository_pb2.pyi reformatted /home/runner/work/MLServer/MLServer/mlserver/grpc/dataplane_pb2.py reformatted /home/runner/work/MLServer/MLServer/mlserver/grpc/model_repository_pb2_grpc.py reformatted /home/runner/work/MLServer/MLServer/mlserver/grpc/dataplane_pb2.pyi reformatted /home/runner/work/MLServer/MLServer/mlserver/types/model_repository.py ``` This will now be detected/surfaced. This allows linting to go on and makes the generation check separate. The intent is to surface this failure but still let PRs go in, as they currently have, as we don't currently have (some) required status checks. I've also reduced what's installed for the lint job which dramatically speeds it up. Along with this, I've cleaned up run commands that didn't need multi-line syntax.
1 parent 3638be9 commit c5b4d5f

File tree

3 files changed

+43
-20
lines changed

3 files changed

+43
-20
lines changed

.github/workflows/tests.yml

+35-18
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,47 @@ on:
99
branches: [master]
1010

1111
jobs:
12+
generate:
13+
strategy:
14+
matrix:
15+
python-version: ["3.10"]
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
- name: Install Poetry
24+
uses: snok/install-poetry@v1
25+
with:
26+
virtualenvs-create: false
27+
- name: Install dependencies
28+
run: poetry install --sync --only dev
29+
- name: Generate
30+
run: make generate
31+
- name: Check for changes
32+
run: git --no-pager diff --exit-code .
33+
1234
lint:
35+
strategy:
36+
matrix:
37+
python-version: ["3.10"]
1338
runs-on: ubuntu-latest
1439
steps:
1540
- uses: actions/checkout@v4
16-
- name: Set up Python 3.10
41+
- name: Set up Python ${{ matrix.python-version }}
1742
uses: actions/setup-python@v5
1843
with:
19-
python-version: "3.10"
44+
python-version: ${{ matrix.python-version }}
2045
- name: Install Poetry
2146
uses: snok/install-poetry@v1
2247
with:
2348
virtualenvs-create: false
2449
- name: Install dependencies
25-
run: |
26-
make install-dev
50+
run: poetry install --sync --only dev
2751
- name: Lint
28-
run: |
29-
make lint
52+
run: make lint
3053

3154
mlserver:
3255
strategy:
@@ -72,11 +95,9 @@ jobs:
7295
with:
7396
virtualenvs-create: false
7497
- name: Install Dependencies
75-
run: |
76-
poetry install --sync --only dev
98+
run: poetry install --sync --only dev
7799
- name: Test
78-
run: |
79-
tox -e mlserver
100+
run: tox -e mlserver
80101

81102
runtimes:
82103
strategy:
@@ -116,11 +137,9 @@ jobs:
116137
with:
117138
virtualenvs-create: false
118139
- name: Install Dependencies
119-
run: |
120-
poetry install --sync --only dev
140+
run: poetry install --sync --only dev
121141
- name: Test
122-
run: |
123-
tox -c ./runtimes/${{ matrix.tox-environment }}
142+
run: tox -c ./runtimes/${{ matrix.tox-environment }}
124143

125144
# Ensure that having all the runtimes installed together works
126145
all-runtimes:
@@ -180,8 +199,6 @@ jobs:
180199
with:
181200
virtualenvs-create: false
182201
- name: Install Dependencies
183-
run: |
184-
poetry install --sync --only dev
202+
run: poetry install --sync --only dev
185203
- name: Test
186-
run: |
187-
tox -e all-runtimes
204+
run: tox -e all-runtimes

Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ test:
6767
tox -c $$_runtime; \
6868
done
6969

70-
lint: generate
70+
lint:
7171
black --check .
7272
flake8 .
7373
mypy ./mlserver
@@ -77,7 +77,9 @@ lint: generate
7777
done
7878
mypy ./benchmarking
7979
mypy ./docs/examples
80-
# Check if something has changed after generation
80+
81+
# Check if something has changed after generation
82+
lint-generate: generate
8183
git \
8284
--no-pager diff \
8385
--exit-code \

hack/generate-types.sh

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -Eeuo pipefail
4+
15
ROOT_FOLDER="$(dirname "${0}")/.."
26

37
_generatePB() {

0 commit comments

Comments
 (0)