[build] Install all dependencies before compiling in Docker. #1358
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
pull_request: | |
push: | |
branches: | |
- "**" | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+" | |
jobs: | |
test_TAT_hpp: | |
name: test TAT.hpp | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: install mpi, openblas and gtest/gmock | |
run: sudo apt-get update && sudo apt-get install -y mpi-default-dev libopenblas-serial-dev libgtest-dev libgmock-dev | |
- name: make build directory | |
run: mkdir ${{runner.workspace}}/build | |
- name: configure | |
working-directory: ${{runner.workspace}}/build | |
run: cmake ${{github.workspace}} -DTAT_BUILD_PYTAT=OFF | |
- name: build | |
working-directory: ${{runner.workspace}}/build | |
run: make test_executables -j 2 | |
- name: ctest | |
working-directory: ${{runner.workspace}}/build | |
run: ctest -j 2 --verbose | |
test_lazy_py: | |
name: test lazy.py | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: setup python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.x" | |
- name: install pytest | |
run: pip install pytest pytest-cov | |
- name: run test | |
working-directory: ${{github.workspace}}/lazy_graph | |
run: python -m pytest | |
test_scalapack_py: | |
name: test scalapack.py | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: install mpi, scalapack | |
run: sudo apt-get update && sudo apt-get install -y mpi-default-dev libscalapack-mpi-dev | |
- name: setup python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.x" | |
- name: install pytest, mpi4py and numpy | |
run: pip install pytest pytest-cov pytest-mpi mpi4py numpy | |
- name: link scalapack library | |
working-directory: ${{github.workspace}}/PyScalapack | |
run: ln -s /usr/lib/x86_64-linux-gnu/libscalapack-openmpi.so libscalapack.so | |
- name: run test | |
working-directory: ${{github.workspace}}/PyScalapack | |
run: mpirun --oversubscribe -n 6 coverage run -m pytest && coverage combine && coverage report | |
env: | |
LD_LIBRARY_PATH: . | |
build_wheels_trigger: | |
name: trigger for building wheels | |
runs-on: ubuntu-latest | |
needs: [test_TAT_hpp, test_lazy_py, test_scalapack_py] | |
if: "github.event_name == 'push' && (startsWith(github.ref, 'refs/tags') || contains(toJSON(github.event.commits.*.message), '[force ci]'))" | |
steps: | |
- name: nothing | |
run: echo this is an empty job | |
generate_python_markdown_readme: | |
name: generate README.md for python package | |
runs-on: ubuntu-latest | |
needs: build_wheels_trigger | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- package: PyTAT | |
- package: tnsp_bridge | |
- package: lazy_graph | |
- package: tetragono | |
- package: tetraku | |
- package: PyScalapack | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: install emacs | |
run: sudo apt-get update && sudo apt-get install -y emacs | |
- name: export to markdown | |
run: emacs ${{matrix.package}}/README.org --batch -f org-md-export-to-markdown --kill | |
- name: upload to artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: README-of-${{matrix.package}} | |
path: ${{matrix.package}}/README.md | |
build_pytat_wasm_wheels: | |
name: build PyTAT wheels for emscripten | |
runs-on: ubuntu-latest | |
needs: [build_wheels_trigger, generate_python_markdown_readme] | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- python: "3.11" | |
pyodide: "0.25.1" | |
- python: "3.12" | |
pyodide: "0.26.2" | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: recovery tag information | |
run: git fetch --tags --force | |
# See: https://github.com/actions/checkout/issues/290 | |
- name: setup python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: setup node | |
uses: actions/setup-node@v3 | |
- name: prepare | |
run: | | |
python -m pip install pyodide-build==${{ matrix.pyodide }} | |
git clone https://github.com/emscripten-core/emsdk.git | |
cd emsdk | |
pyodide config list | |
PYODIDE_EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version) | |
./emsdk install ${PYODIDE_EMSCRIPTEN_VERSION} | |
./emsdk activate ${PYODIDE_EMSCRIPTEN_VERSION} | |
- name: build | |
run: | | |
source emsdk/emsdk_env.sh | |
cd PyTAT | |
export SKBUILD_CMAKE_DEFINE="PYBIND11_FINDPYTHON=ON;TAT_MATH_LIBRARIES=" | |
export CMAKE_BUILD_PARALLEL_LEVEL=4 | |
pyodide build --exports pyinit | |
- name: test | |
run: | | |
cd PyTAT | |
npm install pyodide@$(echo ${{ matrix.pyodide }} | sed 's/a/-alpha./' | sed 's/b/-beta./') | |
node test_wasm.js || node test_wasm.js || node test_wasm.js || node test_wasm.js | |
- name: upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: emscripten | |
path: PyTAT/dist/*.whl | |
build_pytat_wheels: | |
name: build PyTAT wheels | |
runs-on: ${{ matrix.os }} | |
needs: [build_wheels_trigger, generate_python_markdown_readme] | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# Always support manylinux platform | |
- os: ubuntu-latest | |
python: 38 | |
platform_id: manylinux_x86_64 | |
- os: ubuntu-latest | |
python: 39 | |
platform_id: manylinux_x86_64 | |
- os: ubuntu-latest | |
python: 310 | |
platform_id: manylinux_x86_64 | |
- os: ubuntu-latest | |
python: 311 | |
platform_id: manylinux_x86_64 | |
- os: ubuntu-latest | |
python: 312 | |
platform_id: manylinux_x86_64 | |
- os: ubuntu-latest | |
python: 38 | |
platform_id: manylinux_aarch64 | |
- os: ubuntu-latest | |
python: 39 | |
platform_id: manylinux_aarch64 | |
- os: ubuntu-latest | |
python: 310 | |
platform_id: manylinux_aarch64 | |
- os: ubuntu-latest | |
python: 311 | |
platform_id: manylinux_aarch64 | |
- os: ubuntu-latest | |
python: 312 | |
platform_id: manylinux_aarch64 | |
# Always support musllinux platform | |
- os: ubuntu-latest | |
python: 38 | |
platform_id: musllinux_x86_64 | |
- os: ubuntu-latest | |
python: 39 | |
platform_id: musllinux_x86_64 | |
- os: ubuntu-latest | |
python: 310 | |
platform_id: musllinux_x86_64 | |
- os: ubuntu-latest | |
python: 311 | |
platform_id: musllinux_x86_64 | |
- os: ubuntu-latest | |
python: 312 | |
platform_id: musllinux_x86_64 | |
- os: ubuntu-latest | |
python: 38 | |
platform_id: musllinux_aarch64 | |
- os: ubuntu-latest | |
python: 39 | |
platform_id: musllinux_aarch64 | |
- os: ubuntu-latest | |
python: 310 | |
platform_id: musllinux_aarch64 | |
- os: ubuntu-latest | |
python: 311 | |
platform_id: musllinux_aarch64 | |
- os: ubuntu-latest | |
python: 312 | |
platform_id: musllinux_aarch64 | |
# Only support the latest two version for macos platform | |
- os: macos-latest | |
python: 311 | |
platform_id: macosx_x86_64 | |
mac_arch: x86_64 | |
- os: macos-latest | |
python: 312 | |
platform_id: macosx_x86_64 | |
mac_arch: x86_64 | |
- os: macos-latest | |
python: 311 | |
platform_id: macosx_arm64 | |
mac_arch: arm64 | |
- os: macos-latest | |
python: 312 | |
platform_id: macosx_arm64 | |
mac_arch: arm64 | |
# Only support latest four version for windows platform | |
- os: windows-latest | |
python: 39 | |
platform_id: win_amd64 | |
- os: windows-latest | |
python: 310 | |
platform_id: win_amd64 | |
- os: windows-latest | |
python: 311 | |
platform_id: win_amd64 | |
- os: windows-latest | |
python: 312 | |
platform_id: win_amd64 | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: recovery tag information | |
run: git fetch --tags --force | |
# See: https://github.com/actions/checkout/issues/290 | |
- name: setup python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.x" | |
- name: install cibuildwheel | |
run: python -m pip install cibuildwheel | |
- name: download artifacts for PyTAT | |
uses: actions/download-artifact@v3 | |
with: | |
name: README-of-PyTAT | |
path: PyTAT | |
- name: set up qemu for linux arm64 | |
if: "contains(matrix.platform_id, 'aarch64')" | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: arm64 | |
- name: build wheel for PyTAT | |
env: | |
CIBW_TEST_REQUIRES: pytest | |
CIBW_TEST_COMMAND: pytest {project}/PyTAT/tests | |
CIBW_TEST_SKIP: "*-macosx_arm64" | |
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }} | |
CIBW_ARCHS: all | |
CIBW_BEFORE_ALL_LINUX: yum install -y epel-release && yum install -y openblas-devel || apk add openblas-dev | |
CIBW_BEFORE_ALL_WINDOWS: python .github/scripts/get_openblas_for_windows.py | |
CIBW_BEFORE_ALL_MACOS: "" | |
CIBW_ENVIRONMENT_LINUX: CMAKE_BUILD_PARALLEL_LEVEL=4 | |
CIBW_ENVIRONMENT_WINDOWS: CMAKE_BUILD_PARALLEL_LEVEL=4 SKBUILD_CMAKE_ARGS=-GNinja SKBUILD_CMAKE_DEFINE="CMAKE_C_COMPILER=clang;CMAKE_CXX_COMPILER=clang++;TAT_MATH_LIBRARIES=D:/a/TNSP/TNSP/lib/libopenblas.lib" | |
CIBW_ENVIRONMENT_MACOS: CMAKE_BUILD_PARALLEL_LEVEL=6 SKBUILD_CMAKE_DEFINE="CMAKE_OSX_ARCHITECTURES=${{ matrix.mac_arch }}" | |
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: cmd /c python -m pip install delvewheel && python -m delvewheel repair --wheel-dir {dest_dir} {wheel} --add-path bin | |
CIBW_BUILD_VERBOSITY: 1 | |
MACOSX_DEPLOYMENT_TARGET: 10.14 | |
run: python -m cibuildwheel PyTAT --output-dir dist | |
- name: upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
path: dist/*.whl | |
build_pure_python_wheels: | |
name: build pure python wheels | |
runs-on: ubuntu-latest | |
needs: [build_wheels_trigger, generate_python_markdown_readme] | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- package: tnsp_bridge | |
- package: lazy_graph | |
- package: tetragono | |
- package: tetraku | |
- package: PyScalapack | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: recovery tag information | |
run: git fetch --tags --force | |
# See: https://github.com/actions/checkout/issues/290 | |
- name: setup python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.x" | |
- name: install python build | |
run: python -m pip install build | |
- name: download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: README-of-${{matrix.package}} | |
path: ${{matrix.package}} | |
- name: build wheel | |
working-directory: ${{github.workspace}}/${{matrix.package}} | |
run: python -m build | |
- name: upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
path: ${{github.workspace}}/${{matrix.package}}/dist/*.whl | |
release_trigger: | |
name: trigger for release | |
runs-on: ubuntu-latest | |
needs: [build_pytat_wheels, build_pytat_wasm_wheels, build_pure_python_wheels] | |
if: "startsWith(github.ref, 'refs/tags')" | |
steps: | |
- name: nothing | |
run: echo this is an empty job | |
upload_pypi: | |
name: upload wheels to pypi | |
runs-on: ubuntu-latest | |
needs: [release_trigger] | |
environment: release | |
permissions: | |
id-token: write | |
steps: | |
- name: download artifacts | |
uses: actions/download-artifact@v3 | |
- name: setup python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.x" | |
- name: upload | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: artifact | |
create_release: | |
name: create github release | |
runs-on: ubuntu-latest | |
needs: [release_trigger] | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: recovery tag information | |
run: git fetch --tags --force | |
# See: https://github.com/actions/checkout/issues/290 | |
- name: install emacs | |
run: sudo apt-get update && sudo apt-get install -y emacs | |
- name: export to markdown | |
run: emacs CHANGELOG.org --batch -f org-md-export-to-markdown --kill | |
- name: install setuptools_scm | |
run: python -m pip install setuptools_scm | |
- name: generate release description | |
run: python .github/scripts/generate_release_description.py | |
- name: download artifacts | |
uses: actions/download-artifact@v3 | |
- name: release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
artifact/*.whl | |
emscripten/*.whl | |
body_path: release_description.md |