Skip to content

Commit

Permalink
chore: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pedromfedricci committed Nov 4, 2024
0 parents commit 29c2d11
Show file tree
Hide file tree
Showing 28 changed files with 4,488 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[profile.default-miri]
test-threads = "num-cpus"
slow-timeout = { period = "120s", terminate-after = 2 }
7 changes: 7 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2

updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
172 changes: 172 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust stable
run: rustup toolchain install stable
- name: Check format
run: cargo fmt -- --check

no-std:
name: No std
runs-on: ubuntu-latest
env:
NO_STD_TARGET: thumbv7m-none-eabi
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust stable
run: rustup toolchain install stable
- name: Add no_std target
run: rustup target add ${{ env.NO_STD_TARGET }}
- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: Build on no_std environment
run: >
cargo hack build
--target ${{ env.NO_STD_TARGET }}
--no-dev-deps
--feature-powerset
--skip yield,thread_local
msrv:
name: MSRV
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust 1.70.0
run: rustup toolchain install 1.70.0
- name: Set Rust 1.70.0 as default
run: rustup default 1.70.0
- name: Check MSRV
run: cargo check --all-features

docsrs:
name: Build doc
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust nightly
run: rustup toolchain install nightly
- name: Set Rust nightly as default
run: rustup default nightly
- name: Build docs
env:
RUSTDOCFLAGS: --cfg docsrs -D warnings
run: cargo doc --all-features

doc:
name: Test doc
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust stable
run: rustup toolchain install stable
- name: Run doc snippets
run: cargo test --doc --all-features

examples:
name: Examples
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust stable
run: rustup toolchain install stable
- name: Run raw example
run: cargo run --example raw
- name: Run thread_local example
run: cargo run --example thread_local --features thread_local

linter:
name: Linter
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust stable
run: rustup toolchain install stable
- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: Lint feature powerset
env:
RUSTFLAGS: -D warnings -D clippy::pedantic -D clippy::nursery
run: cargo hack clippy --feature-powerset --no-dev-deps
- name: Lint test profile
env:
RUSTFLAGS: -D warnings -D clippy::pedantic -D clippy::nursery
run: cargo hack clippy --profile test --feature-powerset --no-dev-deps
- name: Lint loom
env:
RUSTFLAGS: --cfg loom -D warnings -D clippy::pedantic -D clippy::nursery
run: cargo hack clippy --profile test --feature-powerset

# coverage:
# name: Coverage
# runs-on: ubuntu-latest
# container:
# image: xd009642/tarpaulin:latest
# options: --security-opt seccomp=unconfined
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# - name: Generate coverage
# run: >
# cargo tarpaulin
# --verbose
# --engine llvm
# --all-features
# --out xml
# - name: Upload to Codecov
# uses: codecov/codecov-action@v3
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

miri:
name: Miri
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust nightly and Miri
# NOTE: not all nightly releases come with Miri
run: rustup toolchain install nightly --component miri
- name: Set Rust nightly as default
run: rustup default nightly
# NOTE: Nextest is configure to run Miri against `num-cpus` threads.
- name: Install latest nextest release
uses: taiki-e/install-action@nextest
- name: Miri test
run: cargo miri nextest run --all-features

loom:
name: Loom
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust stable
run: rustup toolchain install stable
- name: Loom test
env:
RUSTFLAGS: --cfg loom
run: cargo test --lib --release --all-features
19 changes: 19 additions & 0 deletions .github/workflows/semver.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Semver

on:
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
semver:
name: Check semver
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust stable
run: rustup toolchain install stable
- name: Check semver violations
uses: obi1kenobi/cargo-semver-checks-action@v2
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/target
/.helix
/Cargo.lock
/cobertura.xml
/cliff.toml
/TODO.txt
39 changes: 39 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[package]
description = """
An implementation of Dave Dice's scalable, concurrency restrictive and eventually
fair lock for mutual exclusion, referred to as Malthusian Lock.
"""
name = "malthlock"
version = "0.1.0"
edition = "2021"
# NOTE: Rust 1.70 is required for `AtomicPtr::as_ptr`.
rust-version = "1.70.0"
license = "MIT OR Apache-2.0"
readme = "README.md"
documentation = "https://docs.rs/malthlock"
repository = "https://github.com/pedromfedricci/malthlock"
authors = ["Pedro de Matos Fedricci <[email protected]>"]
categories = ["algorithms", "concurrency"]
keywords = ["mutex", "spinlock", "synchronization"]

[features]
yield = []
thread_local = []

[dependencies.rand_xoshiro]
version = "0.6"

[target.'cfg(loom)'.dev-dependencies.loom]
version = "0.7"

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = ["cfg(loom)", "cfg(tarpaulin)", "cfg(tarpaulin_include)"]

[[example]]
name = "thread_local"
required-features = ["thread_local"]
Loading

0 comments on commit 29c2d11

Please sign in to comment.