|
| 1 | +name: Build and Test |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + release: |
| 7 | + types: |
| 8 | + - created |
| 9 | + |
| 10 | +env: |
| 11 | + BUILD_TYPE: Release |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + build_type: [Release] |
| 20 | + os: [ubuntu-18.04, windows-latest] |
| 21 | + include: |
| 22 | + - os: ubuntu-18.04 |
| 23 | + build_type: Debug |
| 24 | + - os: windows-latest |
| 25 | + build_type: Debug |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v2 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + - if: contains(matrix.os, 'ubuntu') |
| 31 | + name: Get Dependencies |
| 32 | + run: | |
| 33 | + sudo apt-get update |
| 34 | + sudo apt-get install p7zip-full build-essential zlib1g-dev freeglut3-dev liblapacke-dev libopenblas-dev libatlas-base-dev libpcap-dev python3 python3-pip apt-transport-https dotnet-sdk-3.1 libpcap-dev python-virtualenv ninja-build libeigen3-dev ${{ matrix.deps }} |
| 35 | + - uses: actions/setup-python@v2 |
| 36 | + with: |
| 37 | + python-version: '3.x' |
| 38 | + - name: Setup windows flags |
| 39 | + if: contains(matrix.os, 'windows') && matrix.build_type == 'Release' |
| 40 | + id: flags |
| 41 | + run: echo "::set-output name=SETUP_PY_FLAGS::-G 'Visual Studio 16 2019'" |
| 42 | + - name: Get mac dependencies |
| 43 | + if: contains(matrix.os, 'macos') |
| 44 | + run: | |
| 45 | + brew install freeglut lapack openblas |
| 46 | + - name: Create Build Environment |
| 47 | + # Some projects don't allow in-source building, so create a separate build directory |
| 48 | + # We'll use this as our working directory for all subsequent commands |
| 49 | + run: cmake -E make_directory ${{runner.workspace}}/build |
| 50 | + |
| 51 | + - name: Configure CMake |
| 52 | + shell: bash |
| 53 | + working-directory: ${{runner.workspace}}/build |
| 54 | + run: cmake $GITHUB_WORKSPACE -DUSE_EIGEN=On -DDOWNLOAD_EIGEN=On -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DENABLE_TESTS=ON -DCMAKE_INSTALL_PREFIX=install_root ${{matrix.config_flags}} |
| 55 | + |
| 56 | + - name: Build |
| 57 | + working-directory: ${{runner.workspace}}/build |
| 58 | + shell: bash |
| 59 | + # Execute the build. You can specify a specific target with "--target <NAME>" |
| 60 | + run: cmake --build . --config $BUILD_TYPE -v |
| 61 | + |
| 62 | + - name: Install |
| 63 | + working-directory: ${{runner.workspace}}/build |
| 64 | + shell: bash |
| 65 | + # Execute the build. You can specify a specific target with "--target <NAME>" |
| 66 | + run: cmake --build . --config $BUILD_TYPE --target install |
| 67 | + |
| 68 | + - name: Set bundle name |
| 69 | + id: bundle |
| 70 | + run: echo "::set-output name=BUNDLE_FILE_NAME::cnmatrix-$(git describe --tags)-${{ matrix.os }}.zip" |
| 71 | + |
| 72 | + - name: Bundle |
| 73 | + if: matrix.build_type == 'Release' |
| 74 | + working-directory: ${{runner.workspace}}/cnmatrix |
| 75 | + run: 7z a ${{runner.workspace}}/build/${{ steps.bundle.outputs.BUNDLE_FILE_NAME }} ${{runner.workspace}}/build/install_root/* |
| 76 | + |
| 77 | + - uses: actions/upload-artifact@v2 |
| 78 | + name: Upload |
| 79 | + if: matrix.build_type == 'Release' |
| 80 | + with: |
| 81 | + name: cnmatrix-${{ matrix.os }}-${{ matrix.build_type }} |
| 82 | + path: | |
| 83 | + ${{runner.workspace}}/build/${{steps.bundle.outputs.BUNDLE_FILE_NAME}} |
| 84 | + - name: Get release |
| 85 | + id: get_release |
| 86 | + if: github.event_name == 'release' |
| 87 | + uses: bruceadams/[email protected] |
| 88 | + env: |
| 89 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 90 | + |
| 91 | + - name: Upload Release Asset |
| 92 | + id: upload-release-asset |
| 93 | + continue-on-error: true |
| 94 | + if: github.event_name == 'release' |
| 95 | + uses: actions/upload-release-asset@v1 |
| 96 | + env: |
| 97 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 98 | + with: |
| 99 | + upload_url: ${{ steps.get_release.outputs.upload_url }} |
| 100 | + asset_path: ${{runner.workspace}}/build/${{steps.bundle.outputs.BUNDLE_FILE_NAME}} |
| 101 | + asset_name: ${{steps.bundle.outputs.BUNDLE_FILE_NAME}} |
| 102 | + asset_content_type: application/zip |
| 103 | + |
| 104 | + - name: Test |
| 105 | + working-directory: ${{runner.workspace}}/build |
| 106 | + shell: bash |
| 107 | + # Execute tests defined by the CMake configuration. |
| 108 | + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail |
| 109 | + run: ctest -C $BUILD_TYPE --output-on-failure -j30 |
0 commit comments