Merge pull request #20 from DavidLee18/copilot/extend-plugin-function… #76
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
| name: CMake | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| jobs: | |
| update_version: | |
| if: ${{ github.event_name == 'push' }} | |
| permissions: | |
| contents: write | |
| runs-on: ubuntu-latest | |
| outputs: | |
| new_tag: ${{ steps.tag_version.outputs.new_tag }} | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| - name: Bump version and push tag | |
| id: tag_version | |
| uses: mathieudutour/github-tag-action@a22cf08638b34d5badda920f9daf6e72c477b07b | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| build-and-test: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # ubuntu-22.04: x86_64; ubuntu-24.04: x86_64; ubuntu-24.04-arm: arm64 | |
| os: [ubuntu-22.04, ubuntu-22.04-arm, ubuntu-24.04, ubuntu-24.04-arm] | |
| llvm_ver: [11, 12, 13, 14, 15, 16, 17, 18] | |
| exclude: | |
| # LLVM 11–13 are not available on Ubuntu 24.04 (noble) in the standard | |
| # repositories, and the official LLVM apt PPA for noble only provides | |
| # LLVM 18+. Test these versions on Ubuntu 22.04 (jammy) only. | |
| - os: ubuntu-22.04 | |
| llvm_ver: 16 | |
| - os: ubuntu-22.04 | |
| llvm_ver: 17 | |
| - os: ubuntu-22.04 | |
| llvm_ver: 18 | |
| - os: ubuntu-24.04 | |
| llvm_ver: 11 | |
| - os: ubuntu-24.04 | |
| llvm_ver: 12 | |
| - os: ubuntu-24.04 | |
| llvm_ver: 13 | |
| - os: ubuntu-22.04-arm | |
| llvm_ver: 16 | |
| - os: ubuntu-22.04-arm | |
| llvm_ver: 17 | |
| - os: ubuntu-22.04-arm | |
| llvm_ver: 18 | |
| - os: ubuntu-24.04-arm | |
| llvm_ver: 11 | |
| - os: ubuntu-24.04-arm | |
| llvm_ver: 12 | |
| - os: ubuntu-24.04-arm | |
| llvm_ver: 13 | |
| permissions: | |
| checks: write | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| - name: Build and Test | |
| env: | |
| LLVM_VER: ${{ matrix.llvm_ver }} | |
| run: | | |
| # On Ubuntu 22.04 (jammy), LLVM 15–18 are not in the standard Ubuntu | |
| # repos; add the official LLVM apt repository for those versions. | |
| # LLVM 11–14 are available in the standard universe repository on jammy. | |
| if [ "$(lsb_release -cs)" = "jammy" ] && [ "$LLVM_VER" -ge 15 ]; then | |
| wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key \ | |
| | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc >/dev/null | |
| printf 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-%s main\n' \ | |
| "$LLVM_VER" \ | |
| | sudo tee /etc/apt/sources.list.d/llvm-${LLVM_VER}.list | |
| sudo apt-get update -qq | |
| fi | |
| sudo apt-get install -y clang-${LLVM_VER} llvm-${LLVM_VER}-dev libclang-${LLVM_VER}-dev cmake | |
| # Install libmlir-N-dev where available and fully supported: | |
| # Ubuntu 24.04 (noble): LLVM 17 and 18 ship both translation headers | |
| # (LLVMIRToLLVMTranslation.h + BuiltinToLLVMIRTranslation.h). | |
| # LLVM 16 and below are missing one or both translation headers, so | |
| # MLIR builds are skipped for those versions. | |
| if [ "$(lsb_release -cs)" = "noble" ] && [ "$LLVM_VER" -ge 17 ] && [ "$LLVM_VER" -le 18 ]; then | |
| sudo apt-get install -y libmlir-${LLVM_VER}-dev mlir-${LLVM_VER}-tools | |
| MLIR_FLAGS="-DPAGURUS_WITH_MLIR=ON -DMLIR_DIR=/usr/lib/llvm-${LLVM_VER}/lib/cmake/mlir" | |
| MLIR_SUFFIX="-mlir" | |
| else | |
| MLIR_FLAGS="" | |
| MLIR_SUFFIX="" | |
| fi | |
| mkdir build && cd build | |
| cmake .. \ | |
| -DLLVM_DIR=$(llvm-config-${LLVM_VER} --cmakedir) \ | |
| -DClang_DIR=/usr/lib/llvm-${LLVM_VER}/lib/cmake/clang \ | |
| $MLIR_FLAGS | |
| make -j$(nproc) | |
| ctest --output-on-failure | |
| # Clean up any .pagurus.c files produced by tests running in compile mode. | |
| find ../tests -name '*.pagurus.c' -delete || true | |
| # Rename the artifact with OS and LLVM version for the upload step. | |
| mv pagurus_plugin.so ../pagurus-${{ matrix.os }}-llvm${LLVM_VER}-clang${MLIR_SUFFIX}.so | |
| - uses: LouisBrunner/checks-action@6b626ffbad7cc56fd58627f774b9067e6118af23 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| name: CMake & CTest (${{ matrix.os }}, LLVM ${{ matrix.llvm_ver }}) | |
| conclusion: ${{ job.status }} | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f | |
| if: ${{ github.event_name == 'push' }} | |
| with: | |
| name: ${{ matrix.os }}-llvm${{ matrix.llvm_ver }}-clang | |
| path: pagurus-${{ matrix.os }}-llvm${{ matrix.llvm_ver }}-clang*.so | |
| release: | |
| needs: [update_version, build-and-test] | |
| if: ${{ github.event_name == 'push' }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download all Artifacts | |
| uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 | |
| with: | |
| pattern: '*-llvm*-clang*' | |
| merge-multiple: true | |
| - name: Release | |
| uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b | |
| with: | |
| draft: true | |
| tag_name: ${{ needs.update_version.outputs.new_tag }} | |
| files: 'pagurus-*.so' |