Skip to content

Commit a6b8adc

Browse files
bors[bot]ryankurte
andauthored
Merge #57
57: Add github actions CI r=eldruin a=ryankurte Replaces #56, just adding the actions executor without swapping bors or removing travis. Odds are this doesn't work but, seemingly one can't add actions to a repo from a branch so it has to be manually merged anyway and fixed in PRs... @posborne seem (un)reasonable? Co-authored-by: ryan <[email protected]>
2 parents e9076f8 + a917a33 commit a6b8adc

File tree

4 files changed

+117
-24
lines changed

4 files changed

+117
-24
lines changed

.github/workflows/ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
fail-fast: false
15+
matrix:
16+
# All generated code should be running on stable now
17+
rust: [stable]
18+
19+
# The default target we're compiling on and for
20+
TARGET: [x86_64-unknown-linux-gnu, armv7-unknown-linux-gnueabihf]
21+
22+
include:
23+
# Test MSRV
24+
- rust: 1.35.0
25+
TARGET: x86_64-unknown-linux-gnu
26+
27+
# Test nightly but don't fail
28+
- rust: nightly
29+
experimental: true
30+
TARGET: x86_64-unknown-linux-gnu
31+
32+
steps:
33+
- uses: actions/checkout@v2
34+
35+
- uses: actions-rs/toolchain@v1
36+
with:
37+
profile: minimal
38+
toolchain: ${{ matrix.rust }}
39+
target: ${{ matrix.TARGET }}
40+
override: true
41+
42+
- name: Install armv7 libraries
43+
if: ${{ matrix.TARGET == 'armv7-unknown-linux-gnueabihf' }}
44+
run: sudo apt-get install -y libc6-armhf-cross libc6-dev-armhf-cross gcc-arm-linux-gnueabihf
45+
46+
- uses: actions-rs/cargo@v1
47+
with:
48+
command: check
49+
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: stable
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

src/lib.rs

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ pub use sysfs_gpio;
2525
#[cfg(feature = "gpio_cdev")]
2626
pub use gpio_cdev;
2727

28-
2928
use core::convert::Infallible;
3029
use std::io::{self, Write};
3130
use std::path::{Path, PathBuf};
@@ -202,19 +201,19 @@ impl embedded_hal::blocking::i2c::WriteRead for I2cdev {
202201
buffer: &mut [u8],
203202
) -> Result<(), Self::Error> {
204203
self.set_address(address)?;
205-
let mut messages = [
206-
LinuxI2CMessage::write(bytes),
207-
LinuxI2CMessage::read(buffer),
208-
];
204+
let mut messages = [LinuxI2CMessage::write(bytes), LinuxI2CMessage::read(buffer)];
209205
self.inner.transfer(&mut messages).map(drop)
210206
}
211207
}
212208

213209
impl embedded_hal::blocking::i2c::Transactional for I2cdev {
214210
type Error = i2cdev::linux::LinuxI2CError;
215211

216-
fn try_exec(&mut self, address: u8, operations: &mut [I2cOperation]) -> Result<(), Self::Error>
217-
{
212+
fn try_exec(
213+
&mut self,
214+
address: u8,
215+
operations: &mut [I2cOperation],
216+
) -> Result<(), Self::Error> {
218217
// Map operations from generic to linux objects
219218
let mut messages: Vec<_> = operations
220219
.as_mut()
@@ -280,30 +279,32 @@ impl embedded_hal::blocking::spi::Write<u8> for Spidev {
280279
}
281280
}
282281

283-
pub use embedded_hal::blocking::spi::{Operation as SpiOperation};
282+
pub use embedded_hal::blocking::spi::Operation as SpiOperation;
284283

285284
/// Transactional implementation batches SPI operations into a single transaction
286285
impl embedded_hal::blocking::spi::Transactional<u8> for Spidev {
287286
type Error = io::Error;
288287

289288
fn try_exec<'a>(&mut self, operations: &mut [SpiOperation<'a, u8>]) -> Result<(), Self::Error> {
290-
291289
// Map types from generic to linux objects
292-
let mut messages: Vec<_> = operations.iter_mut().map(|a| {
293-
match a {
294-
SpiOperation::Write(w) => SpidevTransfer::write(w),
295-
SpiOperation::Transfer(r) => {
296-
// Clone read to write pointer
297-
// SPIdev is okay with having w == r but this is tricky to achieve in safe rust
298-
let w = unsafe {
299-
let p = r.as_ptr();
300-
std::slice::from_raw_parts(p, r.len())
301-
};
302-
303-
SpidevTransfer::read_write(w, r)
304-
},
305-
}
306-
}).collect();
290+
let mut messages: Vec<_> = operations
291+
.iter_mut()
292+
.map(|a| {
293+
match a {
294+
SpiOperation::Write(w) => SpidevTransfer::write(w),
295+
SpiOperation::Transfer(r) => {
296+
// Clone read to write pointer
297+
// SPIdev is okay with having w == r but this is tricky to achieve in safe rust
298+
let w = unsafe {
299+
let p = r.as_ptr();
300+
std::slice::from_raw_parts(p, r.len())
301+
};
302+
303+
SpidevTransfer::read_write(w, r)
304+
}
305+
}
306+
})
307+
.collect();
307308

308309
// Execute transfer
309310
self.0.transfer_multiple(&mut messages)

0 commit comments

Comments
 (0)