Merge branch 'master' into user-avatar-ci

This commit is contained in:
Damir Jelić 2020-12-08 14:43:46 +01:00
commit ca4e738fff
9 changed files with 155 additions and 51 deletions

103
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,103 @@
name: CI
on:
push:
pull_request:
branches: [ master ]
env:
CARGO_TERM_COLOR: always
jobs:
style:
name: Check style
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt
profile: minimal
override: true
- name: Cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
name: Run clippy
needs: [style]
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
profile: minimal
override: true
- name: Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets -- -D warnings
test:
name: ${{ matrix.name }}
needs: [clippy]
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
strategy:
matrix:
name:
- linux / stable
- linux / beta
- macOS / stable
- windows / stable-x86_64-msvc
include:
- name: linux / stable
- name: linux / beta
rust: beta
- name: macOS / stable
os: macOS-latest
- name: windows / stable-x86_64-msvc
os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust || 'stable' }}
target: ${{ matrix.target }}
profile: minimal
override: true
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
- name: Test
uses: actions-rs/cargo@v1
with:
command: test

39
.github/workflows/coverage.yml vendored Normal file
View file

@ -0,0 +1,39 @@
name: Code coverage
on:
push:
branches: [ master ]
env:
CARGO_TERM_COLOR: always
jobs:
code_coverage:
name: Code Coverage
runs-on: "ubuntu-latest"
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Install tarpaulin
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-tarpaulin -f
- name: Run tarpaulin
uses: actions-rs/cargo@v1
with:
command: tarpaulin
args: --ignore-config --exclude-files "matrix_sdk/examples/*,matrix_sdk_common,matrix_sdk_test" --out Xml
- name: Upload to codecov.io
uses: codecov/codecov-action@v1

View file

@ -1,4 +1,4 @@
[![Build Status](https://img.shields.io/travis/matrix-org/matrix-rust-sdk.svg?style=flat-square)](https://travis-ci.org/matrix-org/matrix-rust-sdk)
![Build Status](https://img.shields.io/github/workflow/status/matrix-org/matrix-rust-sdk/CI?style=flat-square)
[![codecov](https://img.shields.io/codecov/c/github/matrix-org/matrix-rust-sdk/master.svg?style=flat-square)](https://codecov.io/gh/matrix-org/matrix-rust-sdk)
[![License](https://img.shields.io/badge/License-Apache%202.0-yellowgreen.svg?style=flat-square)](https://opensource.org/licenses/Apache-2.0)
[![#matrix-rust-sdk](https://img.shields.io/badge/matrix-%23matrix--rust--sdk-blue?style=flat-square)](https://matrix.to/#/#matrix-rust-sdk:matrix.org)

View file

@ -904,7 +904,7 @@ impl Client {
since: Option<&str>,
server: Option<&ServerName>,
) -> Result<get_public_rooms::Response> {
let limit = limit.map(|n| UInt::from(n));
let limit = limit.map(UInt::from);
let request = assign!(get_public_rooms::Request::new(), {
limit,

View file

@ -224,11 +224,9 @@ mod test {
use crate::{
identifiers::{room_id, user_id},
push::Ruleset,
BaseClient, BaseClientConfig, Session,
Session,
};
use matrix_sdk_test::{sync_response, SyncResponseFile};
#[tokio::test]
async fn test_store_client_state() {
let dir = tempdir().unwrap();
@ -360,44 +358,4 @@ mod test {
// test that we have removed the correct room
assert!(invited.is_empty());
}
#[tokio::test]
async fn test_client_sync_store() {
let dir = tempdir().unwrap();
let path: &Path = dir.path();
let session = Session {
access_token: "1234".to_owned(),
user_id: user_id!("@cheeky_monkey:matrix.org"),
device_id: "DEVICEID".into(),
};
// a sync response to populate our JSON store
let store = Box::new(JsonStore::open(path).unwrap());
let client =
BaseClient::new_with_config(BaseClientConfig::new().state_store(store)).unwrap();
client.restore_login(session.clone()).await.unwrap();
let mut response = sync_response(SyncResponseFile::Default);
// gather state to save to the db, the first time through loading will be skipped
client.receive_sync_response(&mut response).await.unwrap();
// now syncing the client will update from the state store
let store = Box::new(JsonStore::open(path).unwrap());
let client =
BaseClient::new_with_config(BaseClientConfig::new().state_store(store)).unwrap();
client.restore_login(session.clone()).await.unwrap();
// assert the synced client and the logged in client are equal
assert_eq!(*client.session().read().await, Some(session));
assert_eq!(
client.sync_token().await,
Some("s526_47314_0_7_1_1_1_11444_1".to_string())
);
assert_eq!(
*client.ignored_users.read().await,
vec![user_id!("@someone:example.org")]
);
}
}

View file

@ -170,7 +170,7 @@ impl Account {
return Err(OlmError::SessionWedged(user_id, sender_key));
}
}
Err(e) => return Err(e.into()),
Err(e) => return Err(e),
};
debug!("Decrypted a to-device event {:?}", event);

View file

@ -138,7 +138,7 @@ mod test {
use crate::ReadOnlyAccount;
#[tokio::test]
#[cfg(not(target_os = "macos"))]
#[cfg(target_os = "linux")]
async fn expiration() {
let settings = EncryptionSettings {
rotation_period_msgs: 1,

View file

@ -316,8 +316,7 @@ mod test {
use matrix_sdk_common::{
api::r0::keys::claim_keys::Response as KeyClaimResponse,
identifiers::{user_id, DeviceIdBox, DeviceKeyAlgorithm, UserId},
instant::{Duration, Instant},
identifiers::{user_id, DeviceIdBox, UserId},
};
use matrix_sdk_test::async_test;
@ -422,8 +421,13 @@ mod test {
// This test doesn't run on macos because we're modifying the session
// creation time so we can get around the UNWEDGING_INTERVAL.
#[async_test]
#[cfg(not(target_os = "macos"))]
#[cfg(target_os = "linux")]
async fn session_unwedging() {
use matrix_sdk_common::{
identifiers::DeviceKeyAlgorithm,
instant::{Duration, Instant},
};
let manager = session_manager().await;
let bob = bob_account();
let (_, mut session) = bob.create_session_for(&manager.account).await;

View file

@ -380,7 +380,7 @@ mod test {
assert!(bob.is_done());
}
#[cfg(not(target_os = "macos"))]
#[cfg(target_os = "linux")]
#[tokio::test]
async fn timing_out() {
let (alice_machine, bob) = setup_verification_machine().await;