|
| 1 | +name: CI & Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master] |
| 6 | + tags: ['v*'] |
| 7 | + pull_request: |
| 8 | + branches: [master] |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + include: |
| 16 | + - os: ubuntu-24.04 |
| 17 | + target: x86_64-unknown-linux-gnu |
| 18 | + platform: linux-x86_64 |
| 19 | + archive_ext: tar.gz |
| 20 | + |
| 21 | + - os: ubuntu-24.04-arm |
| 22 | + target: aarch64-unknown-linux-gnu |
| 23 | + platform: linux-aarch64 |
| 24 | + archive_ext: tar.gz |
| 25 | + |
| 26 | + - os: macos-14 |
| 27 | + target: aarch64-apple-darwin |
| 28 | + platform: macos-arm64 |
| 29 | + archive_ext: tar.gz |
| 30 | + |
| 31 | + - os: windows-2025 |
| 32 | + target: x86_64-pc-windows-msvc |
| 33 | + platform: windows-x86_64 |
| 34 | + archive_ext: zip |
| 35 | + |
| 36 | + runs-on: ${{ matrix.os }} |
| 37 | + |
| 38 | + # Must match OpenMS's MACOSX_DEPLOYMENT_TARGET (see pyOpenMS pyproject.toml |
| 39 | + # and openms_ci_matrix_full.yml) to avoid deployment target mismatch warnings |
| 40 | + # when linking the static library into OpenMS/pyOpenMS. |
| 41 | + env: |
| 42 | + MACOSX_DEPLOYMENT_TARGET: ${{ startsWith(matrix.os, 'macos') && '14.0' || '' }} |
| 43 | + |
| 44 | + steps: |
| 45 | + # actions/checkout v6.0.2 |
| 46 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 47 | + |
| 48 | + - name: Install Rust toolchain |
| 49 | + # dtolnay/rust-toolchain stable branch |
| 50 | + uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 |
| 51 | + with: |
| 52 | + toolchain: stable |
| 53 | + |
| 54 | + - name: Cache Cargo |
| 55 | + # Swatinem/rust-cache v2.8.2 |
| 56 | + uses: Swatinem/rust-cache@401aff9a7a08acb9d27b64936a90db81024cff97 |
| 57 | + |
| 58 | + - name: Run tests |
| 59 | + run: cargo test --features with_timsrust |
| 60 | + |
| 61 | + - name: Build release |
| 62 | + run: cargo build --features with_timsrust --release |
| 63 | + |
| 64 | + - name: Smoke test (Linux) |
| 65 | + if: runner.os == 'Linux' |
| 66 | + shell: bash |
| 67 | + run: | |
| 68 | + g++ -std=c++17 examples/cpp_client.cpp \ |
| 69 | + -Iinclude \ |
| 70 | + target/release/libtimsrust_cpp_bridge.a \ |
| 71 | + -lpthread -ldl -lm \ |
| 72 | + -o target/smoke_test |
| 73 | + # Run with no args — expect exit code 1 (usage), fail only on signal/crash |
| 74 | + target/smoke_test || if [ $? -gt 128 ]; then exit 1; fi |
| 75 | +
|
| 76 | + - name: Smoke test (macOS) |
| 77 | + if: runner.os == 'macOS' |
| 78 | + shell: bash |
| 79 | + run: | |
| 80 | + clang++ -std=c++17 examples/cpp_client.cpp \ |
| 81 | + -Iinclude \ |
| 82 | + target/release/libtimsrust_cpp_bridge.a \ |
| 83 | + -framework Security -framework SystemConfiguration -framework CoreFoundation \ |
| 84 | + -lresolv -lpthread \ |
| 85 | + -o target/smoke_test |
| 86 | + # Run with no args — expect exit code 1 (usage), fail only on signal/crash |
| 87 | + target/smoke_test || if [ $? -gt 128 ]; then exit 1; fi |
| 88 | +
|
| 89 | + - name: Setup MSVC dev environment |
| 90 | + if: runner.os == 'Windows' |
| 91 | + # ilammy/msvc-dev-cmd v1.13.0 |
| 92 | + uses: ilammy/msvc-dev-cmd@a102174a2b586eec2ea151a69e6fd14404a8ce7c |
| 93 | + |
| 94 | + - name: Smoke test (Windows) |
| 95 | + if: runner.os == 'Windows' |
| 96 | + shell: cmd |
| 97 | + run: | |
| 98 | + cl.exe /std:c++17 /EHsc /MD /Fe:target\smoke_test.exe /I include examples\cpp_client.cpp target\release\timsrust_cpp_bridge.lib ws2_32.lib userenv.lib bcrypt.lib ntdll.lib advapi32.lib |
| 99 | + target\smoke_test.exe |
| 100 | + if %errorlevel% GEQ 2 exit /b %errorlevel% |
| 101 | + exit /b 0 |
| 102 | +
|
| 103 | + - name: Set version |
| 104 | + id: version |
| 105 | + shell: bash |
| 106 | + run: | |
| 107 | + if [[ "$GITHUB_REF" == refs/tags/v* ]]; then |
| 108 | + echo "version=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT" |
| 109 | + else |
| 110 | + echo "version=0.0.0-dev" >> "$GITHUB_OUTPUT" |
| 111 | + fi |
| 112 | +
|
| 113 | + - name: Package |
| 114 | + shell: bash |
| 115 | + run: bash scripts/package.sh "${{ steps.version.outputs.version }}" "${{ matrix.target }}" |
| 116 | + |
| 117 | + - name: Validate CMake package |
| 118 | + shell: bash |
| 119 | + run: | |
| 120 | + ARCHIVE_DIR="target/package/timsrust_cpp_bridge-v${{ steps.version.outputs.version }}-${{ matrix.platform }}/timsrust_cpp_bridge" |
| 121 | + mkdir -p /tmp/timsrust_cmake_test |
| 122 | + cat > /tmp/timsrust_cmake_test/CMakeLists.txt << 'CMAKEOF' |
| 123 | + cmake_minimum_required(VERSION 3.11) |
| 124 | + project(test_consumer CXX) |
| 125 | + set(CMAKE_CXX_STANDARD 17) |
| 126 | + find_package(timsrust_cpp_bridge REQUIRED) |
| 127 | + add_executable(test_consumer test.cpp) |
| 128 | + target_link_libraries(test_consumer timsrust_cpp_bridge::timsrust_cpp_bridge) |
| 129 | + CMAKEOF |
| 130 | + cat > /tmp/timsrust_cmake_test/test.cpp << 'CPPEOF' |
| 131 | + #include "timsrust_cpp_bridge.h" |
| 132 | + int main() { return 0; } |
| 133 | + CPPEOF |
| 134 | + cmake -S /tmp/timsrust_cmake_test -B /tmp/timsrust_cmake_test/build \ |
| 135 | + -DCMAKE_PREFIX_PATH="$(pwd)/${ARCHIVE_DIR}" |
| 136 | + cmake --build /tmp/timsrust_cmake_test/build |
| 137 | + rm -rf /tmp/timsrust_cmake_test |
| 138 | +
|
| 139 | + - name: Upload artifact |
| 140 | + if: startsWith(github.ref, 'refs/tags/v') |
| 141 | + # actions/upload-artifact v7.0.0 |
| 142 | + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f |
| 143 | + with: |
| 144 | + name: timsrust_cpp_bridge-v${{ steps.version.outputs.version }}-${{ matrix.platform }} |
| 145 | + path: target/package/timsrust_cpp_bridge-v${{ steps.version.outputs.version }}-${{ matrix.platform }}.${{ matrix.archive_ext }} |
| 146 | + |
| 147 | + release: |
| 148 | + if: startsWith(github.ref, 'refs/tags/v') |
| 149 | + needs: build |
| 150 | + runs-on: ubuntu-latest |
| 151 | + permissions: |
| 152 | + contents: write |
| 153 | + |
| 154 | + steps: |
| 155 | + - name: Download all artifacts |
| 156 | + # actions/download-artifact v8.0.1 |
| 157 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c |
| 158 | + with: |
| 159 | + path: artifacts/ |
| 160 | + |
| 161 | + - name: Create GitHub Release |
| 162 | + # softprops/action-gh-release v2.5.0 |
| 163 | + uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b |
| 164 | + with: |
| 165 | + files: artifacts/**/* |
| 166 | + generate_release_notes: true |
0 commit comments