Introduce importability as a Swift package (C library). #1159
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: CI | |
| on: | |
| push: | |
| branches: | |
| - "master" | |
| - "release/*" | |
| pull_request: | |
| branches: | |
| - "master" | |
| - "release/*" | |
| merge_group: | |
| types: [checks_requested] | |
| env: | |
| RUST_VERSION: "1.88" | |
| CMAKE_GENERATOR: Ninja | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| preset: | |
| - rust-release | |
| - rust-with-sqlite-release | |
| runs-on: ${{ matrix.os }} | |
| name: ${{ matrix.os }}, preset=${{ matrix.preset }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - if: ${{ matrix.os == 'ubuntu-latest' }} | |
| run: sudo apt-get install ninja-build | |
| - if: ${{ matrix.os == 'macos-latest' }} | |
| run: brew install ninja | |
| - if: ${{ matrix.os == 'windows-latest' }} | |
| uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 | |
| - if: ${{ matrix.os == 'windows-latest' }} | |
| run: | | |
| choco install ninja | |
| echo VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT >> $env:GITHUB_ENV | |
| echo CMAKE_TOOLCHAIN_FILE=$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake >> $env:GITHUB_ENV | |
| echo VCPKG_TARGET_TRIPLET=x64-windows-static >> $env:GITHUB_ENV | |
| & $env:VCPKG_INSTALLATION_ROOT\vcpkg install --triplet x64-windows-static sqlite3 | |
| & $env:VCPKG_INSTALLATION_ROOT\vcpkg install --triplet x64-windows-static-md sqlite3 | |
| - name: Setup rustup | |
| run: | | |
| rustup set auto-self-update disable | |
| rustup install ${{ env.RUST_VERSION }} | |
| rustup default ${{ env.RUST_VERSION }} | |
| - name: Build | |
| run: | | |
| cmake --preset ${{ matrix.preset }} -DVCPKG_TARGET_TRIPLET=${{ env.VCPKG_TARGET_TRIPLET }} | |
| cmake --build build | |
| cmake --install build --prefix install | |
| - name: Test | |
| run: | | |
| ctest --test-dir build --output-on-failure | |
| aarch64-smoke: | |
| runs-on: ubuntu-latest | |
| name: Aarch64 cross-compile smoke test | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup rustup | |
| run: | | |
| rustup set auto-self-update disable | |
| rustup install ${{ env.RUST_VERSION }} | |
| rustup default ${{ env.RUST_VERSION }} | |
| rustup target add aarch64-unknown-linux-gnu | |
| - name: Build | |
| run: | | |
| cargo build --target=aarch64-unknown-linux-gnu | |
| cargo build -p chewing_capi --target=aarch64-unknown-linux-gnu | |
| coverage: | |
| strategy: | |
| matrix: | |
| preset: | |
| - rust-coverage | |
| - rust-with-sqlite-coverage | |
| runs-on: ubuntu-latest | |
| container: fedora:latest | |
| name: Coverage preset=${{ matrix.preset }} | |
| steps: | |
| - run: sudo dnf -y install clang cmake ninja-build sqlite-devel llvm rustup bzip2 git gnupg2 | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - name: Setup rustup | |
| run: | | |
| rustup-init -y | |
| source "$HOME/.cargo/env" | |
| rustup set auto-self-update disable | |
| rustup component add llvm-tools | |
| - name: Setup grcov | |
| run: | | |
| curl -LO https://github.com/mozilla/grcov/releases/download/v0.8.19/grcov-x86_64-unknown-linux-gnu.tar.bz2 | |
| echo 098be4d60b8016913542d58456fea6e771890096d1bf86e7f83dac650ba4b58a grcov-x86_64-unknown-linux-gnu.tar.bz2 | sha256sum -c - | |
| tar xf grcov-x86_64-unknown-linux-gnu.tar.bz2 | |
| - name: Build | |
| env: | |
| CARGO_INCREMENTAL: 0 | |
| RUSTFLAGS: -Cinstrument-coverage -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off | |
| run: | | |
| source "$HOME/.cargo/env" | |
| cmake --preset ${{ matrix.preset }} | |
| cmake --build build | |
| - name: Test | |
| env: | |
| CARGO_INCREMENTAL: 0 | |
| RUSTFLAGS: -Cinstrument-coverage -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off | |
| run: | | |
| source "$HOME/.cargo/env" | |
| ctest --test-dir build --output-on-failure | |
| ./grcov . -s . -b . --keep-only 'src/*' --keep-only 'capi/src/*' --llvm -t lcov -o coverage.lcov | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v5 | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| # On macOS we run Swift Package Manager tests to validate SPM integration. | |
| # Use macOS 26 runner if available—fall back to macos-latest if not. | |
| # No need to add code-coverage for this target as we already do that on Linux above. | |
| # The essense of this Swift package is to allow all C APIs to be accessible from Swift. | |
| macos-swift: | |
| # If your org's runner image naming differs, replace `macos-26` with `macos-latest`. | |
| runs-on: macos-26 | |
| name: macOS Swift tests (macOS 26) | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - name: Setup rustup | |
| run: | | |
| rustup set auto-self-update disable | |
| rustup install ${{ env.RUST_VERSION }} | |
| rustup default ${{ env.RUST_VERSION }} | |
| - name: Build chewing_capi via cargo (macOS) | |
| # Ensure the cargo-built static lib is present for the Swift package to link | |
| run: | | |
| chmod +x ./swift/scripts/build-cargo.sh | |
| ./swift/scripts/build-cargo.sh | |
| - name: Run Swift tests | |
| run: | | |
| swift test -v | |
| # https://github.com/orgs/community/discussions/26822 | |
| results: | |
| if: ${{ always() }} | |
| runs-on: ubuntu-latest | |
| name: Final Results | |
| needs: [build, aarch64-smoke] | |
| steps: | |
| - run: exit 1 | |
| # see https://stackoverflow.com/a/67532120/4907315 | |
| if: >- | |
| ${{ | |
| contains(needs.*.result, 'failure') | |
| || contains(needs.*.result, 'cancelled') | |
| }} |