Skip to content

Add GHA workflow for building MLIR Python bindings #7

Add GHA workflow for building MLIR Python bindings

Add GHA workflow for building MLIR Python bindings #7

name: mlir_bindings_conda_builder
on:
push:
branches:
- main
pull_request:
paths:
- .github/workflows/mlir_conda_builder.yml
- conda-recipes/mlir-python-bindings/**
workflow_dispatch:
inputs:
platform:
description: Conda Platform
default: linux-64
required: true
type: choice
options:
- all
- linux-64
# Add concurrency control
concurrency:
group: >-
${{ github.workflow }}-
${{ (github.event_name == 'push' && github.ref)
|| github.event.pull_request.number
|| toJson(github.event.inputs)
|| github.sha }}
cancel-in-progress: true
env:
ARTIFACT_RETENTION_DAYS: 7
jobs:
build:
name: ${{ matrix.platform }}-py${{ matrix.python-version }}-build
runs-on: ${{ matrix.runner }}
defaults:
run:
shell: bash -elx {0}
strategy:
matrix:
python-version: ["3.12"]
platform: ["linux-64"]
runner: ["ubuntu-24.04"]
fail-fast: false
steps:
- name: Clone repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0
with:
auto-update-conda: true
auto-activate-base: true
python-version: ${{ matrix.python-version }}
- name: Install conda-build
run: conda install conda-build
- name: Build mlir-python-bindings conda package
run: |
CONDA_CHANNEL_DIR="conda_channel_dir"
mkdir $CONDA_CHANNEL_DIR
conda build --debug -c defaults --python=${{ matrix.python-version }} conda-recipes/mlir-python-bindings --output-folder="${CONDA_CHANNEL_DIR}" --no-test
- name: Install and test conda package
run: |
CONDA_CHANNEL_DIR="conda_channel_dir"
conda install --use-local -c "file://${{ github.workspace }}/${CONDA_CHANNEL_DIR}" mlir-python-bindings
python conda-recipes/mlir-python-bindings/test.py
- name: Upload mlir-python-bindings conda package
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: mlir-python-bindings-${{ matrix.platform }}-py${{ matrix.python-version }}
path: conda_channel_dir
compression-level: 0
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error
- name: Show Workflow Run ID
run: "echo \"Workflow Run ID: ${{ github.run_id }}\""