Skip to content

Commit 7dac32d

Browse files
Added github actions for PRs (#3)
* Added github actions for PRs * Added some rustfmt::skip attributes * Applied formatting * Added rustfmt component in action * Configured to use rustfmt version 2 which fixes some comment formatting * Removed ready_for_review condition for github actions Since it has the synchronize condition, it will update after each commit, whether in draft or not, so I think this should be alright
1 parent a2372d1 commit 7dac32d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+2389
-1567
lines changed

.clippy.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv = "1.60.0"
1+
msrv = "1.70.0"

.github/workflows/clippy.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: clippy
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
clippy:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
submodules: true
19+
20+
- name: Install dependencies
21+
run: |
22+
sudo apt-get install -y alsa-base libasound2-dev libxkbcommon-dev
23+
24+
- name: Select rust version
25+
run: |
26+
rustup toolchain install 1.70 --profile minimal --no-self-update
27+
rustup default 1.70
28+
rustup component add clippy
29+
30+
- name: Check clippy
31+
run: |
32+
cargo clippy
File renamed without changes.

.github/workflows/rustdoc.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: rustdoc
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
rustdocs:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
submodules: true
19+
20+
- name: Install dependencies
21+
run: |
22+
sudo apt-get install -y alsa-base libasound2-dev libxkbcommon-dev
23+
24+
- name: Select rust version
25+
run: |
26+
rm Cargo.lock
27+
rustup toolchain install nightly --profile minimal --no-self-update
28+
rustup default nightly
29+
30+
- name: Build rustdoc
31+
run: |
32+
RUSTDOCFLAGS="--deny=warnings --cfg=docsrs" cargo doc --all-features

.github/workflows/rustfmt.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: rustfmt
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
rustfmt:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
submodules: true
19+
20+
- name: Install dependencies
21+
run: |
22+
sudo apt-get install -y alsa-base libasound2-dev libxkbcommon-dev
23+
24+
- name: Select rust version
25+
run: |
26+
rustup toolchain install nightly --profile minimal --no-self-update
27+
rustup default nightly
28+
rustup component add rustfmt
29+
30+
- name: Check rustfmt
31+
run: |
32+
cargo +nightly fmt --check

.github/workflows/test.yaml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: test
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
9+
permissions:
10+
contents: read
11+
12+
env:
13+
RUSTFLAGS: '--deny warnings'
14+
15+
jobs:
16+
test-ubuntu:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
submodules: true
22+
23+
- name: Install dependencies
24+
run: |
25+
sudo apt-get install -y alsa-base libasound2-dev libxkbcommon-dev
26+
27+
- name: Select rust version
28+
run: |
29+
rustup toolchain install 1.70 --profile minimal --no-self-update
30+
rustup default 1.70
31+
32+
- name: Run tests with default features
33+
run: |
34+
cargo test
35+
36+
- name: Run tests with all features
37+
run: |
38+
cargo test #--features=std,fugit,femtos
39+
40+
- name: Run test with no_std
41+
run: |
42+
cargo test --no-default-features
43+
44+

.rustfmt.toml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
edition = "2021"
2+
version = "Two"
3+
4+
max_width = 132
5+
6+
struct_lit_width = 0 # default 18 (24)
7+
fn_call_width=100 # default 60 (80)
8+
array_width=132 # default 60 (80)
9+
#chain_width=100 # default 60 (80)
10+
#attr_fn_like_width=100 # default 70 (92)
11+
#single_line_if_else_max_width=100 # default 50 (66)
12+
#struct_variant_width = 0 # default 35 (46)
13+
14+
newline_style = "Unix"
15+
reorder_imports = false
16+
match_block_trailing_comma = true
17+
18+
## Experimental Features
19+
unstable_features = true
20+
blank_lines_upper_bound = 3
21+
overflow_delimited_expr = true
22+
23+
# it would be nice to allow a newline at the top and bottom of file
24+
# it would be nice to not erase the whitespace between the end of the code line and start of a comment on the same line

Cargo.lock

-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

emulator/core/src/devices.rs

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
use std::rc::Rc;
32
use std::cell::{RefCell, RefMut, BorrowMutError};
43
use std::sync::atomic::{AtomicUsize, Ordering};
@@ -17,7 +16,7 @@ pub type Address = u64;
1716
/// information that might be helpful for debugging.
1817
pub trait Steppable {
1918
fn step(&mut self, system: &System) -> Result<Duration, Error>;
20-
fn on_error(&mut self, _system: &System) { }
19+
fn on_error(&mut self, _system: &System) {}
2120
}
2221

2322
/// A device that can receive an interrupt. The `interrupt_state_change()` method
@@ -104,30 +103,22 @@ pub trait Addressable {
104103

105104
#[inline]
106105
pub fn read_beu16(data: &[u8]) -> u16 {
107-
(data[0] as u16) << 8 |
108-
(data[1] as u16)
106+
(data[0] as u16) << 8 | (data[1] as u16)
109107
}
110108

111109
#[inline]
112110
pub fn read_leu16(data: &[u8]) -> u16 {
113-
(data[1] as u16) << 8 |
114-
(data[0] as u16)
111+
(data[1] as u16) << 8 | (data[0] as u16)
115112
}
116113

117114
#[inline]
118115
pub fn read_beu32(data: &[u8]) -> u32 {
119-
(data[0] as u32) << 24 |
120-
(data[1] as u32) << 16 |
121-
(data[2] as u32) << 8 |
122-
(data[3] as u32)
116+
(data[0] as u32) << 24 | (data[1] as u32) << 16 | (data[2] as u32) << 8 | (data[3] as u32)
123117
}
124118

125119
#[inline]
126120
pub fn read_leu32(data: &[u8]) -> u32 {
127-
(data[3] as u32) << 24 |
128-
(data[2] as u32) << 16 |
129-
(data[1] as u32) << 8 |
130-
(data[0] as u32)
121+
(data[3] as u32) << 24 | (data[2] as u32) << 16 | (data[1] as u32) << 8 | (data[0] as u32)
131122
}
132123

133124

@@ -239,7 +230,7 @@ pub struct Device(DeviceId, TransmutableBox);
239230
impl Device {
240231
pub fn new<T>(value: T) -> Self
241232
where
242-
T: Transmutable + 'static
233+
T: Transmutable + 'static,
243234
{
244235
Self(DeviceId::new(), wrap_transmutable(value))
245236
}

emulator/core/src/error.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
use std::fmt;
32
use moa_host::HostError;
43

@@ -52,10 +51,7 @@ impl Error {
5251

5352
pub fn msg(&self) -> &str {
5453
match self {
55-
Error::Assertion(msg) |
56-
Error::Breakpoint(msg) |
57-
Error::Other(msg) |
58-
Error::Emulator(_, msg) => msg.as_str(),
54+
Error::Assertion(msg) | Error::Breakpoint(msg) | Error::Other(msg) | Error::Emulator(_, msg) => msg.as_str(),
5955
Error::Processor(_) => "native exception",
6056
}
6157
}
@@ -64,10 +60,7 @@ impl Error {
6460
impl fmt::Display for Error {
6561
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6662
match self {
67-
Error::Assertion(msg) |
68-
Error::Breakpoint(msg) |
69-
Error::Other(msg) |
70-
Error::Emulator(_, msg) => write!(f, "{}", msg),
63+
Error::Assertion(msg) | Error::Breakpoint(msg) | Error::Other(msg) | Error::Emulator(_, msg) => write!(f, "{}", msg),
7164
Error::Processor(_) => write!(f, "native exception"),
7265
}
7366
}
@@ -78,4 +71,3 @@ impl<E> From<HostError<E>> for Error {
7871
Self::Other("other".to_string())
7972
}
8073
}
81-

emulator/core/src/interrupts.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
use crate::error::Error;
32

43

@@ -43,4 +42,3 @@ impl InterruptController {
4342
Ok(acknowledge)
4443
}
4544
}
46-

emulator/core/src/lib.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#[macro_use]
32
mod error;
43

@@ -7,12 +6,15 @@ mod interrupts;
76
mod memory;
87
mod system;
98

10-
pub use crate::devices::{Address, Addressable, Steppable, Interruptable, Debuggable, Inspectable, Transmutable, TransmutableBox, Device};
11-
pub use crate::devices::{read_beu16, read_beu32, read_leu16, read_leu32, write_beu16, write_beu32, write_leu16, write_leu32, wrap_transmutable};
9+
pub use crate::devices::{
10+
Address, Addressable, Steppable, Interruptable, Debuggable, Inspectable, Transmutable, TransmutableBox, Device,
11+
};
12+
pub use crate::devices::{
13+
read_beu16, read_beu32, read_leu16, read_leu32, write_beu16, write_beu32, write_leu16, write_leu32, wrap_transmutable,
14+
};
1215
pub use crate::error::Error;
1316
pub use crate::interrupts::InterruptController;
1417
pub use crate::memory::{MemoryBlock, AddressTranslator, AddressRepeater, Bus, BusPort, dump_slice, dump_memory};
1518
pub use crate::system::System;
1619

1720
pub use emulator_hal::bus::{BusAccess};
18-

0 commit comments

Comments
 (0)