Skip to content

Commit 6dfd6e3

Browse files
bors[bot]eldruin
andauthored
Merge #64
64: Several updates r=ryankurte a=eldruin Including: - Update `nix` - Raise MSRV to 1.46.0 due to dependencies. Effectively it has been raised already and so far nobody noticed. - Fix warnings - Improvements to `Cargo.toml` - Add bors configuration - Switch to GHA for CI (tested on my fork) Fixes #56 Co-authored-by: Diego Barrios Romero <eldruin@gmail.com>
2 parents 5bf63c4 + b52f930 commit 6dfd6e3

File tree

13 files changed

+153
-54
lines changed

13 files changed

+153
-54
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @rust-embedded/embedded-linux

.github/bors.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
block_labels = ["needs-decision"]
2+
delete_merged_branches = true
3+
required_approvals = 1
4+
status = [
5+
"CI (stable, x86_64-unknown-linux-gnu)",
6+
"CI (stable, armv7-unknown-linux-gnueabihf)",
7+
"CI (1.46.0, x86_64-unknown-linux-gnu)",
8+
"CI-macOS (stable, x86_64-apple-darwin)",
9+
"CI-macOS (1.46.0, x86_64-apple-darwin)",
10+
]

.github/workflows/ci.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
on:
2+
push:
3+
branches: [ staging, trying, master ]
4+
pull_request:
5+
6+
name: Continuous integration
7+
8+
jobs:
9+
ci-linux:
10+
name: CI
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
# All generated code should be running on stable now
16+
rust: [stable]
17+
18+
# The default target we're compiling on and for
19+
TARGET: [x86_64-unknown-linux-gnu, armv7-unknown-linux-gnueabihf]
20+
21+
include:
22+
# Test MSRV
23+
- rust: 1.46.0
24+
TARGET: x86_64-unknown-linux-gnu
25+
26+
# Test nightly but don't fail
27+
- rust: nightly
28+
experimental: true
29+
TARGET: x86_64-unknown-linux-gnu
30+
31+
steps:
32+
- uses: actions/checkout@v2
33+
34+
- uses: actions-rs/toolchain@v1
35+
with:
36+
profile: minimal
37+
toolchain: ${{ matrix.rust }}
38+
target: ${{ matrix.TARGET }}
39+
override: true
40+
41+
- name: Install armv7 libraries
42+
if: ${{ matrix.TARGET == 'armv7-unknown-linux-gnueabihf' }}
43+
run: sudo apt-get install -y libc6-armhf-cross libc6-dev-armhf-cross gcc-arm-linux-gnueabihf
44+
45+
- uses: actions-rs/cargo@v1
46+
if: ${{ matrix.TARGET != 'armv7-unknown-linux-gnueabihf' }}
47+
with:
48+
command: test
49+
args: --target=${{ matrix.TARGET }}
50+
51+
52+
- uses: actions-rs/cargo@v1
53+
if: ${{ matrix.TARGET == 'armv7-unknown-linux-gnueabihf' }}
54+
with:
55+
command: build
56+
args: --target=${{ matrix.TARGET }}
57+
58+
ci-macos:
59+
name: CI-macOS
60+
runs-on: macos-11
61+
62+
strategy:
63+
matrix:
64+
rust: [stable, 1.46.0]
65+
TARGET: [x86_64-apple-darwin]
66+
67+
steps:
68+
- uses: actions/checkout@v2
69+
70+
- uses: actions-rs/toolchain@v1
71+
with:
72+
profile: minimal
73+
toolchain: ${{ matrix.rust }}
74+
target: ${{ matrix.TARGET }}
75+
override: true
76+
77+
- uses: actions-rs/cargo@v1
78+
with:
79+
command: build
80+
args: --target=${{ matrix.TARGET }}

.github/workflows/clippy.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
on:
2+
push:
3+
branches: [ staging, trying, master ]
4+
pull_request:
5+
6+
name: Clippy check
7+
jobs:
8+
clippy_check:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: actions-rs/toolchain@v1
13+
with:
14+
profile: minimal
15+
toolchain: 1.55.0
16+
override: true
17+
components: clippy
18+
- uses: actions-rs/clippy-check@v1
19+
with:
20+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/rustfmt.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
on:
2+
push:
3+
branches: [ staging, trying, master ]
4+
pull_request:
5+
6+
name: Code formatting check
7+
8+
jobs:
9+
fmt:
10+
name: Rustfmt
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions-rs/toolchain@v1
15+
with:
16+
profile: minimal
17+
toolchain: stable
18+
override: true
19+
components: rustfmt
20+
- uses: actions-rs/cargo@v1
21+
with:
22+
command: fmt
23+
args: --all -- --check

