Feat/build libvnpu #34
This file contains hidden or 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
| # This workflow will build a golang project | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | |
| name: CI | |
| on: | |
| pull_request: | |
| branches: [ "main" ] | |
| env: | |
| GO_VERSION: "1.22.5" | |
| jobs: | |
| build-vnpu: | |
| runs-on: ubuntu-22.04-arm | |
| container: | |
| image: ghcr.io/dsfans2014/ascend-device-plugin/ascend-lib:0.2 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Build | |
| run: cargo build --release | |
| working-directory: ./libvnpu | |
| - name: Prepare artifacts for upload | |
| run: | | |
| mkdir -p ./lib/hami-vnpu-core/ | |
| cp libvnpu/target/release/limiter ./lib/hami-vnpu-core/ | |
| cp libvnpu/target/release/libvnpu.so ./lib/hami-vnpu-core/ | |
| echo "/vnpu/libvnpu.so" > ./lib/hami-vnpu-core/ld.so.preload | |
| - name: upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| if-no-files-found: error | |
| path: ./lib/hami-vnpu-core/* | |
| build: | |
| env: | |
| IMAGE_NAME: ${{ secrets.IMAGE_NAME || 'projecthami/ascend-device-plugin' }} | |
| runs-on: ubuntu-latest | |
| needs: ["build-vnpu"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| submodules: true | |
| - name: Get branch names. | |
| id: branch-names | |
| uses: tj-actions/branch-names@v8 | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| path: . | |
| - name: Find all downloaded files | |
| run: | | |
| echo "=== All files in workspace ===" | |
| ls -laR | |
| echo "=== Search for limiter ===" | |
| find . -name "limiter" -type f | |
| echo "=== Search for .so files ===" | |
| find . -name "*.so" -type f | |
| echo "=== Show artifact download location ===" | |
| echo "Artifacts are downloaded to: $(pwd)" | |
| echo "Content of current directory:" | |
| ls -la | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: linux/amd64 | |
| push: false | |
| build-args: | | |
| BASE_IMAGE=ubuntu:20.04 | |
| GO_VERSION=${{ env.GO_VERSION }} | |
| VERSION=${{ steps.branch-names.outputs.current_branch || steps.branch-names.outputs.tag }}-${{ github.sha }} | |
| tags: ${{ env.IMAGE_NAME }}:dev |