Skip to content

Commit 498372a

Browse files
committed
feat: Replace Docker builds with conda-based CI workflows
Add conda/micromamba-based GitHub Actions workflows for building and testing ml-metadata wheels. Uses GCC 8.5.0 to match manylinux2014 compatibility, supports Python 3.9-3.11, and includes automated PyPI publishing.
1 parent 41be499 commit 498372a

File tree

4 files changed

+189
-0
lines changed

4 files changed

+189
-0
lines changed

.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ build --protocopt=--experimental_allow_proto3_optional
2323
# parameter 'user_link_flags' is deprecated and will be removed soon.
2424
# It may be temporarily re-enabled by setting --incompatible_require_linker_input_cc_api=false
2525
build --incompatible_require_linker_input_cc_api=false
26+
2627
build:macos --apple_platform_type=macos
2728
build:macos_arm64 --cpu=darwin_arm64

.github/workflows/conda-build.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Build ml-metadata with Conda
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: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-latest]
19+
python-version: ["3.9", "3.10", "3.11"]
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Micromamba
26+
uses: mamba-org/setup-micromamba@v1
27+
with:
28+
environment-file: ci/environment.yml
29+
cache-environment: true
30+
create-args: >-
31+
python=${{ matrix.python-version }}
32+
33+
- name: Display environment info
34+
shell: bash -l {0}
35+
run: |
36+
micromamba info
37+
micromamba list
38+
39+
- name: Install Bazel
40+
shell: bash -l {0}
41+
run: |
42+
# Install Bazelisk (manages Bazel versions)
43+
if [ "$RUNNER_OS" == "Linux" ]; then
44+
curl -Lo /tmp/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64
45+
elif [ "$RUNNER_OS" == "macOS" ]; then
46+
curl -Lo /tmp/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-darwin-amd64
47+
fi
48+
chmod +x /tmp/bazelisk
49+
sudo mv /tmp/bazelisk /usr/local/bin/bazel
50+
echo "USE_BAZEL_VERSION=6.1.0" >> $GITHUB_ENV
51+
bazel --version
52+
53+
- name: Build the package
54+
shell: bash -l {0}
55+
run: |
56+
python setup.py bdist_wheel
57+
58+
- name: Repair wheel (Linux)
59+
if: runner.os == 'Linux'
60+
shell: bash -l {0}
61+
run: |
62+
WHEEL_PATH="$(ls dist/*.whl)"
63+
WHEEL_DIR=$(dirname "${WHEEL_PATH}")
64+
auditwheel repair --plat manylinux2014_x86_64 -w "${WHEEL_DIR}" "${WHEEL_PATH}"
65+
rm "${WHEEL_PATH}"
66+
67+
- name: Upload wheel artifact
68+
uses: actions/upload-artifact@v4.4.0
69+
with:
70+
name: ml-metadata-wheel-${{ matrix.os }}-py${{ matrix.python-version }}
71+
path: dist/*.whl
72+
73+
upload_to_pypi:
74+
name: Upload to PyPI
75+
runs-on: ubuntu-latest
76+
if: (github.event_name == 'release' && startsWith(github.ref, 'refs/tags')) || (github.event_name == 'workflow_dispatch')
77+
needs: [build]
78+
environment:
79+
name: pypi
80+
url: https://pypi.org/p/ml-metadata/
81+
permissions:
82+
id-token: write
83+
steps:
84+
- name: Retrieve wheels
85+
uses: actions/download-artifact@v4.1.8
86+
with:
87+
merge-multiple: true
88+
path: wheels
89+
90+
- name: List the build artifacts
91+
run: |
92+
ls -lAs wheels/
93+
94+
- name: Upload to PyPI
95+
uses: pypa/gh-action-pypi-publish@release/v1.9
96+
with:
97+
packages_dir: wheels/

.github/workflows/conda-test.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Test ml-metadata with Conda
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: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-latest]
19+
python-version: ["3.9", "3.10", "3.11"]
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Micromamba
26+
uses: mamba-org/setup-micromamba@v1
27+
with:
28+
environment-file: ci/environment.yml
29+
cache-environment: true
30+
create-args: >-
31+
python=${{ matrix.python-version }}
32+
33+
- name: Display environment info
34+
shell: bash -l {0}
35+
run: |
36+
micromamba info
37+
micromamba list
38+
39+
- name: Install Bazel
40+
shell: bash -l {0}
41+
run: |
42+
# Install Bazelisk (manages Bazel versions)
43+
if [ "$RUNNER_OS" == "Linux" ]; then
44+
curl -Lo /tmp/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64
45+
elif [ "$RUNNER_OS" == "macOS" ]; then
46+
curl -Lo /tmp/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-darwin-amd64
47+
fi
48+
chmod +x /tmp/bazelisk
49+
sudo mv /tmp/bazelisk /usr/local/bin/bazel
50+
echo "USE_BAZEL_VERSION=6.1.0" >> $GITHUB_ENV
51+
bazel --version
52+
53+
- name: Build the package
54+
shell: bash -l {0}
55+
run: |
56+
python setup.py bdist_wheel
57+
58+
- name: Install built wheel (Linux/macOS)
59+
shell: bash -l {0}
60+
run: |
61+
pip install dist/*.whl
62+
63+
- name: Run tests
64+
shell: bash -l {0}
65+
run: |
66+
# cleanup (interferes with tests)
67+
rm -rf bazel-*
68+
# run tests
69+
pytest -vv

ci/environment.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Conda environment for building and testing ml-metadata on Linux
2+
name: mlmd-dev
3+
channels:
4+
- conda-forge
5+
dependencies:
6+
# Note: Bazel is installed separately via official installer (conda package is unreliable)
7+
- setuptools
8+
- wheel
9+
- pip
10+
- numpy
11+
- pytest
12+
- pytest-cov
13+
- patchelf # For wheel repair on Linux
14+
- cmake=3.29
15+
16+
# C/C++ compilers - GCC 8.x to match manylinux2014 devtoolset-8
17+
- gcc_linux-64=8.5.0
18+
- gxx_linux-64=8.5.0
19+
- sysroot_linux-64=2.17 # CentOS 7/manylinux2014 compatible glibc headers
20+
21+
- pip:
22+
- auditwheel # For manylinux wheel compliance

0 commit comments

Comments
 (0)