diff --git a/.cargo/config.toml b/.cargo/config.toml index 52051b2d7..71820b3b8 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,7 +1,7 @@ # Pass the rustflags specified to host dependencies (build scripts, proc-macros) # when a `--target` is passed to Cargo. Historically this was not the case, and # because of that, cross-compilation would not set the rustflags configured -# below in `target.'cfg(all())'` for them, resulting in cache invalidation. +# below in `target.'cfg(...)'` for them, resulting in cache invalidation. # # Since this is an unstable feature (enabled at the bottom of the file), this # setting is unfortunately ignored on stable toolchains, but it's still better @@ -15,7 +15,12 @@ uniffi-bindgen = "run --package uniffi-bindgen --" [doc.extern-map.registries] crates-io = "https://docs.rs/" -[target.'cfg(all())'] +# Exclude tarpaulin, android and ios from extra lints since on stable, without +# the nightly-only target-applies-to-host setting at the top, cross compilation +# and otherwise changing cfg's can be very bad for caching. These should never +# be the default either and don't have much target-specific code that would +# benefit from the extra lints. +[target.'cfg(not(any(tarpaulin, target_os = "android", target_os = "ios")))'] rustflags = [ "-Wrust_2018_idioms", "-Wsemicolon_in_expressions_from_macros", diff --git a/.github/workflows/bindings_ci.yml b/.github/workflows/bindings_ci.yml index c62542b73..7691728a0 100644 --- a/.github/workflows/bindings_ci.yml +++ b/.github/workflows/bindings_ci.yml @@ -41,6 +41,11 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable + # Cargo config can screw with caching and is only used for alias config + # and extra lints, which we don't care about here + - name: Delete cargo config + run: rm .cargo/config.toml + - name: Load cache uses: Swatinem/rust-cache@v2 with: @@ -78,6 +83,11 @@ jobs: - name: Install aarch64-apple-ios target run: rustup target install aarch64-apple-ios + # Cargo config can screw with caching and is only used for alias config + # and extra lints, which we don't care about here + - name: Delete cargo config + run: rm .cargo/config.toml + - name: Load cache uses: Swatinem/rust-cache@v2 with: diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 9c11b9847..e070189fd 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -25,46 +25,54 @@ jobs: if: github.event_name == 'push' || !github.event.pull_request.draft steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.sha }} + - name: Checkout repository + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} - - name: Install Rust - uses: dtolnay/rust-toolchain@stable + - name: Install Rust + uses: dtolnay/rust-toolchain@stable - - name: Load cache - uses: Swatinem/rust-cache@v2 - with: - save-if: ${{ github.ref == 'refs/heads/main' }} + # Cargo config can screw with caching and is only used for alias config + # and extra lints, which we don't care about here + - name: Delete cargo config + run: rm .cargo/config.toml - - name: Install tarpaulin - uses: taiki-e/install-action@v2 - with: - tool: cargo-tarpaulin + - name: Load cache + uses: Swatinem/rust-cache@v2 + with: + save-if: ${{ github.ref == 'refs/heads/main' }} - # set up backend for integration tests - - uses: actions/setup-python@v4 - with: - python-version: 3.8 + - name: Install tarpaulin + uses: taiki-e/install-action@v2 + with: + tool: cargo-tarpaulin - - uses: michaelkaye/setup-matrix-synapse@main - with: - installer: venv # TODO revert to poetry once https://github.com/michaelkaye/setup-matrix-synapse/issues/95 is fixed - uploadLogs: true - httpPort: 8228 - disableRateLimiting: true + # set up backend for integration tests + - uses: actions/setup-python@v4 + with: + python-version: 3.8 - - name: Run tarpaulin - run: | - cargo tarpaulin --out Xml -e sliding-sync-integration-test --features testing + - uses: michaelkaye/setup-matrix-synapse@main + with: + installer: venv # TODO revert to poetry once https://github.com/michaelkaye/setup-matrix-synapse/issues/95 is fixed + uploadLogs: true + httpPort: 8228 + disableRateLimiting: true - - name: Upload to codecov.io - uses: codecov/codecov-action@v3 - with: - # Work around frequent upload errors, for runs inside the main repo (not PRs from forks). - # Otherwise not required for public repos. - token: ${{ secrets.CODECOV_UPLOAD_TOKEN }} - # The upload sometimes fails due to https://github.com/codecov/codecov-action/issues/837. - # To make sure that the failure gets flagged clearly in the UI, fail the action. - fail_ci_if_error: true + - name: Run tarpaulin + run: | + rustup run stable cargo tarpaulin --skip-clean --profile cov --out Xml --features testing + env: + CARGO_PROFILE_COV_INHERITS: 'dev' + CARGO_PROFILE_COV_DEBUG: 'false' + + - name: Upload to codecov.io + uses: codecov/codecov-action@v3 + with: + # Work around frequent upload errors, for runs inside the main repo (not PRs from forks). + # Otherwise not required for public repos. + token: ${{ secrets.CODECOV_UPLOAD_TOKEN }} + # The upload sometimes fails due to https://github.com/codecov/codecov-action/issues/837. + # To make sure that the failure gets flagged clearly in the UI, fail the action. + fail_ci_if_error: true diff --git a/tarpaulin.toml b/tarpaulin.toml index 315601be0..66d2994a6 100644 --- a/tarpaulin.toml +++ b/tarpaulin.toml @@ -22,4 +22,6 @@ exclude = [ # repo automation (ci, codegen) "uniffi-bindgen", "xtask", + # temporary: tiny test suite, expensive to run + "sliding-sync-integration-test", ] diff --git a/xtask/src/swift.rs b/xtask/src/swift.rs index 276ae7aaa..d10d06ee6 100644 --- a/xtask/src/swift.rs +++ b/xtask/src/swift.rs @@ -67,7 +67,7 @@ fn build_library() -> Result<()> { create_dir_all(ffi_directory.as_path())?; - cmd!("cargo build -p matrix-sdk-ffi").run()?; + cmd!("rustup run stable cargo build -p matrix-sdk-ffi").run()?; rename( target_directory.join(release_type).join(static_lib_filename), @@ -109,7 +109,8 @@ fn generate_uniffi(library_file: &Utf8Path, ffi_directory: &Utf8Path) -> Result< } fn build_for_target(target: &str, profile: &str) -> Result { - cmd!("cargo build -p matrix-sdk-ffi --target {target} --profile {profile}").run()?; + cmd!("rustup run stable cargo build -p matrix-sdk-ffi --target {target} --profile {profile}") + .run()?; // The builtin dev profile has its files stored under target/debug, all // other targets have matching directory names