|
| 1 | +name: C/C++ CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ['*'] |
| 6 | + tags: |
| 7 | + paths_ignore: ['docs/**', '.travis.yml'] |
| 8 | + pull_request: |
| 9 | + release: |
| 10 | + types: ['created'] |
| 11 | + workflow_dispatch: |
| 12 | + inputs: |
| 13 | + cmakeextra: |
| 14 | + description: 'Extra CMake options' |
| 15 | + required: false |
| 16 | + default: '' |
| 17 | + |
| 18 | +defaults: |
| 19 | + run: |
| 20 | + shell: bash |
| 21 | + |
| 22 | + |
| 23 | +jobs: |
| 24 | + build: |
| 25 | + name: ${{ matrix.config.name }} |
| 26 | + runs-on: ${{ matrix.config.os }} |
| 27 | + strategy: |
| 28 | + fail-fast: false |
| 29 | + matrix: |
| 30 | + config: |
| 31 | + - {name: "ubuntu-20.04", os: "ubuntu-20.04", cmake_extra: "-DLSL_BUNDLED_PUGIXML=OFF"} |
| 32 | + - {name: "ubuntu-18.04", os: "ubuntu-latest", docker: "ubuntu:18.04" } |
| 33 | + - {name: "windows-x64", os: "windows-latest", cmake_extra: "-T v140,host=x86"} |
| 34 | + - {name: "windows-32", os: "windows-latest", cmake_extra: "-T v140,host=x86 -A Win32"} |
| 35 | + - {name: "macOS-latest", os: "macOS-latest"} |
| 36 | + |
| 37 | + # runs all steps in the container configured in config.docker or as subprocesses when empty |
| 38 | + container: ${{ matrix.config.docker }} |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v2 |
| 41 | + - name: set up build environment in container |
| 42 | + run: | |
| 43 | + apt update |
| 44 | + apt install -y --no-install-recommends g++ git python3-pip ninja-build file dpkg-dev lsb-release sudo curl |
| 45 | + python3 -m pip install cmake |
| 46 | + if: ${{ matrix.config.docker }} |
| 47 | + |
| 48 | + - name: Configure CMake |
| 49 | + run: | |
| 50 | + if [[ "${{ matrix.config.os }}" == "ubuntu-20.04" ]]; then |
| 51 | + sudo apt-get install libpugixml-dev |
| 52 | + fi |
| 53 | + cmake --version |
| 54 | + cmake -S . -B build \ |
| 55 | + -DCMAKE_BUILD_TYPE=Release \ |
| 56 | + -DCMAKE_INSTALL_PREFIX=${PWD}/install \ |
| 57 | + -DLSL_UNITTESTS=ON \ |
| 58 | + -DLSL_BUILD_EXAMPLES=ON \ |
| 59 | + -DCPACK_PACKAGE_DIRECTORY=${PWD}/package \ |
| 60 | + -Dlslgitrevision=${{ github.sha }} \ |
| 61 | + -Dlslgitbranch=${{ github.ref }} \ |
| 62 | + ${{ matrix.config.cmake_extra }} |
| 63 | + echo ${PWD} |
| 64 | + - name: make |
| 65 | + run: cmake --build build --target install --config Release -j |
| 66 | + |
| 67 | + - name: package |
| 68 | + run: | |
| 69 | + echo $GITHUB_REF |
| 70 | + cmake --build build --target package --config Release -j |
| 71 | + echo $PWD |
| 72 | + ls -la |
| 73 | + # On Debian / Ubuntu the dependencies can only be resolved for |
| 74 | + # already installed packages. Therefore, we have built all |
| 75 | + # packages without dependencies in the previous step, |
| 76 | + # install them and rebuild them with dependency discovery enabled |
| 77 | + if [[ "${{ matrix.config.os }}" == ubuntu-* ]]; then |
| 78 | + cmake -DCPACK_DEBIAN_PACKAGE_SHLIBDEPS=ON . |
| 79 | + sudo dpkg -i package/*.deb |
| 80 | + cmake --build build --target package --config Release -j |
| 81 | + dpkg -I package/liblsl*.deb |
| 82 | + fi |
| 83 | + cmake -E remove_directory package/_CPack_Packages |
| 84 | + - name: upload install dir |
| 85 | + uses: actions/upload-artifact@master |
| 86 | + with: |
| 87 | + name: build-${{ matrix.config.name }} |
| 88 | + path: install |
| 89 | + |
| 90 | + - name: upload package |
| 91 | + uses: actions/upload-artifact@master |
| 92 | + with: |
| 93 | + name: pkg-${{ matrix.config.name }} |
| 94 | + path: package |
| 95 | + - name: print network config |
| 96 | + run: | |
| 97 | + which ifconfig && ifconfig |
| 98 | + if [ `which ip` ]; then |
| 99 | + ip link |
| 100 | + ip addr |
| 101 | + ip route |
| 102 | + ip -6 route |
| 103 | + fi |
| 104 | + |
| 105 | + # run internal tests, ignore test failures on docker (missing IPv6 connectivity) |
| 106 | + - name: unit tests (internal functions) |
| 107 | + run: 'install/bin/lsl_test_internal --order rand --wait-for-keypress never --durations yes || test ! -z "${{ matrix.config.docker }}"' |
| 108 | + timeout-minutes: 5 |
| 109 | + |
| 110 | + - name: unit tests (exported functions) |
| 111 | + run: install/bin/lsl_test_exported --order rand --wait-for-keypress never --durations yes |
| 112 | + timeout-minutes: 5 |
| 113 | + if: ${{ success() || failure() }} |
| 114 | + - name: upload to release page |
| 115 | + if: github.event_name == 'release' |
| 116 | + env: |
| 117 | + TOKEN: "token ${{ secrets.GITHUB_TOKEN }}" |
| 118 | + TAG: ${{ github.event.release.tag_name }} |
| 119 | + UPLOAD_URL: ${{ github.event.release.upload_url }} |
| 120 | + run: | |
| 121 | + # Do try this at home! The REST API is documented at |
| 122 | + # https://docs.github.com/en/free-pro-team@latest/rest and you can get a personal |
| 123 | + # access token at https://github.com/settings/tokens |
| 124 | + # (set TOKEN to "bearer abcdef1234") |
| 125 | + # you can get the UPLOAD_URL with a short bash snippet; make sure to set the env var TAG: |
| 126 | + # UPLOAD_URL=$(curl -H 'Accept: application/vnd.github.v3+json' $GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/tags/$TAG | jq -r .upload_url) |
| 127 | + UPLOAD_URL=${UPLOAD_URL%\{*} # remove "{name,label}" suffix |
| 128 | + for pkg in package/*.*; do |
| 129 | + NAME=$(basename $pkg) |
| 130 | + MIME=$(file --mime-type $pkg|cut -d ' ' -f2) |
| 131 | + curl -X POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: $TOKEN" -H "Content-Type: $MIME" --data-binary @$pkg $UPLOAD_URL?name=$NAME |
| 132 | + done |
0 commit comments