Skip to content

Add build and test github action before each PR #21

Add build and test github action before each PR

Add build and test github action before each PR #21

name: Build and test
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest]
build_type: [Release]
c_compiler: [clang]
include:
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
env:
CACHE_DIR: ${{ github.workspace }}/.ccache
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.GITHUB_TOKEN }}
# - name: Enable cache
# uses: actions/cache/restore@v3
# with:
# path: ${{ env.CACHE_DIR }}
# key: build-test-cpp-asserts-manylinux-${{ github.sha }}
# restore-keys: |
# build-test-cpp-asserts-manylinux-
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Setup Python Version
uses: actions/setup-python@v5
with:
python-version: 3.11 # Install the python version needed
- name: Set PYTHONPATH
run: export PYTHONPATH=build/tools/torch-mlir/python_packages/torch_mlir:build/tools/mpact/python_packages/mpact
shell: bash
- name: ccache
uses: hendrikmuhs/[email protected]
- name: Install requirements
run: |
export CCACHE_DIR="$HOME/.ccache"
echo "$PWD"
echo "$CCACHE_DIR"
ls "$CCACHE_DIR"
python -m pip install --upgrade pip
python -m pip install -r externals/torch-mlir/requirements.txt
python -m pip install -r externals/torch-mlir/torchvision-requirements.txt
- name: Create build directory
run: mkdir build
- name: Configure CMake
run: >
cmake -GNinja -Bbuild
-DCMAKE_BUILD_TYPE=Release
-DLLVM_ENABLE_PROJECTS=mlir
-DLLVM_EXTERNAL_PROJECTS="torch-mlir;mpact"
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="${PWD}/externals/torch-mlir"
-DLLVM_EXTERNAL_MPACT_SOURCE_DIR="${PWD}"
-DLLVM_TARGETS_TO_BUILD=host
-DMLIR_ENABLE_BINDINGS_PYTHON=ON
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
"externals/torch-mlir/externals/llvm-project/llvm"
- name: Build
# run: cmake --build build --config ${{ matrix.build_type }} --target check-mpact
run: ninja -C build -k 0 check-mpact
# - name: Save cache
# uses: actions/cache/save@v3
# if: ${{ !cancelled() }}
# with:
# path: ${{ env.CACHE_DIR }}
# key: build-test-cpp-asserts-manylinux-${{ github.sha }}