Skip to content

Commit 9d1e2a0

Browse files
Merge #44
44: Migrate to GitHub Actions r=adamgreig a=thalesfragoso @adamgreig Could you please take a look at this PR ? I still don't completely understand some of GHA's syntax, thanks. Co-authored-by: Thales Fragoso <thales.fragosoz@gmail.com>
2 parents a947c06 + 00150da commit 9d1e2a0

File tree

10 files changed

+134
-93
lines changed

10 files changed

+134
-93
lines changed

.github/bors.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
block_labels = ["needs-decision"]
22
delete_merged_branches = true
33
required_approvals = 1
4-
status = ["continuous-integration/travis-ci/push"]
4+
status = [
5+
"ci (thumbv6m-none-eabi)",
6+
"ci (thumbv7m-none-eabi)",
7+
"clippy",
8+
"rustfmt",
9+
]

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
on:
2+
push:
3+
branches: [ staging, trying, master ]
4+
pull_request:
5+
6+
name: Continuous integration
7+
8+
jobs:
9+
ci:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
target:
14+
- thumbv6m-none-eabi
15+
- thumbv7m-none-eabi
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- uses: actions-rs/toolchain@v1
20+
with:
21+
profile: minimal
22+
toolchain: nightly
23+
target: ${{ matrix.target }}
24+
override: true
25+
- uses: actions-rs/cargo@v1
26+
with:
27+
command: check
28+
args: --target=${{ matrix.target }} --examples

.github/workflows/clippy.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
on:
2+
push:
3+
branches: [ staging, trying, master ]
4+
pull_request_target:
5+
6+
name: Clippy check
7+
8+
jobs:
9+
clippy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
if: github.event_name == 'pull_request_target'
14+
with:
15+
ref: refs/pull/${{ github.event.number }}/head
16+
- uses: actions/checkout@v2
17+
if: github.event_name != 'pull_request_target'
18+
- uses: actions-rs/toolchain@v1
19+
with:
20+
profile: minimal
21+
toolchain: nightly
22+
override: true
23+
components: clippy
24+
- uses: actions-rs/clippy-check@v1
25+
with:
26+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/cron.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
on:
2+
schedule:
3+
# Run every week at 8am UTC Saturday.
4+
- cron: '0 8 * * SAT'
5+
6+
name: Cron CI
7+
8+
jobs:
9+
ci-cron:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions-rs/toolchain@v1
14+
with:
15+
profile: minimal
16+
toolchain: nightly
17+
target: thumbv6m-none-eabi
18+
override: true
19+
- uses: actions-rs/cargo@v1
20+
with:
21+
command: check
22+
args: --examples
23+
- uses: imjohnbo/issue-bot@v2
24+
if: failure()
25+
with:
26+
title: CI Failure
27+
labels: ci
28+
body: |
29+
Scheduled CI run failed. Details:
30+
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/rustfmt.yml

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

.travis.yml

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

ci/install.sh

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

ci/script.sh

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

examples/global_alloc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
extern crate alloc;
66

7-
use core::panic::PanicInfo;
8-
use core::alloc::Layout;
97
use alloc::vec::Vec;
108
use alloc_cortex_m::CortexMHeap;
9+
use core::alloc::Layout;
10+
use core::panic::PanicInfo;
1111
use cortex_m_rt::entry;
1212

1313
#[global_allocator]

src/lib.rs

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
99
#![no_std]
1010

11-
use core::cell::RefCell;
1211
use core::alloc::{GlobalAlloc, Layout};
12+
use core::cell::RefCell;
1313
use core::ptr::NonNull;
1414

1515
use cortex_m::interrupt::Mutex;
@@ -55,48 +55,39 @@ impl CortexMHeap {
5555
/// - `size > 0`
5656
pub unsafe fn init(&self, start_addr: usize, size: usize) {
5757
cortex_m::interrupt::free(|cs| {
58-
self.heap
59-
.borrow(cs)
60-
.borrow_mut()
61-
.init(start_addr, size);
58+
self.heap.borrow(cs).borrow_mut().init(start_addr, size);
6259
});
6360
}
6461

6562
/// Returns an estimate of the amount of bytes in use.
6663
pub fn used(&self) -> usize {
67-
cortex_m::interrupt::free(|cs| {
68-
self.heap
69-
.borrow(cs)
70-
.borrow_mut()
71-
.used()
72-
})
64+
cortex_m::interrupt::free(|cs| self.heap.borrow(cs).borrow_mut().used())
7365
}
7466

7567
/// Returns an estimate of the amount of bytes available.
7668
pub fn free(&self) -> usize {
77-
cortex_m::interrupt::free(|cs| {
78-
self.heap
79-
.borrow(cs)
80-
.borrow_mut()
81-
.free()
82-
})
69+
cortex_m::interrupt::free(|cs| self.heap.borrow(cs).borrow_mut().free())
8370
}
8471
}
8572

8673
unsafe impl GlobalAlloc for CortexMHeap {
8774
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
88-
cortex_m::interrupt::free(|cs| self.heap
89-
.borrow(cs)
90-
.borrow_mut()
91-
.allocate_first_fit(layout)
92-
.ok()
93-
.map_or(0 as *mut u8, |allocation| allocation.as_ptr()))
75+
cortex_m::interrupt::free(|cs| {
76+
self.heap
77+
.borrow(cs)
78+
.borrow_mut()
79+
.allocate_first_fit(layout)
80+
.ok()
81+
.map_or(0 as *mut u8, |allocation| allocation.as_ptr())
82+
})
9483
}
9584

9685
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
97-
cortex_m::interrupt::free(|cs| self.heap
98-
.borrow(cs)
99-
.borrow_mut()
100-
.deallocate(NonNull::new_unchecked(ptr), layout));
86+
cortex_m::interrupt::free(|cs| {
87+
self.heap
88+
.borrow(cs)
89+
.borrow_mut()
90+
.deallocate(NonNull::new_unchecked(ptr), layout)
91+
});
10192
}
10293
}

0 commit comments

Comments
 (0)