Skip to content

Commit a3e9286

Browse files
authored
Merge pull request #206 from aktech/build-package
Add workflow to build and test ml-metadata
2 parents 398994b + e1838b6 commit a3e9286

File tree

8 files changed

+247
-117
lines changed

8 files changed

+247
-117
lines changed

.github/reusable-build/action.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Resusable steps to build ml-metadata
2+
3+
inputs:
4+
python-version:
5+
description: 'Python version'
6+
required: true
7+
runs:
8+
using: 'composite'
9+
steps:
10+
11+
- name: Set up Python ${{ inputs.python-version }}
12+
uses: actions/setup-python@v5
13+
with:
14+
python-version: ${{ inputs.python-version }}
15+
16+
- name: Upgrade pip
17+
shell: bash
18+
run: |
19+
python -m pip install --upgrade pip pytest
20+
21+
- name: Build the package for Python ${{ inputs.python-version }}
22+
shell: bash
23+
run: |
24+
version="${{ inputs.python-version }}"
25+
DOCKER_SERVICE=manylinux-python$(echo "$version" | sed 's/\.//')
26+
docker compose build ${DOCKER_SERVICE}
27+
docker compose run ${DOCKER_SERVICE}
28+
29+
- name: Upload wheel artifact for Python ${{ inputs.python-version }}
30+
uses: actions/upload-artifact@v4.4.0
31+
with:
32+
name: ml-metadata-wheel-py${{ inputs.python-version }}
33+
path: dist/*.whl
34+
35+
- name: Install built wheel
36+
shell: bash
37+
run: pip install dist/*.whl

.github/workflows/build.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build ml-metadata
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
python-version: ["3.9", "3.10", "3.11"]
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Build ml-metadata
24+
id: build-ml-metadata
25+
uses: ./.github/reusable-build
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
29+
upload_to_pypi:
30+
name: Upload to PyPI
31+
runs-on: ubuntu-latest
32+
if: (github.event_name == 'release' && startsWith(github.ref, 'refs/tags')) || (github.event_name == 'workflow_dispatch')
33+
needs: [build]
34+
environment:
35+
name: pypi
36+
url: https://pypi.org/p/ml-metadata/
37+
permissions:
38+
id-token: write
39+
steps:
40+
- name: Retrieve wheels
41+
uses: actions/download-artifact@v4.1.8
42+
with:
43+
merge-multiple: true
44+
path: wheels
45+
46+
- name: List the build artifacts
47+
run: |
48+
ls -lAs wheels/
49+
50+
- name: Upload to PyPI
51+
uses: pypa/gh-action-pypi-publish@release/v1.9
52+
with:
53+
packages_dir: wheels/

.github/workflows/test.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Test ml-metadata
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
workflow_dispatch:
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
python-version: ["3.9", "3.10", "3.11"]
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Build ml-metadata
24+
id: build-ml-metadata
25+
uses: ./.github/reusable-build
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
29+
- name: Test
30+
run: |
31+
# cleanup (interferes with tests)
32+
rm -rf bazel-*
33+
# run tests
34+
pytest -vv

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ Then, run the following at the project root:
5353

5454
```bash
5555
DOCKER_SERVICE=manylinux-python${PY_VERSION}
56-
sudo docker-compose build ${DOCKER_SERVICE}
57-
sudo docker-compose run ${DOCKER_SERVICE}
56+
sudo docker compose build ${DOCKER_SERVICE}
57+
sudo docker compose run ${DOCKER_SERVICE}
5858
```
5959

6060
where `PY_VERSION` is one of `{39, 310, 311}`.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def pytest_addoption(parser):
2+
parser.addoption(
3+
'--use_grpc_backend', action='store_true', default=False,
4+
help='Set this to true to use gRPC instead of sqlLite backend.'
5+
)
6+
parser.addoption(
7+
'--grpc_host', type=str, default=None,
8+
help="The gRPC host name to use when use_grpc_backed is set to 'True'"
9+
)
10+
parser.addoption(
11+
'--grpc_port', type=int, default=0,
12+
help="The gRPC port number to use when use_grpc_backed is set to 'True'"
13+
)

0 commit comments

Comments
 (0)