.travis.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ authors = ["Paul Osborne <osbpau@gmail.com>"]
66
license = "MIT/Apache-2.0"
77
repository = "https://github.com/rust-embedded/rust-i2cdev"
88
homepage = "https://github.com/rust-embedded/rust-i2cdev"
9-
documentation = "http://rust-embedded.github.io/rust-i2cdev"
9+
documentation = "https://docs.rs/i2cdev"
10+
readme = "README.md"
11+
keywords = ["linux"]
12+
categories = ["embedded", "hardware-support"]
1013
description = """
1114
Provides API for safe access to Linux i2c device interface.
12-
13-
https://www.kernel.org/doc/Documentation/i2c/dev-interface
1415
"""
1516

1617
[dependencies]
1718
libc = "0.2"
1819
bitflags = "1"
1920
byteorder = "1"
20-
nix = "0.14"
21+
nix = "0.22"
2122

2223
[dev-dependencies]
2324
docopt = "1"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Rust I2cdev
22

3-
[![Build Status](https://travis-ci.org/rust-embedded/rust-i2cdev.svg?branch=master)](https://travis-ci.org/rust-embedded/rust-i2cdev)
3+
[![Build Status](https://github.com/rust-embedded/rust-i2cdev/workflows/CI/badge.svg)](https://github.com/rust-embedded/rust-i2cdev/actions)
44
[![Version](https://img.shields.io/crates/v/i2cdev.svg)](https://crates.io/crates/i2cdev)
55
[![License](https://img.shields.io/crates/l/i2cdev.svg)](https://github.com/rust-embedded/rust-i2cdev/blob/master/README.md#license)
66

@@ -53,7 +53,7 @@ cross-compile. See https://github.com/japaric/rust-cross for pointers.
5353

5454
## Minimum Supported Rust Version (MSRV)
5555

56-
This crate is guaranteed to compile on stable Rust 1.32.0 and up. It *might*
56+
This crate is guaranteed to compile on stable Rust 1.46.0 and up. It *might*
5757
compile with older versions but that may change in any new patch release.
5858

5959
## License

examples/nunchuck.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,12 @@ mod nunchuck {
4040
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
4141
match *self {
4242
NunchuckError::Error(ref e) => fmt::Display::fmt(e, f),
43-
NunchuckError::ParseError => fmt::Display::fmt(self.description(), f),
43+
NunchuckError::ParseError => write!(f, "Could not parse data"),
4444
}
4545
}
4646
}
4747

4848
impl<E: Error> Error for NunchuckError<E> {
49-
fn description(&self) -> &str {
50-
match *self {
51-
NunchuckError::Error(ref e) => e.description(),
52-
NunchuckError::ParseError => "Unable to Parse Data",
53-
}
54-
}
55-
5649
fn cause(&self) -> Option<&dyn Error> {
5750
match *self {
5851
NunchuckError::Error(ref e) => Some(e),
@@ -129,10 +122,9 @@ mod nunchuck {
129122
let mut buf: [u8; 6] = [0; 6];
130123

131124
// tell the nunchuck to prepare a sample
132-
try!(self
133-
.i2cdev
125+
self.i2cdev
134126
.smbus_write_byte(0x00)
135-
.map_err(NunchuckError::Error));
127+
.map_err(NunchuckError::Error)?;
136128

137129
// now, read it!
138130
thread::sleep(Duration::from_millis(10));

examples/sensors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ mod sensors {
173173
i2cdev.smbus_write_byte_data(REGISTER_POWER_CTL, 0x00)?;
174174

175175
// configure some defaults
176-
try!(i2cdev
177-
.smbus_write_byte_data(REGISTER_BW_RATE, ADXL345DataRate::RATE_1600HZ as u8));
176+
i2cdev
177+
.smbus_write_byte_data(REGISTER_BW_RATE, ADXL345DataRate::RATE_1600HZ as u8)?;
178178
i2cdev.smbus_write_byte_data(REGISTER_DATA_FORMAT, 0x08)?;
179179
i2cdev.smbus_write_byte_data(REGISTER_OFSX, 0xFD)?;
180180
i2cdev.smbus_write_byte_data(REGISTER_OFSY, 0x03)?;

0 commit comments

Comments
 (0)