Skip to content

Commit a562213

Browse files
authored
Setup Github Actions (#2)
* Setup Github Actions * Update source. * Remove needless main. * Add .vscode. * ++ * ++ * ++ * Add docs. * Fix windows tests. * ++ * ++ * ++ * ++ * ++ * ++
1 parent 063f435 commit a562213

File tree

11 files changed

+199
-142
lines changed

11 files changed

+199
-142
lines changed

.github/workflows/docs.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
concurrency:
8+
group: deploy
9+
cancel-in-progress: false
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Install Rust
22+
uses: actions-rust-lang/setup-rust-toolchain@v1
23+
24+
- name: Cache Dependencies
25+
uses: actions/cache@v4
26+
with:
27+
path: |
28+
~/.cargo/registry
29+
~/.cargo/git
30+
target
31+
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
32+
restore-keys: |
33+
${{ runner.os }}-rust-
34+
35+
- name: Setup pages
36+
id: pages
37+
uses: actions/configure-pages@v5
38+
39+
- name: Clean docs folder
40+
run: cargo clean --doc
41+
42+
- name: Build docs
43+
run: cargo doc --no-deps
44+
45+
- name: Add redirect
46+
run: echo '<meta http-equiv="refresh" content="0;url=aoc/index.html">' > target/doc/index.html
47+
48+
- name: Remove lock file
49+
run: rm target/doc/.lock
50+
51+
- name: Upload artifact
52+
uses: actions/upload-pages-artifact@v3
53+
with:
54+
path: target/doc
55+
56+
deploy:
57+
runs-on: ubuntu-latest
58+
needs: build
59+
permissions:
60+
pages: write
61+
id-token: write
62+
environment:
63+
name: github-pages
64+
url: ${{ steps.deployment.outputs.page_url }}
65+
steps:
66+
- name: Deploy to GitHub Pages
67+
id: deployment
68+
uses: actions/deploy-pages@v4

.github/workflows/rust.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Rust
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
pull_request:
8+
branches: [ "main" ]
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
13+
jobs:
14+
build:
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os:
20+
- ubuntu-latest
21+
- windows-latest
22+
- macos-latest
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Install Rust
29+
uses: actions-rust-lang/setup-rust-toolchain@v1
30+
with:
31+
components: rustfmt, clippy
32+
33+
- name: Cache Dependencies
34+
uses: actions/cache@v4
35+
with:
36+
path: |
37+
~/.cargo/registry
38+
~/.cargo/git
39+
target
40+
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
41+
restore-keys: |
42+
${{ runner.os }}-rust-
43+
44+
- name: Format
45+
uses: actions-rust-lang/rustfmt@v1
46+
47+
- name: Lint
48+
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
49+
env:
50+
RUSTFLAGS: "-D warnings"
51+
52+
- name: Install Tools
53+
uses: taiki-e/install-action@v2
54+
with:
55+
tool: cargo-llvm-cov, nextest
56+
57+
- name: Test
58+
run: cargo llvm-cov nextest --no-fail-fast --lcov --output-path lcov.info
59+
60+
- name: Upload Coverage
61+
if: matrix.os == 'ubuntu-latest'
62+
uses: codecov/codecov-action@v3
63+
with:
64+
files: lcov.info
65+
fail_ci_if_error: true
66+
token: ${{ secrets.CODECOV_TOKEN }}

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"rust-analyzer.check.extraArgs": [
3+
"--all-features",
4+
"--",
5+
"-D warnings"
6+
],
7+
"rust-analyzer.check.command": "clippy"
8+
}

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ default-features = false
3131
[dev-dependencies]
3232
libc = "0.2.172"
3333
serde_json = "1.0.140"
34+
serde_test = "1.0.177"

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ Unix exit code from a raw integer:
3636
```rust
3737
use proc_result::unix::ExitCode;
3838

39-
fn main() {
40-
let code = ExitCode::from_raw(1);
41-
if code.is_success() {
42-
println!("Command succeeded!");
43-
} else {
44-
eprintln!("Command failed with exit code: {}", code);
45-
}
39+
let code = ExitCode::from_raw(1);
40+
if code.is_success() {
41+
println!("Command succeeded!");
42+
} else {
43+
eprintln!("Command failed with exit code: {}", code);
4644
}
4745
```
4846

src/unix/exit_code.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ use crate::raw::RawExitCode;
44

55
/// A Unix-like exit code.
66
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7-
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7+
#[cfg_attr(
8+
feature = "serde",
9+
derive(serde::Serialize, serde::Deserialize),
10+
serde(transparent)
11+
)]
812
pub struct ExitCode(u8);
913

1014
impl ExitCode {

src/unix/signal.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ use core::fmt::Display;
44
///
55
/// Represents a signal that can be sent to or received by processes on Unix-like systems.
66
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7-
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7+
#[cfg_attr(
8+
feature = "serde",
9+
derive(serde::Serialize, serde::Deserialize),
10+
serde(transparent)
11+
)]
812
pub struct Signal(u8);
913

1014
impl Signal {

0 commit comments

Comments
 (0)