diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..2f2b3342 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,33 @@ +name: Build wheel + +on: + pull_request: + types: [opened, reopened] + branches: + - 'dev' + +jobs: + build-upload-wheel: + + uses: OpenBMB/BMTrain/.github/workflows/build_whl.yml@workflow + secrets: + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + + publish: + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set Up the Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Download distribution files + uses: actions/download-artifact@v2 + with: + name: dist + path: dist diff --git a/.github/workflows/build_whl.yml b/.github/workflows/build_whl.yml new file mode 100644 index 00000000..b8bbfcb9 --- /dev/null +++ b/.github/workflows/build_whl.yml @@ -0,0 +1,55 @@ +name: Build wheel + +on: + workflow_call: + secrets: + DOCKERHUB_TOKEN: + required: true + DOCKERHUB_USERNAME: + required: true + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['37', '38', '39', '310', '311'] + + + steps: + + - name: Check the disk space and clear unnecessary library + run: | + rm -rf /home/runner/work/BMTrain/BMTrain/dist + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + df -hl + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Pull Docker image + run: docker pull pytorch/manylinux-cuda113:latest + + - name: Run Docker image and execute script + run: | + version=${{ matrix.python-version }} + docker run -e BUILD_DOCKER_ENV=1 -e CUDACXX=/usr/local/cuda-11.3/bin/nvcc -e PATH="/opt/rh/devtoolset-9/root/usr/bin:$PATH" -e LD_LIBRARY_PATH="/opt/rh/devtoolset-9/root/usr/lib64:/opt/rh/devtoolset-9/root/usr/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64:$LD_LIBRARY_PATH" -v ${{ github.workspace }}:/workspace/BMTrain -i pytorch/manylinux-cuda113:latest /bin/bash -c "cd /workspace/BMTrain;/opt/python/cp${version}*/bin/pip install build; /opt/python/cp${version}*/bin/python -m build .;for file in dist/*-linux_x86_64.whl; do mv \"\$file\" \"\${file//-linux_x86_64/-manylinux2014_x86_64}\"; done" + + - name: Archive distribution files + uses: actions/upload-artifact@v2 + with: + name: dist + path: | + dist/*.tar.gz + dist/*.whl + + \ No newline at end of file