Skip to content

Commit

Permalink
Dev add ci (#43)
Browse files Browse the repository at this point in the history
* add CI

* cargo fmt
  • Loading branch information
loongs-zhang authored Sep 5, 2023
1 parent da861cb commit 55b28ce
Show file tree
Hide file tree
Showing 18 changed files with 664 additions and 76 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: cargo
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
allow:
- dependency-type: direct
- dependency-type: indirect
83 changes: 83 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
on:
push:
pull_request:

jobs:
test:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.target == 'i686-pc-windows-gnu' && format('{0}-i686-pc-windows-gnu', matrix.channel) || matrix.channel }}
target: ${{ matrix.target }}
override: true
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Run cargo release test
uses: actions-rs/cargo@v1
with:
command: test
args: --release --all
env:
CHANNEL: ${{ matrix.channel }}
CROSS: ${{ !startsWith(matrix.target, 'x86_64') && contains(matrix.target, 'linux') && '1' || '0' }}
TARGET: ${{ matrix.target }}
NO_RUN: ${{ matrix.no_run }}

strategy:
fail-fast: false
matrix:
target: [
x86_64-unknown-linux-gnu,
i686-unknown-linux-gnu,
aarch64-unknown-linux-gnu,
armv7-unknown-linux-gnueabihf,
riscv64gc-unknown-linux-gnu,
mips64-unknown-linux-muslabi64,
loongarch64-unknown-linux-gnu,
s390x-unknown-linux-gnu,

x86_64-apple-darwin,
aarch64-apple-darwin,

x86_64-pc-windows-gnu,
x86_64-pc-windows-msvc,
i686-pc-windows-gnu,
i686-pc-windows-msvc,
]
channel: [stable, nightly]
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: i686-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
- target: armv7-unknown-linux-gnueabihf
os: ubuntu-latest
- target: riscv64gc-unknown-linux-gnu
os: ubuntu-latest
- target: mips64-unknown-linux-muslabi64
os: ubuntu-latest
- target: loongarch64-unknown-linux-gnu
os: ubuntu-latest
- target: s390x-unknown-linux-gnu
os: ubuntu-latest

- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest

- target: x86_64-pc-windows-msvc
os: windows-latest
- target: x86_64-pc-windows-gnu
os: windows-latest
- target: i686-pc-windows-msvc
os: windows-latest
- target: i686-pc-windows-gnu
os: windows-latest
39 changes: 39 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Code Coverage

on:
push:
paths-ignore:
- '**.md'
- '**.png'

env:
RUST_TOOLCHAIN: nightly
TOOLCHAIN_PROFILE: minimal

jobs:
coverage:
name: Run cargo coverage
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: ${{ env.TOOLCHAIN_PROFILE }}
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
components: llvm-tools-preview
- name: Install grcov
uses: actions-rs/cargo@v1
with:
command: install
args: grcov
- name: Cache
uses: Swatinem/rust-cache@v1
- name: Run cargo test
run: sudo bash -c "ulimit -Sl 512 && ulimit -Hl 512 && sudo -u runner RUSTUP_TOOLCHAIN=nightly RUSTFLAGS="-Zinstrument-coverage" LLVM_PROFILE_FILE="coverage-%p-%m.profraw" RUST_BACKTRACE=1 /home/runner/.cargo/bin/cargo test --all-features"
- name: Run grcov
run: grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "*cargo*" -o lcov.info
- name: Upload coverage
run: bash <(curl -s https://codecov.io/bash) -f lcov.info
32 changes: 32 additions & 0 deletions .github/workflows/pr-audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Pull Request Security Audit

on:
push:
paths:
- '**/Cargo.toml'
pull_request:
paths:
- '**/Cargo.toml'

jobs:
security-audit:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'ci skip')"
steps:
- uses: actions/checkout@v2

- name: Install cargo-audit
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-audit

- name: Generate lockfile
uses: actions-rs/cargo@v1
with:
command: generate-lockfile

- name: Audit dependencies
uses: actions-rs/cargo@v1
with:
command: audit
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ ppc32 | SYSV (ELF), XCOFF | - | SYSV (MACH-O) | -
ppc64 | SYSV (ELF), XCOFF | - | SYSV (MACH-O) | -
loongarch64 | SYSV (ELF) | - | - | -
riscv64 | SYSV (ELF) | - | - | -
s390x | SYSV (ELF) | - | - | -

Format: `ABI (binary format)`.
Source: [Boost.Context](http://www.boost.org/doc/libs/1_60_0/libs/context/doc/html/context/architectures.html)
2 changes: 1 addition & 1 deletion benches/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
extern crate context;
extern crate test;

use context::stack::{Stack, FixedSizeStack, ProtectedFixedSizeStack};
use context::stack::{FixedSizeStack, ProtectedFixedSizeStack, Stack};
use test::Bencher;

#[bench]
Expand Down
7 changes: 4 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

extern crate cc;

use std::path::PathBuf;
use std::env;
use std::path::PathBuf;

fn main() {
let target: String = env::var("TARGET").unwrap();
Expand All @@ -24,9 +24,10 @@ fn main() {
"powerpc" => "ppc32",
"powerpc64" => "ppc64",
"x86_64" => "x86_64",
"mips64" => "mips64",
"mips64" | "mips64el" => "mips64",
"loongarch64" => "loongarch64",
"riscv64" => "riscv64",
"riscv64gc" => "riscv64",
"s390x" => "s390x",
_ => {
panic!("Unsupported architecture: {}", target);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

extern crate context;

use context::{Context, Transfer};
use context::stack::ProtectedFixedSizeStack;
use context::{Context, Transfer};

// Print the natural numbers from 0 to 9 using a "generator" preserving state on the stack.
fn main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/fibonacci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

extern crate context;

use context::{Context, Transfer};
use context::stack::ProtectedFixedSizeStack;
use context::{Context, Transfer};

// Print the natural numbers from 0 to 9 using a "generator" preserving state on the stack.
fn main() {
Expand Down
6 changes: 4 additions & 2 deletions examples/how_to_ontop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
extern crate context;
use std::panic;

use context::{Context, Transfer};
use context::stack::ProtectedFixedSizeStack;
use context::{Context, Transfer};

// This struct is used to demonstrate that the stack is actually being unwound.
struct Dropper;
Expand Down Expand Up @@ -82,7 +82,9 @@ extern "C" fn context_function(t: Transfer) -> ! {
let stack_ref = stack_ref_from_some_stack(&mut some_stack);

let (result, context) = {
let mut carrier = Carrier { context: Some(t.context) };
let mut carrier = Carrier {
context: Some(t.context),
};

let carrier_ptr = &mut carrier as *mut _ as usize;

Expand Down
Loading

0 comments on commit 55b28ce

Please sign in to comment.